Durable Transaction Nonces
Durable transaction nonces are a mechanism for getting around the typical
short lifetime of a transaction's recent_blockhash
.
They are implemented as a Renec Program, the mechanics of which can be read
about in the proposal.
#
Usage ExamplesFull usage details for durable nonce CLI commands can be found in the CLI reference.
#
Nonce AuthorityAuthority over a nonce account can optionally be assigned to another account. In
doing so the new authority inherits full control over the nonce account from the
previous authority, including the account creator. This feature enables the
creation of more complex account ownership arrangements and derived account
addresses not associated with a keypair. The --nonce-authority <AUTHORITY_KEYPAIR>
argument is used to specify this account and is supported by the following
commands
create-nonce-account
new-nonce
withdraw-from-nonce-account
authorize-nonce-account
#
Nonce Account CreationThe durable transaction nonce feature uses an account to store the next nonce value. Durable nonce accounts must be rent-exempt, so need to carry the minimum balance to achieve this.
A nonce account is created by first generating a new keypair, then create the account on chain
- Command
- Output
To keep the keypair entirely offline, use the Paper Wallet keypair generation instructions instead
#
Querying the Stored Nonce ValueCreating a durable nonce transaction requires passing the stored nonce value as
the value to the --blockhash
argument upon signing and submission. Obtain the
presently stored nonce value with
- Command
- Output
#
Advancing the Stored Nonce ValueWhile not typically needed outside a more useful transaction, the stored nonce value can be advanced by
- Command
- Output
#
Display Nonce AccountInspect a nonce account in a more human friendly format with
- Command
- Output
#
Withdraw Funds from a Nonce AccountWithdraw funds from a nonce account with
- Command
- Output
Close a nonce account by withdrawing the full balance
#
Assign a New Authority to a Nonce AccountReassign the authority of a nonce account after creation with
- Command
- Output
#
Other Commands Supporting Durable NoncesTo make use of durable nonces with other CLI subcommands, two arguments must be supported.
--nonce
, specifies the account storing the nonce value--nonce-authority
, specifies an optional nonce authority
The following subcommands have received this treatment so far
#
Example Pay Using Durable NonceHere we demonstrate Alice paying Bob 1 RENEC using a durable nonce. The procedure is the same for all subcommands supporting durable nonces
#
- Create accountsFirst we need some accounts for Alice, Alice's nonce and Bob
#
- Fund Alice's accountAlice will need some funds to create a nonce account and send to Bob. Airdrop her some RENEC
#
- Create Alice's nonce accountNow Alice needs a nonce account. Create one
Here, no separate nonce authority is employed, so
alice.json
has full authority over the nonce account
#
- A failed first attempt to pay BobAlice attempts to pay Bob, but takes too long to sign. The specified blockhash expires and the transaction fails
#
- Nonce to the rescue!Alice retries the transaction, this time specifying her nonce account and the blockhash stored there
Remember,
alice.json
is the nonce authority in this example
#
- Success!The transaction succeeds! Bob receives 0.01 RENEC from Alice and Alice's stored nonce advances to a new value