13
  { expiration: '2018-05-09T10:21:48',
    region: 0,
    ref_block_num: 1055,
    ref_block_prefix: 4035814219,
    max_net_usage_words: 0,
    max_kcpu_usage: 0,
    delay_sec: 0,

What is expiration, region, ref_block_num, ref_block_prefix, max_net_usage_words, max_kcpu_usage and delay_sec?

I assumed expiration was just the date at which the transaction would just become rejected if it had not been confirmed yet, but the date generated when I do eos.transfer(params) is actually 1 or 2 hours before the current time.

| improve this question | | | | |
14

expiration -> after this time the transaction can never be included in a block.

ref_block_num / ref_block_prefix -> this transaction can only in blockchains where the highest block_num%0xff has a blockid that contains ref_block_prefix. Stated another way, this says the transaction can only be included in forks that build off of the reference block.

Taken together the transaction is only valid for the specified period of time and can be declared invalid if it isn't included in a block by the time the last irreversible block time is equal to the expiration.

EOSIO uses this information to prevent replay attacks on transactions.

delay_sec will cause the transaction to be executed a specified number of seconds after being included in a block. During this time the user can cancel it. Some permissions and contracts require a minimum delay period for security purposes.

netusage and cpu usage limit how much a block producer can bill the signers for the transaction, set to 0 to allow the producers to subjectively determine your resource usage.

| improve this answer | | | | |
2
  • expiration - the time at which a transaction expires
  • ref_block_num - specifies a block num in the last 2^16 blocks.
  • ref_block_prefix - specifies the lower 32 bits of the blockid at get_ref_blocknum

  • max_net_usage_words - upper limit on total network bandwidth (in 8 byte words) billed for this transaction

  • max_cpu_usage_ms - upper limit on the total CPU time billed for this transaction

  • delay_sec - number of seconds to delay this transaction for during which it may be canceled.

How to get ref_block_num:

 /**
  * @return the absolute block number given the relative ref_block_num
  */
  block_num_type get_ref_blocknum( block_num_type head_blocknum )const {
     return ((head_blocknum/0xffff)*0xffff) + head_blocknum%0xffff;
  }

Source: https://github.com/EOSIO/eos/blob/e87d245da0e458edc66139c3ca59f71861bcc1dd/libraries/chain/include/eosio/chain/transaction.hpp#L31


More on difference between ref_block_num & ref_block_prefix: Difference between ref_block_num and ref_block_prefix and how to retrieve it?

| improve this answer | | | | |
1

How to GET

ref_block_prefix

I have method get info chain

getInfo: function(){
            var $vm = this;
            return axios
                  .post('https://eos.greymass.com/v1/chain/get_info')
                  .then( function(response){
                      $vm.info = response.data
                      console.log($vm.info)
                  });
          }

BUT it return not have

ref_block_prefix

Response Data:

{ server_version: '0acef24b',
  chain_id:
   'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
  head_block_num: 26019924,
  last_irreversible_block_num: 26019605,
  last_irreversible_block_id:
   '018d07150cb10fc84ce1121cb28a468303d654250edb839bf573bfbd075c47f5',
  head_block_id:
   '018d08545ae1e45d3b0fc5fa61f836b3d4a23944133ce0ae0c568f7ccd403da8',
  head_block_time: '2018-11-09T10:24:19.500',
  head_block_producer: 'eoslaomaocom',
  virtual_block_cpu_limit: 49100543,
  virtual_block_net_limit: 1048576000,
  block_cpu_limit: 194971,
  block_net_limit: 1047496,
  server_version_string: 'v1.3.0' }
| improve this answer | | | | |
0

but the date generated when I do eos.transfer(params) is actually 1 or 2 hours before the current time.

Take a look on that:

https://github.com/EOSIO/eosjs-api/blob/HEAD/docs/index.md#headers--object

expiration - This is based on the head block time from the blockchain. Be careful to suffix a Z if required (as with Firefox and JavaScript) to ensure this date string is interpreted as Zulu time. Example: new Date(new Date(info.head_block_time + 'Z').getTime() + expireInSeconds * 1000).toISOString().split('.')[0]

// Zulu (short for "Zulu time") is used in the military and in navigation generally as a term for Universal Coordinated Time (UCT)

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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