Gas Keys
Send transactions in parallel using access keys with a prepaid gas balance and independent nonce lanes.
Gas keys (NEP-611) are access keys designed for sending many transactions in parallel. They were introduced in nearcore 2.13 (protocol version 86) and differ from regular access keys in two ways:
- Prepaid gas balance: a gas key holds its own NEAR balance, and transactions signed with it pay gas from that balance instead of the account's main balance
- Parallel nonces: a gas key has up to 1,024 independent nonces (called nonce lanes), so many transactions can be in flight at once without nonce collisions
A gas key can have either FullAccess or FunctionCall permission, with one restriction: a function-call gas key cannot set an allowance — its prepaid balance already serves as the gas budget.
[!TIP]
Gas keys are ideal for programmatic senders — relayers, bots, exchanges, or a fleet of agents operating one account — which previously had to juggle many separate access keys just to avoid nonce collisions, and risked draining the account's main balance on gas.
Lifecycle of a Gas Key
A gas key is managed with the same actions as any other key, plus two new actions to move NEAR in and out of its balance:
- Create: an
AddKeyaction with a gas-key permission creates the key, specifying its number of nonces (num_nonces, between 1 and 1,024). The key is always created with zero balance - Fund: a
TransferToGasKeyaction moves NEAR from the account's balance into the gas key's balance. It can be used repeatedly to top up the key - Use: transactions signed with the gas key specify a
nonce_indexselecting which nonce lane to use, and consume gas from the key's balance - Withdraw: a
WithdrawFromGasKeyaction moves NEAR from the key's balance back to the account. Only the account itself can withdraw - Delete: a
DeleteKeyaction removes the key. Any remaining balance is burned, so the action fails if the key holds more than 1 NEAR — withdraw first, then delete
[!WARNING]
Deleting a gas key burns whatever balance is left on it — this is a protocol-level protection against spam attacks, not a bug. Always
WithdrawFromGasKeybefore deleting. The deletion (and likewiseDeleteAccount) fails if more than 1 NEAR would be burned, protecting you from losing significant funds by accident.
How Gas Keys Pay for Transactions
When a transaction is signed with a gas key:
- The gas costs (both burned gas and gas prepaid for function calls) are charged to the gas key's balance
- Any attached NEAR (deposits, transfers) is still paid from the account's main balance
- Gas refunds for unspent gas return to the gas key's balance, so the key sustains itself between top-ups, while balance refunds go to the account
If the gas key's balance cannot cover a transaction's gas, the transaction is rejected. If the gas is covered but the account cannot pay the attached deposit at execution time, the transaction fails and the gas burned to process it is still charged to the gas key. The gas that was attached to the receipt is refunded.
[!NOTE]
Gas is bought at a price that can be higher than the price it burns at, so a gas key has to hold more than its transactions finally cost. The difference comes back to the key as a refund, but it has to be on the key upfront.
Using Nonce Lanes
Each of the key's num_nonces lanes keeps its own independent nonce. A transaction signed with a gas key picks a lane through a nonce_index field (from 0 to num_nonces - 1), and only that lane's nonce advances. Two transactions on different lanes can never conflict, so a sender can run one lane per worker and submit transactions concurrently — with a single key to manage.
You can inspect a gas key's lanes with the view_gas_key_nonces RPC query, and gas keys appear in view_access_key with their balance and num_nonces.
[!NOTE]
Tooling support
You can create and manage gas keys with the NEAR CLI (
near account add-key ... grant-gas-key-full-access,fund-gas-key,withdraw-from-gas-key,view-gas-key-nonces) and from your app with thenear-kit(TypeScript) andnear-kit-rs(Rust) libraries — both cover creating, funding, withdrawing, signing on a nonce lane, and reading a key's lanes viaview_gas_key_nonces. Contracts can also add and fund gas keys through batch-promise host functions — though only the account's own transactions can withdraw from one.
Meta transactions
[!WARNING]
From protocol version 87, gas keys cannot sign the inner delegate action of a meta transaction. Users must use a regular access key. Relayers can still sign the outer transaction with a full access gas key to pay for gas.