Send a Transfer
- High-level JS
- Low-level JS
- NEAR CLI
A plain transfer to a non-existing named account fails and refunds the transferred amount, while consumed gas remains charged.
Transaction results
Inspectresult.status for success or failure and require final_execution_status === "FINAL" before treating the transfer as complete. The example below shows a finalized FT transfer-and-call submitted by influencer.testnet on testnet.
Example FT transfer-and-call response
Example FT transfer-and-call response
result.transaction.hash.
Concurrent Transactions
If you start sending multiple transactions from a same account - e.g. when creating a relayer - you need to manage nonces carefully to avoid conflicts. In NEAR, accounts can have multiple keys, each with its own nonce sequence. So the simplest way to avoidnonce collisions is to use multiple access keys for concurrent transactions.
In near-api-js the MultiKeySigner rotates through a set of keys when creating transactions:
Submission errors and retries
Withnear-api-js 7.3.1, error handling depends on the method used:
Typed errors are exported from
near-api-js/rpc-errors. When the high-level method throws a transaction or contract execution error derived from a submitted transaction, its transactionResult contains the RPC response, including receipt outcomes. Use that response to inspect status.Failure and the failed receipt; read-only call errors do not include transaction outcomes.
Account.signAndSendTransaction() defaults to up to 10 retries after InvalidNonceError, constructing and signing a new transaction on each retry. These examples set retries: 0 so withdrawal recovery controls replacement transactions. This setting does not disable the provider’s HTTP retries.
Before broadcasting a withdrawal, persist its business intent, network, signer, reserved nonce, signed bytes, and transaction hash. Keep one recovery process in control of that intent until its outcome is resolved.
If rebroadcasting is necessary, resend the same signed bytes while their reference block remains valid. A newly signed transaction has a different hash and can execute a second payment. An expired block hash or consumed nonce on a later attempt does not prove that the original transaction never executed. Resolve the original outcome and reconcile balances before issuing a replacement under the same intent lock.
Actions within one receipt are atomic; separate receipts are not rolled back together. A contract call can fail after an earlier receipt has transferred funds. Keep transport errors, validation rejections, and execution failures distinct in your withdrawal records.
Frequently Asked Questions
What is the fee structure for on-chain transactions?
What is the fee structure for on-chain transactions?
NEAR uses a gas-based model where prices are generally deterministically adjusted based on congestion of the network.We avoid making changes that are too large through re-sharding by changing number of available shards (and thus throughput).Accounts don’t have associated resources. Gas amount is predetermined for all transactions except function calls. For function call transactions the user (or more likely the developer) attaches the required amount of gas. Unused prepaid gas is refunded according to current runtime rules, including any configured unused-gas refund penalty. Query the runtime configuration and budget gas for the contract being called.
How do we know how much gas to add to a transaction?
How do we know how much gas to add to a transaction?
- See Gas fees.
- See API documentation for discovering gas price via RPC here.
How do we follow Tx status?
How do we follow Tx status?
See related RPC interface for fetching transaction status here.