Metadata
The metadata is the backbone of every mini-app built using the Sherry SDK. It’s a structured JSON object that defines how your mini-app behaves, how it interacts with blockchain smart contracts, and how it is rendered for users.
By carefully crafting the metadata, developers can create mini-apps tailored to various use cases, from executing token swaps to interacting with complex decentralized protocols.
Here’s a breakdown of a sample metadata object:
- type *: Indicates the mini-app type.
- Example: "action"
- icon *: URL of the mini-app's visual representation.
- Example: "https://mi-image.com"
- title *: The title displayed in the user interface.
- Example: "sherry.social"
- description *: A short explanation of the mini-app's purpose.
- Example: "Claim your early supporter badge"
- actions *: Defines the operations the mini-app performs. Each action includes:
- label*: Describes the action.
- Example: "Mint badge"
- contractAddress*: Smart contract address.
- Example: "0x012345678901234567890x01234567890123456789"
- contractABI*: ABI of the contract for interaction.
- Example: [ { name: 'safeMint', type: 'function', stateMutability: 'nonpayable', inputs: [{ name: 'to', type: 'address' }], outputs: [{ name: 'tokenId', type: 'uint256' }], }]
- functionName: Name of the contract function to execute.
- Example: "safeMint"
- functionParamsLabel?: Optional name for inputs of the function.
- Example: ["To"]
- chainId: The blockchain where the action occurs.
- Example: "avalanche"
The Sherry Link will look as follows
In order to be able to define the metadata correctly, we have made the corresponding interfaces available through the SDK. You are free to define the metadata arbitrarily but it will be validated before publishing-rendering your mini-app. In order for everything to work smoothly, we strongly recommend using the types, interfaces, classes and functions accordingly.
We will now explain the interfaces used for the definition and validation of the Metadata. We have main interfaces which are Metadata and ValidatedMetadata. As a developer you only have to worry about using the Metadata interface and then send that information to the createMetadata function to obtain as a result an object of the ValidatedMetadata type. This in order to maintain the coherence of the definition and the subsequent interaction with the mini-app based on the metadata.
Anyway if you want you can use ValidatedMetadata to define and return the metadata, just remember that it will be re-validated before being published, and it will continue to be validated before each rendering.
Interface used to define the Metadata of the mini-app
Interface used as a result of the validation of the Metadata defined with Metadata, through the createMetadata function.
Used to validate the metadata, it receives as input a Metadata type and returns a ValidatedMetadata type.
Our metadata interface is the core of our SDK and the behavior of the mini-apps. If you want to know more about the definition and example of each of the properties check the Key Metadata Properties . As you can see below, the interface looks like this:
Blockchain Actions correspond to the functions to be executed in the blockchain, the definition of these is essential for the correct functioning of the app. More detail about Blockchain Actions .
In order to validate the metadata, we have provided a method called createMetadata that receives the definition of a Metadata interface and returns the same validated with the inputs and their types as appropriate, always taking into account that the defined Blockchain Actions must exist in the ABI. Since the ABI contains the structure of the contract so to speak, it is the one that our SDK to validate the metadata. In case any error happens in the validation process, we have defined some classes that allow you to get more information and you can review them in Validating Metadata .