Embedded Wallets
SDK
Javascript
How to
Wallet Operation
Send Coin

Send Coin

This method allows you to send coin (native currency) from a blockchain network.

Method Signature

async sendCoin(config: SendCoinConfig): Promise<TransactionReceipt>

Parameters

config: SendCoinConfig - An object with the following properties:

  • network: Network (required) - The network used for transactions.
  • to: string (required) - The address of the recipient.
  • amount: string (required) - The amount of the transaction.
  • nonce: string (optional) - The number used once to prevent duplicate transactions (this will be calculated automatically if not provided).
  • gasPrice: string (optional) - Gas price in Wei (this will be calculated automatically if not provided).
  • gasLimit: string (optional) - Gas limit for single transaction, transaction will be reverted if actual gas consumption is higher than gas limit (this will be calculated automatically if not provided).
  • maxPriorityFeePerGas: string (optional) - Maximum priority fee per gas you are willing to pay, this only used in EIP1559 support blockchain.
  • walletToken: string (required) - The wallet token of the wallet to send the transaction for.
  • refreshToken: string (optional) - The refresh token for authentication. Use this if you want to allow SDK automatically refresh the wallet token.

Returns

Promise<TransactionReceipt> - An object containing the transaction receipt data.

Example Usage

const receipt = await sdk.wallet.sendCoin({
  network: Network.ETHEREUM,
  to: '0x1234567890123456789012345678901234567890',
  amount: '0.123',
  walletToken: 'your-wallet-token',
  refreshToken: 'your-refresh-token' // Optional
});
console.log(receipt);

Response Example

{
  "txReceipt": {
    "_type": "TransactionReceipt",
    "accessList": null,
    "blockNumber": null,
    "blockHash": null,
    "chainId": "1",
    "data": "0x",
    "from": "0xBfE64B4b628E0998A03e2522B051Cf1B4661c964",
    "gasLimit": "21000",
    "gasPrice": "10000000000",
    "hash": "0x4ec81ca3d6a112bdf991a220ed84a3458f061f1f818273c93546ea91a4e1d675",
    "maxFeePerGas": null,
    "maxPriorityFeePerGas": null,
    "nonce": 0,
    "signature": {
      "_type": "signature",
      "network": "230",
      "r": "0xa68e03c27544801a8b6b80fb78be4f9cc2c9aeeeb189e3ae177a0a1155647dee",
      "s": "0x097e8fd0d6922c0766c14279289d0076fdcff8d29f893ce7b78b82e499341cb7",
      "v": 28
    },
    "to": "0x9B9ef330B204bf33316FAf24E3Ed4FfCf57F02C3",
    "type": 0,
    "value": "15000000000000000"
  },
  "walletToken": "your-new-wallet-token",
  "refreshToken": "your-new-refresh-token"
}
ℹ️

The SDK will automatically refresh the wallet token and return the new wallet token and refresh token if the refresh token is provided.

ℹ️

The response is an object containing the transaction receipt data, including details such as the transaction hash, gas used, and block information.

Additional Information

  • This method requires a valid wallet token in the SDK configuration.
  • The amount parameter should be provided as a string to preserve precision for large numbers.
  • Optional parameters like nonce, gasPrice, and gasLimit will be automatically calculated if not provided.
  • For EIP1559 compatible networks, you can specify maxPriorityFeePerGas.

For more information, see the Xellar Send Coin API Documentation (opens in a new tab).