ContractMetadata
Functionality available for contracts that inherit the ContractMetadata
extensions.
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.
metadata = contract.metadata.get()
print(metadata)
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.
from thirdweb.types import ContractMetadataSchema
metadata = ContractMetadataSchema.from_json({
"name": "My Contract",
"description": "This is my contract!",
"image": open("path/to/file.jpg", "rb")
})
receipt = contract.metadata.set(metadata)