# Transfer

#### Simple Transfer

```javascript
// send 1eth to 0x812D3C67d283F3b9d1F1E347DF37F0C7fbD6a0B0
const transaction = {
  to: "0x812D3C67d283F3b9d1F1E347DF37F0C7fbD6a0B0",
  value: "1000000000000000000"
}

const signer = wallet.getSigner()
const txnResponse = await signer.sendTransaction(transaction)
console.log(txnResponse)

// wait for the transaction to be mined
await txnResponse.wait()
```

It creates a transaction object with the destination address and amount in wei, gets a Signer from the wallet, and calls sendTransaction() to send the signed transaction.

#### Transfer ERC20

```javascript
// ERC20 contract address to send from
const erc20ContractAddress = "";
// Destination address for the transfer
const recipientAddress = "";
// Transfer amount
const amount = "";

const erc20Interface = new ethers.utils.Interface([
  'function transfer(address _to, uint256 _value)'
])

// Encode an ERC-20 token transfer to recipient of the specified amount
const data = erc20Interface.encodeFunctionData(
  'transfer', [recipientAddress, amount]
)

const transaction = {
  to: erc20ContractAddress,
  data
}

const signer = wallet.getSigner()
const txnResponse = await signer.sendTransaction(transaction)
console.log(txnResponse)

// wait for the transaction to be mined
await txnResponse.wait()
```

It encodes an ERC20 transfer call, creates a transaction with the data, and sends the transaction.

#### Batch Transactions

> Sodium Wallet supports batch transactions.&#x20;
>
> This is useful for scenarios like token approval.

```javascript
// ERC20 contract address to send from
const erc20ContractAddress = "";
// Destination address for the first transfer
const recipientAddress1 = "";
// Transfer amount for the first transfer
const amount1 = "";

// Destination address for the second transfer
const recipientAddress2 = "";
// Transfer amount for the second transfer
const amount2 = "";

const erc20Interface = new ethers.utils.Interface([
  'function transfer(address _to, uint256 _value)'
])

// Encode two different ERC-20 token transfers
const data1 = erc20Interface.encodeFunctionData(
  'transfer', [recipient1Address, amount1]
)
const data2 = erc20Interface.encodeFunctionData(
  'transfer', [recipient2Address, amount2]
)

const transaction1 = {
  to: erc20ContractAddress,
  data: data1
}

const transaction2 = {
  to: erc20ContractAddress,
  data: data2
}

// Send a multiple transactions as a single bundle which is executed as one transaction on chain.
const signer = wallet.getSigner()
const txnResponse = await signer.sendTransactionBatch([transaction1, transaction2])
console.log(txnResponse)

// Wait for the batched transaction to be mined
await txnResponse.wait()javasc  
```

It shows how to send multiple transactions in a single call by passing an array of transactions to sendTransactionBatch(). This allows executing multiple transactions as one on-chain.

In summary:

* sendTransaction() sends a single ether or ERC20 transaction
* sendTransactionBatch() sends multiple transactions in a single call
* encodeFunctionData() encodes an ERC20 transfer call
* getSigner() obtains a Signer to sign transactions from the wallet


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sodiums.gitbook.io/sodium-documentation/sdk/transfer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
