企业信息
所在地:
联系人: 刘毅
手机:18028578624
联系时请说是在网商汇看到的我
  
您的当前位置:首页 > 新闻资讯 > 企业资讯

NFT链游系统开发游戏技术方案

2023/2/3 14:20:50  

  Therefore,in a distributed system,despite the bad guys,the bad guys can do anything(not limited by the protocol),such as not responding,sending error messages,sending different decisions to different nodes,and different wrong nodes joining together to do bad things.However,as long as most people are good people,it is entirely possible to achieve consensus in a decentralized way.

  智能合约是编程在区块链上的汇编语言。通常人们不会自己写字节码,I8O系2857统X开8624发但是会从更高级的语言来编译它,例如用Solidity,与Javascript类似的专用语言。这些字节码确实给区块链的功能性提供了指引,因此代码可以很容易与它进行交互,例如转移密码学货币和记录事件。

  代码的执行是自动的:要么成功执行,或者所有的状态变化都撤销(包括从当前失败的合约中已经送或接收的信息。)这是很重要的,因为它避免了合约部分执行的情况(例如,在证券购买交易中,证券所有者已经转移发送了证券,但是密码学货币的支付转移却失败了)。在区块链环境中,这尤为重要,因为没有办法来撤销执行错误所带来的不好的后果(而且如果对手不配合的话,根本就没有办法逆转交易)。

  1.定义pallet中的常量

  MaxAddend将是元数据中显示的值。

  ClearFrequency跟踪块编号并将用于重置SingleValue。

  #[pallet::config]

  pub trait Config:frame_system::Config{

  type Event:From<Event<Self>> IsType<<Self as frame_system::Config>::Event>;

  #[pallet::constant]//put the constant in metadata

  ///Maximum amount added per invocation.

  type MaxAddend:Get<u32>;

  ///Frequency with which the stored value is deleted.

  type ClearFrequency:Get<Self::BlockNumber>;

  }

  2.声明存储项目和事件。

  使用存储属性宏,声明SingleValue每个块周期都会修改的值。

  #[pallet::storage]

  #[pallet::getter(fn single_value)]

  pub(super)type SingleValue<T:Config>=StorageValue<_,u32,ValueQuery>;

  3.定义pallet的事件。

  #[pallet::event]

  #[pallet::generate_deposit(pub(super)fn deposit_event)]

  pub enum Event<T:Config>{

  ///The value has been added to.The parameters are

  ///(initial amount,amount added,final amount).

  Added(u32,u32,u32),

  ///The value has been cleared.The parameter is the value before clearing.

  Cleared(u32)

  }

  4.添加处理操作溢出的错误:

  #[pallet::error]

  pub enum Error<T>{

  ///An operation would lead to an overflow.

  Overflow

  }

资讯标签:

NFT链游系统开发游戏技术方案
上一篇: 无
下一篇: 无