Eos: Can a smart contract action access the transactionId?

Created on 1 Aug 2018  路  4Comments  路  Source: EOSIO/eos

Is it possible to find out the transactionId from within an action?

I know I can access the block_num and a few other details using the tapos function but I did not find similar for transactionId.

enhancement

Most helpful comment

Note: I did find the following in contracts/test_api/test_transaction.h that seems to work:

void test_transaction::test_read_transaction() {
   using namespace eosio;
   checksum256 h;
   auto size = transaction_size();
   char buf[size];
   uint32_t read = read_transaction( buf, size );
   eosio_assert( size == read, "read_transaction failed");
   sha256(buf, read, &h);
   printhex( &h, sizeof(h) );
}

I tested with an action and the printed string _seems_ to work for cleos get transaction ....

I didnt know if there was another (better) way.

All 4 comments

Note: I did find the following in contracts/test_api/test_transaction.h that seems to work:

void test_transaction::test_read_transaction() {
   using namespace eosio;
   checksum256 h;
   auto size = transaction_size();
   char buf[size];
   uint32_t read = read_transaction( buf, size );
   eosio_assert( size == read, "read_transaction failed");
   sha256(buf, read, &h);
   printhex( &h, sizeof(h) );
}

I tested with an action and the printed string _seems_ to work for cleos get transaction ....

I didnt know if there was another (better) way.

This is not available for now. However, we'll treat it as a future enhancement.

Note: I did find the following in contracts/test_api/test_transaction.h that seems to work:

void test_transaction::test_read_transaction() {
   using namespace eosio;
   checksum256 h;
   auto size = transaction_size();
   char buf[size];
   uint32_t read = read_transaction( buf, size );
   eosio_assert( size == read, "read_transaction failed");
   sha256(buf, read, &h);
   printhex( &h, sizeof(h) );
}

I tested with an action and the printed string _seems_ to work for cleos get transaction ....

I didnt know if there was another (better) way.

Have you solve this problem, I also want to get transaction id offline.

Created #6289 to address this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zxf969175364 picture zxf969175364  路  3Comments

hoopslb picture hoopslb  路  3Comments

jiazechen picture jiazechen  路  3Comments

Npizza picture Npizza  路  3Comments

christola picture christola  路  3Comments