Send ETH, BNB, TRX and BTC Transactions
To send a native coin with Chaingateway, you post the sender, the recipient, the amount and a signing secret to POST /api/v2/{chain}/transactions. Chaingateway signs the transaction, broadcasts it and returns the transaction id (txid). The signing secret is the wallet password for password-protected addresses, or the privatekey for addresses created without a password. This tutorial covers ETH, BNB, MATIC, TRX, BTC and SOL.
Tokens such as USDT use different endpoints, which Create Token Transactions describes. You need an API token and a funded address, see Quickstart and Create Addresses.
How do I send ETH, BNB or MATIC?
Section titled “How do I send ETH, BNB or MATIC?”Use the endpoint of the chain: /ethereum, /bsc, /polygon or /arbitrum. The body for the EVM chains has three required fields and a signing secret.
| Field | Required | Meaning |
|---|---|---|
from | yes | Sender address, validated as 40 hex characters with an optional 0x. |
to | yes | Recipient address, same format. |
amount | yes | The amount to send. |
password | one of the two | Wallet password. Required when privatekey is not present. |
privatekey | one of the two | Private key of the sender, for addresses created without a password. |
gas, gasprice, maxPriorityFeePerGas, maxFeePerGas, nonce, data | no | Optional transaction settings. |
Send a small amount on the testnet first, with the header X-Network: testnet, and compare the balance change before you move real funds. The unit of amount follows the API reference of the endpoint, so check it there. The authorization header carries your token: Authorization: Bearer YOUR_API_TOKEN.
curl --request POST \ --url https://app.chaingateway.io/api/v2/ethereum/transactions \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_API_TOKEN' \ --data '{ "from": "0xYourSenderAddress", "to": "0xRecipientAddress", "amount": "0.1", "password": "YourPassword"}'import requests
url = "https://app.chaingateway.io/api/v2/ethereum/transactions"payload = { "from": "0xYourSenderAddress", "to": "0xRecipientAddress", "amount": "0.1", "password": "YourPassword"}headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_TOKEN'}
response = requests.post(url, json=payload, headers=headers)print(response.json())const axios = require('axios');
const url = 'https://app.chaingateway.io/api/v2/ethereum/transactions';const payload = { from: '0xYourSenderAddress', to: '0xRecipientAddress', amount: '0.1', password: 'YourPassword'};const headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_TOKEN'};
axios.post(url, payload, { headers }) .then(response => { console.log(response.data); }) .catch(error => { console.error(error.response?.data ?? error); });<?phprequire 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();$response = $client->post('https://app.chaingateway.io/api/v2/ethereum/transactions', [ 'headers' => [ 'Accept' => 'application/json', 'Authorization' => 'Bearer YOUR_API_TOKEN', ], 'json' => [ 'from' => '0xYourSenderAddress', 'to' => '0xRecipientAddress', 'amount' => '0.1', 'password' => 'YourPassword' ]]);
echo $response->getBody();A successful call answers with status 201 and the transaction hash:
{ "status": 201, "ok": true, "message": "Succesfully created transaction", "data": { "txid": "0x73344d178812d4919e9002c560781f288030edf72ece88823ef1c377dfb71f27" }}How do I send TRX?
Section titled “How do I send TRX?”POST /api/v2/tron/transactions takes from, to and amount, plus password or privatekey. Tron addresses must match the pattern T followed by 33 alphanumeric characters. The sender needs enough TRX for the amount and for the network resources the transfer uses, as TRON’s resource model describes.
curl --request POST \ --url https://app.chaingateway.io/api/v2/tron/transactions \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_API_TOKEN' \ --data '{ "from": "YourSenderAddress", "to": "RecipientAddress", "amount": 1, "privatekey": "YourPrivateKey"}'The response has the same shape as the EVM response above, with the transaction hash in data.txid. If you sign transactions in your own code, POST /api/v2/tron/transactions/build returns an unsigned transaction and POST /api/v2/tron/transactions/broadcast accepts the signed one in the field signed_transaction.
How do I send BTC?
Section titled “How do I send BTC?”Bitcoin sends from a wallet, not from a single address. POST /api/v2/bitcoin/transactions requires to, amount, walletname, password and speed. The speed is fast, medium or slow and sets the fee level. The optional field subtractfee takes the fee from the amount instead of adding it on top.
curl --request POST \ --url https://app.chaingateway.io/api/v2/bitcoin/transactions \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_API_TOKEN' \ --data '{ "to": "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq", "amount": 0.0001, "walletname": "mywallet", "password": "YourWalletPassword", "speed": "medium", "subtractfee": false}'Bitcoin addresses are validated against the pattern (bc1|tb1|[13]) followed by 25 to 39 characters, which accepts mainnet and testnet formats. The Bitcoin developer guide on transactions explains inputs, outputs and fees.
How do I send SOL?
Section titled “How do I send SOL?”POST /api/v2/solana/transactions takes from, to, amount and the sender’s privatekey. The OpenAPI file lists all four as required and has no password mode for Solana. SPL tokens use POST /api/v2/solana/transactions/SPL with the additional field contractaddress, which holds the mint address of the token.
How do I set gas and fees on EVM chains?
Section titled “How do I set gas and fees on EVM chains?”You do not have to, because gas, gasprice, maxPriorityFeePerGas and maxFeePerGas are optional. To set them yourself, read the current price with GET /api/v2/ethereum/gasprice, which returns a value such as {"gasPrice":"12.28"} in data. The two max fields correspond to the fee parameters of EIP-1559. The Ethereum documentation on transactions lists all transaction fields, including nonce.
How do I check that the transaction went through?
Section titled “How do I check that the transaction went through?”Use the txid from the response. GET /api/v2/ethereum/transactions/{txid} returns the transaction, and GET /api/v2/ethereum/transactions/{txid}/decoded returns it with decoded input data. A transaction hash that the node does not know answers with status 422 and the message transaction not found. To be told when funds arrive, create a webhook instead of polling.
What errors can I expect?
Section titled “What errors can I expect?”Errors use the same envelope as successful calls, with ok set to false.
| Status | Message | Cause |
|---|---|---|
| 401 | Wrong password provided | The password does not match the address. |
| 422 | insufficient funds for gas * price + value: ... | The balance does not cover the amount plus the fee. |
| 422 | Data validation failed | A field is missing or has the wrong format. The errors object names it. |
| 422 | Error: The wallet passphrase entered was incorrect. | Bitcoin: the wallet password is wrong. |
Important information
Section titled “Important information”Chaingateway does not store your passwords or the private keys of unsecured addresses. If you lose them, nobody can recover the funds on the address. Keep both in a secrets store and never in client-side code.