Skip to main content

ContractMetadata

Functionality available for contracts that inherit the ContractMetadata contract.

Read, set, or update the metadata of a smart contract, such as its name, description, image, etc.

If Permissions are enabled, admin permissions are required to set/update the metadata (unless otherwise specified).

Under the hood, the metadata object you provide is uploaded and pinned to IPFS. The IPFS hash that is returned is then stored on-chain. When you retrieve the metadata of a contract, the IPFS hash is retrieved from the blockchain and the metadata is retrieved from IPFS and returned to you in an object.

get

Get the metadata of a smart contract.

const metadata = await contract.metadata.get();
Configuration

Return Value

While the actual return type is any, you can expect an object containing properties that follow the contract level metadata standards, outlined below:

{
name: string; // Name of your smart contract
description?: string; // Short description of your smart contract
image?: string; // Image of your smart contract (any URL, or IPFS URI)
symbol?: string; // Symbol of your smart contract (ticker, e.g. "ETH")
external_link?: string; // Link to view this smart contract on your website
seller_fee_basis_points?: number // The fee you charge on secondary sales, e.g. 100 = 1% seller fee.
fee_recipient?: string; // Wallet address that receives the seller fee
}

update

Update the metadata of your smart contract.

const txResult = await contract.metadata.update({
name: "My Contract",
description: "My contract description",
});
Configuration

metadata

Provide an object containing the metadata of your smart contract following the contract level metadata standards.

New properties will be added, and existing properties will be overwritten. If you do not provide a new value for a previously set property, it will remain unchanged.

Below are the properties you can define on your smart contract.

{
name: string; // Name of your smart contract
description?: string; // Short description of your smart contract
image?: string; // Image of your smart contract (any URL, or IPFS URI)
symbol?: string; // Symbol of your smart contract (ticker, e.g. "ETH")
external_link?: string; // Link to view this smart contract on your website
seller_fee_basis_points?: number // The fee you charge on secondary sales, e.g. 100 = 1% seller fee.
fee_recipient?: string; // Wallet address that receives the seller fee
}

set

Overwrite the metadata of a contract, an object following the contract level metadata standards.

This operation ignores any existing metadata and replaces it with the new metadata provided.

const txResult = await contract.metadata.set({
name: "My Contract",
description: "My contract description",
});
Configuration

metadata

Provide an object containing the metadata of your smart contract following the contract level metadata standards.

{
name: string; // Name of your smart contract
description?: string; // Short description of your smart contract
image?: string; // Image of your smart contract (any URL, or IPFS URI)
symbol?: string; // Symbol of your smart contract (ticker, e.g. "ETH")
external_link?: string; // Link to view this smart contract on your website
seller_fee_basis_points?: number // The fee you charge on secondary sales, e.g. 100 = 1% seller fee.
fee_recipient?: string; // Wallet address that receives the seller fee
}