Skip to main content
This page documents every method available on the TransactionBuilder. To start a transaction:
near.transaction(signerId: string)

Token Operations

Sends NEAR tokens from the signer to the receiver.
receiverId
string
required
The account receiving the tokens.
amount
Amount
required
The amount to send (e.g. "10 NEAR", "0.5 NEAR", "1000 yocto").
.transfer("bob.near", "10 NEAR")
Stakes NEAR with a validator.
publicKey
string
required
The validator’s public key.
amount
Amount
required
The amount to stake.

Contract Operations

Calls a method on a smart contract.
contractId
string
required
The contract account ID.
methodName
string
required
The method to call.
args
object | Uint8Array
Arguments. Objects are automatically JSON serialized.
options
object
.functionCall(
  "market.near",
  "buy",
  { item_id: "sword-1" },
  { gas: "50 Tgas", attachedDeposit: "1 NEAR" }
)
Deploys Wasm code to an account. If the account already has a contract, it will be updated.
accountId
string
required
The account to deploy to.
code
Uint8Array
required
The raw bytes of the compiled Wasm file.
Deploys a contract to a deterministic account ID (NEP-616). The address is auto-derived from the initialization state. Idempotent—refunds if already deployed.
stateInit
object
required
options
object
const encoder = new TextEncoder();
.stateInit({
  code: { accountId: "publisher.near" },
  data: new Map([
    [encoder.encode("owner"), encoder.encode("alice.near")]
  ]),
  deposit: "1 NEAR",
})
See Global Contracts for more details.

Account Management

Creates a new account. This is often chained with .transfer (to fund it) and .addKey (to secure it).
accountId
string
required
The full ID of the new account (must be a sub-account of the signer).
.createAccount("bob.alice.near")
.transfer("bob.alice.near", "1 NEAR")
.addKey(publicKey, { type: "fullAccess" })
Deletes the transaction receiver’s account and sends all remaining funds to the beneficiary.
beneficiary
string
required
The account that receives the remaining NEAR balance.
// Delete 'old-account.alice.near' and send remaining funds to 'alice.near'
await near
  .transaction("old-account.alice.near")
  .deleteAccount({ beneficiary: "alice.near" })
  .send()

Access Keys

Adds a new access key to the account.
publicKey
string
required
The public key to add (ed25519 or secp256k1).
permission
AccessKeyPermission
required
One of:
  • { type: "fullAccess" } - Can do anything.
  • { type: "functionCall", receiverId, methodNames?, allowance? } - Restricted to specific contracts/methods.
.addKey(pk, { type: "fullAccess" })
Removes an access key.
accountId
string
required
The account to remove the key from.
publicKey
string
required
The public key to remove.

Global Contracts

Publishes contract code to the global registry so others can deploy it by reference.
code
Uint8Array
required
The Wasm bytes.
options
object
// Identified by your account - you can update it later
.publishContract(wasm)
Deploys contract code that was previously published to the registry. This saves gas by avoiding uploading the full Wasm bytes.
reference
object
required
One of:
  • { accountId: string } - Account ID of the publisher (for updatable contracts)
  • { codeHash: string } - Base58 hash of an immutable contract

Advanced / Meta-Transactions

Instead of sending the transaction, this method signs it and returns a SignedDelegateAction payload. This is used for meta-transactions where a relayer pays the gas.
options
object
Returns: { signedDelegateAction, payload, format }
Adds a pre-signed delegate action to this transaction. Used by relayers to submit a user’s action.
signedDelegate
SignedDelegateAction
required
The signed delegate action from the user.
Overrides the signer for this specific transaction. Does not change the global Near configuration.
key
string | Signer
required
A private key string OR a custom signer function.
// Use a specific key just for this transaction
.signWith("ed25519:...")