Skip to content

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.

Sending a native coin: post from, to, amount and password or private key, Chaingateway signs and broadcasts the transaction, the response returns the txid, then you read the transaction status POST /api/v2/{chain}/transactions from, to, amount, password or privatekey Chaingateway signs and broadcasts Response: txid status 201, message Succesfully createdtransaction GET /api/v2/{chain}/transactions/{txid} check the transaction on the chain
The same four steps apply on every chain, only the body fields differ.

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.

FieldRequiredMeaning
fromyesSender address, validated as 40 hex characters with an optional 0x.
toyesRecipient address, same format.
amountyesThe amount to send.
passwordone of the twoWallet password. Required when privatekey is not present.
privatekeyone of the twoPrivate key of the sender, for addresses created without a password.
gas, gasprice, maxPriorityFeePerGas, maxFeePerGas, nonce, datanoOptional 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.

Terminal window
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"
}'

A successful call answers with status 201 and the transaction hash:

{
"status": 201,
"ok": true,
"message": "Succesfully created transaction",
"data": {
"txid": "0x73344d178812d4919e9002c560781f288030edf72ece88823ef1c377dfb71f27"
}
}

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.

Terminal window
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.

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.

Terminal window
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.

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.

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.

Errors use the same envelope as successful calls, with ok set to false.

StatusMessageCause
401Wrong password providedThe password does not match the address.
422insufficient funds for gas * price + value: ...The balance does not cover the amount plus the fee.
422Data validation failedA field is missing or has the wrong format. The errors object names it.
422Error: The wallet passphrase entered was incorrect.Bitcoin: the wallet password is wrong.

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.