- 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
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.
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
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
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’snum_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.
Tooling supportYou 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 the near-kit (TypeScript) and near-kit-rs (Rust) libraries — both cover creating, funding, withdrawing, signing on a nonce lane, and reading a key’s lanes via view_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.DelegateV2 action lets a user sign a delegate action on a gas key’s nonce lane, enabling relayers to sponsor gas end to end.