TransactionBuilder.
To start a transaction:
Token Operations
.transfer(receiverId, amount)
.transfer(receiverId, amount)
Contract Operations
.functionCall(contractId, methodName, args, options)
.functionCall(contractId, methodName, args, options)
.deployContract(accountId, code)
.deployContract(accountId, code)
.stateInit(stateInit, options?)
.stateInit(stateInit, options?)
Deploys a contract to a deterministic account ID (NEP-616). The address is auto-derived from the initialization state. Idempotent—refunds if already deployed.See Global Contracts for more details.
Account Management
.createAccount(accountId)
.createAccount(accountId)
Creates a new account. This is often chained with
.transfer (to fund it) and .addKey (to secure it).The full ID of the new account (must be a sub-account of the signer).
.deleteAccount({ beneficiary })
.deleteAccount({ beneficiary })
Deletes the transaction receiver’s account and sends all remaining funds to the beneficiary.
The account that receives the remaining NEAR balance.
Access Keys
.addKey(publicKey, permission)
.addKey(publicKey, permission)
Adds a new access key to the account.
The public key to add (ed25519 or secp256k1).
One of:
{ type: "fullAccess" }- Can do anything.{ type: "functionCall", receiverId, methodNames?, allowance? }- Restricted to specific contracts/methods.
- Full Access
- Function Call (Restricted)
Global Contracts
.publishContract(code, options?)
.publishContract(code, options?)
.deployFromPublished(reference)
.deployFromPublished(reference)
Deploys contract code that was previously published to the registry. This saves gas by avoiding uploading the full Wasm bytes.
One of:
{ accountId: string }- Account ID of the publisher (for updatable contracts){ codeHash: string }- Base58 hash of an immutable contract
Advanced / Meta-Transactions
.delegate(options?)
.delegate(options?)
Instead of sending the transaction, this method signs it and returns a Returns:
SignedDelegateAction payload. This is used for meta-transactions where a relayer pays the gas.{ signedDelegateAction, payload, format }.signedDelegateAction(signedDelegate)
.signedDelegateAction(signedDelegate)
Adds a pre-signed delegate action to this transaction. Used by relayers to submit a user’s action.
The signed delegate action from the user.
.signWith(key)
.signWith(key)
Overrides the signer for this specific transaction. Does not change the global
Near configuration.A private key string OR a custom signer function.
- Private Key
- Custom Signer