Skip to main content

ContractMetadata

Functionality available for contracts that inherit the ContractMetadata extensions.

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.

metadata = contract.metadata.get()
print(metadata)
Configuration

Return Value

The return type is TContractSchema, an object containing properties that follow the contract level metadata standards, outlined below:

class ContractMetadataSchema:
name: str = ""
description: Optional[str] = None
image: Optional[Union[str, TextIO, BinaryIO]] = None
external_link: Optional[str] = None

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)
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
}