Search code examples
nearprotocol

How long before a block hash is invalidated?


The documentation says "Block hash is hash of the block from the current blockchain on top of which this transaction can be applied. It’s used to guard against blockchain forks and rollbacks."

If I try to sign and send a transaction with a block hash that is "a little out of date" then I get the error InvalidTxError::Expired

Is there some specific definition of this expiration timeout that I can use to predict whether it will happen and therefore need to refresh the block hash that I plan to use?

Does it happen after a period of time or if the block hash is Nth from the top of the chain or something?


Solution

  • There is a system-wide parameter transaction_validity_period that defines how long (for how many blocks) a transaction can be considered valid since the block hash it is based on.