Context

Functions on Sonr are user-defined functions that can be accessed via HTTP. These functions provide a flexible and customizable way to interact with the platform. Users can invoke these functions by sending a request to a static endpoint, which includes the function name and a parameter. The parameter is obtained from ipfs using the specified CID, ensuring the reliability and security of the data. By leveraging this mechanism, users can easily integrate their own logic and algorithms into the Sonr platform, expanding its capabilities and possibilities.


Objective


Solution

The proposed solution aims to enable the deployment and invocation of user-defined functions, allowing for custom-defined behavior and interaction with the chain, ultimately enhancing the capabilities and possibilities of the Sonr platform.


Definitions


Sequence Methods

1. Calling a Function

Static and Variable functions are useful when the function needs to make its own interaction with the chain or fund calls within. A function that’s invoked should have the following defined within the body of the HTTP request. The Response will simply be an empty body with an HTTP status.

Parameters Description
DID A DID which uniquely identifies the function
Label A label for conveniently referencing the function.
CID Reflects whether or not the bucket is active. Inactive functions cannot be modified.
Metadata A map that stores the encrypted keys for each party who should have access to the content referenced by a CID. Each CID entry contains a map of public keys (those of the members being granted access) to the JWK encrypted with that public key (PK). This allows the user to find the JWK they need to decrypt the data found with CID.
CallbackURLs Maps developer-defined keys to the CID for content. Content is posted via the APIs described below and can be found again via this map.