Skip to main content

Method Signature

align.blockchain.wallets.sendNativeToken(
  wallet: Wallet,
  to: string,
  amount: string,
  network: Network
): Promise<Transaction>

Parameters

wallet
Wallet
required
The sender’s wallet object (with private key)
to
string
required
Recipient wallet address
amount
string
required
Amount to send (e.g., "0.1" for 0.1 ETH/MATIC)
network
string
required
Network: ethereum, polygon, base, arbitrum, optimism

Returns

hash
string
Transaction hash
status
string
Transaction status: pending, confirmed, failed

Examples

import Align from "@tolbel/align";

const align = new Align({
  apiKey: process.env.ALIGN_API_KEY!,
  environment: "sandbox",
});

// Create or import a wallet
const wallet = await align.blockchain.wallets.createFromPrivateKey(
  process.env.PRIVATE_KEY!
);

// Send 0.1 MATIC
const tx = await align.blockchain.wallets.sendNativeToken(
  wallet,
  "0xRecipientAddress...",
  "0.1",
  "polygon"
);

console.log(`TX Hash: ${tx.hash}`);

// Wait for confirmation
const receipt = await align.blockchain.transactions.waitForConfirmation(
  tx.hash,
  "polygon"
);
console.log(`Confirmed in block ${receipt.blockNumber}`);

Check Balance Before Send

const balance = await align.blockchain.wallets.getBalance(
  wallet.address,
  "polygon"
);

const sendAmount = "0.1";
const estimatedGas = 0.001; // Approximate gas cost

if (parseFloat(balance) < parseFloat(sendAmount) + estimatedGas) {
  throw new Error("Insufficient balance");
}

await align.blockchain.wallets.sendNativeToken(
  wallet,
  to,
  sendAmount,
  "polygon"
);
Ensure the wallet has sufficient balance for both the transfer amount and gas fees.