2个不稳定版本

0.18.0 2023年7月2日
0.17.0 2023年3月23日

#37#mint

Download history 103/week @ 2024-04-22 19/week @ 2024-04-29 42/week @ 2024-05-13 47/week @ 2024-05-20 94/week @ 2024-05-27 45/week @ 2024-06-03 19/week @ 2024-06-10 26/week @ 2024-06-17 70/week @ 2024-06-24 128/week @ 2024-07-01 44/week @ 2024-07-08 18/week @ 2024-07-15 59/week @ 2024-07-22 140/week @ 2024-07-29 37/week @ 2024-08-05

每月254次下载

Apache-2.0

135KB
3K SLoC

CW-2981 Token-level Royalties

将EIP-2981移植到token铸币级别实现版税的一个示例。

基于cw721-metadata-onchain中的元数据模式。

所有cw721逻辑和行为都按照常规实现,但在铸币时,可以将版税信息附加到token上。

公开了两种新的查询消息类型,可以调用

// Should be called on sale to see if royalties are owed
// by the marketplace selling the NFT.
// See https://eips.ethereum.org/EIPS/eip-2981
RoyaltyInfo {
    token_id: String,
    // the denom of this sale must also be the denom returned by RoyaltiesInfoResponse
    sale_price: Uint128,
},
// Called against the contract to signal that CW-2981 is implemented
CheckRoyalties {},

响应是

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct RoyaltiesInfoResponse {
    pub address: String,
    // Note that this must be the same denom as that passed in to RoyaltyInfo
    // rounding up or down is at the discretion of the implementer
    pub royalty_amount: Uint128,
}

/// Shows if the contract implements royalties
/// if royalty_payments is true, marketplaces should pay them
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct CheckRoyaltiesResponse {
    pub royalty_payments: bool,
}

要设置此信息,铸币时可用新的元字段

    /// specify whether royalties are set on this token
    pub royalty_payments: bool,
    /// This is how much the minter takes as a cut when sold
    pub royalty_percentage: Option<u64>,
    /// The payment address, may be different to or the same
    /// as the minter addr
    /// question: how do we validate this?
    pub royalty_payment_address: Option<String>,

注意,royalty_payment_address当然可以是单个地址、多重签名或DAO。

关于CheckRoyalties的说明

对于此合约,没有需要检查的内容。此钩子预期存在,以检查合约是否实现了CW2981,并指示在销售时应该检查版税。由于在token级别实现,它应该始终返回true,因为这取决于token。

当然,扩展此合约的合约可以确定自己的行为,并在有更复杂的行为时替换此函数(例如,您可以维护一个二级索引,列出哪些token实际上有版税)。

在这种情况下,这不是必要的。

依赖项

~4–6MB
~126K SLoC