Skip to content

Allow NFTs to include custom data #440

@ethanfrey

Description

@ethanfrey

A first step on #391

A few people have tried to build on cw721-base but want to add extra metadata to the contract and cannot extend it. Basically, we would need:

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct TokenInfo<T> {
    /// The owner of the newly minted NFT
    pub owner: Addr,
    /// Approvals are stored here, as we clear them all upon transfer and cannot accumulate much
    pub approvals: Vec<Approval>,

    /// Identifies the asset to which this NFT represents
    pub name: String,
    /// Describes the asset to which this NFT represents
    pub description: String,
    /// A URI pointing to an image representing the asset
    pub image: Option<String>,

    pub extension: Option<T>,
}

(source)

The default implementation can simply leave extension: None. (Or use extension: Empty, removing the Option).

This can be done and then we make all query and execute methods accept this T. However, when thinking about it, it would be a great first example of using a struct to represent a contract, as described in #391

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions