创造我们的NFT,使用Substrate 创建KItties 二

创造我们的NFT,使用Substrate 创建KItties 二唯一性 自定义类型和存储映射 接下来几个基础步骤 使用以下代码段更新您的 pallet 代码 如果您不想使用模板代码 请跳过此步骤 cfg attr not feature std no std pub use pallet frame support pallet pub mod pallet

大家好,我是讯享网,很高兴认识大家。

唯一性、自定义类型和存储映射

接下来几个基础步骤,使用以下代码段更新您的pallet代码(如果您不想使用模板代码,请跳过此步骤):


讯享网

#![cfg_attr(not(feature = "std"), no_std)] pub use pallet::*; #[frame_support::pallet] pub mod pallet { 
    use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; use frame_support::{ 
    sp_runtime::traits::Hash, traits::{ 
    Randomness, Currency, tokens::ExistenceRequirement }, transactional }; use sp_io::hashing::blake2_128; #[cfg(feature = "std")] use frame_support::serde::{ 
   Deserialize, Serialize}; // ACTION #1: Write a Struct to hold Kitty information. // ACTION #2: Enum declaration for Gender. // ACTION #3: Implementation to handle Gender type in Kitty struct. #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet<T>(_); /// Configure the pallet by specifying the parameters and types it depends on. #[pallet::config] pub trait Config: frame_system::Config { 
    /// Because this pallet emits events, it depends on the runtime's definition of an event. type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>; /// The Currency handler for the Kitties pallet. type Currency: Currency<Self::AccountId>; // ACTION #5: Specify the type for Randomness we want to specify for runtime. // ACTION #9: Add MaxKittyOwned constant } // Errors. #[pallet::error] pub enum Error<

讯享网
小讯
上一篇 2025-03-15 14:02
下一篇 2025-03-29 13:20

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/64224.html