智能合约 请问如何在智能合约内获取当前的 transaction id 和 block id

lcg635 · August 22, 2018 · Last by vergil replied at August 23, 2018 · 5592 hits

如题, 现在在智能合约内可以获取到当前transaction, 但是里面没有transaction id和block id

共收到 1 条回复

transaction id就是transaction的fc::raw::pack序列化后的hash

transaction id:
{
  checksum256 transaction_id;
  auto size = transaction_size();
  char buf[size];
  uint32_t read = read_transaction( buf, size );
  sha256(buf, read, &transaction_id);
}

block id:

{
  int tbn = tapos_block_num();
}
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up