Sender Wallet Developer Documentation
  • Guide
    • Introduction
    • Getting Started
    • Sign in Applications
      • Sign in Applications in Near
      • Sign in Applications in Ethereum
    • Access Accounts
      • Access Accounts in Near
      • Access Account in Ethereum
    • Send Transactions
      • Send Transactions in Near
      • Send Transactions in Ethereum
  • API Reference
    • Near
      • NEAR Provider API
      • Deprecated APIs
    • Ethereum
      • Sign Data
      • Ethereum Provider API
    • Ton
      • Mobile Dapp Provider
  • Best Practices
    • Define App's Icon
Powered by GitBook
On this page
  • Sign and Send a Single Transaction
  • Sign and Send Multiple Transactions
  1. Guide
  2. Send Transactions

Send Transactions in Near

PreviousSend TransactionsNextSend Transactions in Ethereum

Last updated 2 years ago

Transactions are a formal action on a blockchain. They can be initiated in Sender with a call to NEAR's RPC node. They can be a simple sending of $NEAR, may result in sending fungible tokens, creating a new account, or changing state on the blockchain in any number of ways. They are always initiated by a signature from an NEAR account, usually with .

Sign and Send a Single Transaction

With Sender, you could sign and send a single transaction with one or multiple actions.

// Call wNEAR contract method 
// Register the 'xxx.testnet' account to wNEAR on testnet (wrap.testnet)
const tx = {
  receiverId: 'wrap.testnet',
  actions: [
    { 
      methodName: 'storage_deposit',
      args: {
        account_id: 'alice.testnet',
        registration_only: true,
      },
      gas: parseNearAmount('0.003'),
      deposit: parseNearAmount('0.00125'),
    },
  ],
}
const res = await window.near.signAndSendTransaction(tx);
// Call multiple methods from wNEAR contract
// Swap NEAR to wNEAR, then transfer wNEAR to others
const tx = {
  receiverId: 'wrap.testnet',
  actions: [
    {
      methodName: 'near_deposit',
      args: {},
      deposit: parseNearAmount('1'),
    },
    { 
      methodName: 'storage_deposit',
      args: {
        account_id: 'bob.testnet',
        registration_only: true,
      },
      gas: parseNearAmount('0.003'),
      deposit: parseNearAmount('0.00125'),
    },
    {
      methodName: 'ft_transfer',
      args: {
        received_id: 'bob.testnet',
        amount: '1000000000000000000',
      },
      gas: parseNearAmount('0.003')
    }
  ]
}
const res = await window.near.signAndSendTransaction(tx);

Sign and Send Multiple Transactions

Sender also supports sign and send multiple transactions when needed.

const transactions = [
  {
    receiverId: wNearContractId,
    actions: [
      {
        methodName: 'near_deposit',
        args: {},
        amount: '100000000000000000000000',
      },
    ]
  },
  {
    receiverId: RefFinanceContractId,
    actions: [
      {
        methodName: 'add_liquidity',
        args: {
          tokens_ids: ['wrap.testnet', 'token.paras.testnet'],
          amounts: ['1000000000000000000', '1000000000000000000'],
        },
      }
    ]
  }
];

const res = await window.near.requestSignTransactions({ transactions });

console.log('Swap and Send wNEAR with requestSignTransactions response: ', res);
a function call key or full access key