ContractMetadata
Functionality available for contracts that inherit the ContractMetadata
contract.
Read, set, or update the metadata of a smart contract, such as it’s 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
update
Update the metadata of your smart contract.
const txResult = await contract.metadata.update({
name: "My Contract",
description: "My contract description",
});
Configuration
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",
});