0

I am trying to extract the data out of a packed transaction. Specifically, I am reading a proposal from the eosio.msig table and trying to get the data from the proposed multisig transaction to validate it.

Here's the code

   eosio::multisig::proposals proptable( "eosio.msig"_n, proposer.value );
   auto& prop = proptable.get( proposal_name.value, "proposal not found" );

where now prop.packed_transaction holds the packed transaction.

I think I might need to use prop.packed_transaction.data() but I am not sure what this is returning and I can't find any documentation.

2 Answers 2

1

Here is an example reading token transfer data out of a transaction

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;
}
0

Havn't tried myself but i think you can use one of the Unpack<T>(...)-functions from datastream-library - as long as you know Type T.

something like the following:

auto unpackedProposal = unpack<knownProposalType>( prop.packed_transaction.data );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.