EOS合约内unpack data

void myaction() {

   struct token_transfer {
      name from;
      name to;
      asset quantity;
      string memo;
   };

   // transaction is inside "prop" object (that we get from a eosio.msig table)
   eosio::multisig::proposals proptable( "eosio.msig"_n, proposer.value );
   auto& prop = proptable.get( proposal_name.value, "proposal not found" );

   // get the first action in the transaction, remember transactions can have multiple actions
   eosio::action my_action = eosio::unpack<eosio::transaction>( prop.packed_transaction ).actions.front();

   // get the data out of the action
   token_transfer my_action_data = my_action.data_as<token_transfer>();

   const name from      = my_action_data.from;
   const name to        = my_action_data.to;
   const asset quantity = my_action_data.quantity;
   const string memo    = my_action_data.memo;
}

参考

https://eosio.stackexchange.com/questions/4142/how-to-get-data-from-a-packed-transaction

,

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享
评论 抢沙发
区块链技术的头像-区块链开发网

昵称

取消
昵称表情代码图片