Type/to search
Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
Capability Matrix
Centralized Exchanges
Decentralized Exchanges (DEX)
Prediction Markets
Securities and Futures
On-chain & Custom

Transfers the chain's native coin (such as ETH or BNB) or an ERC20 token out of the configured wallet.

exchange.IO(k, to, amount)
exchange.IO(k, to, amount, token)

Examples

Transfer ETH and USDC, then wait for the transaction to be confirmed on-chain.

javascript
function main() { var TO = "0xRecipientAddress" // Transfer 0.05 ETH; use "all" to transfer the full balance var r = exchange.IO("transfer", TO, "0.05") if (!r) { Log("Transfer failed:", GetLastError()) return } Log("Sent", r.amount, r.token, "tx:", r.txHash) // Wait up to 3 minutes for on-chain confirmation var rc = exchange.IO("receipt", r.txHash, 180000) if (rc.pending) { Log("Not on-chain yet") } else { Log("Result:", rc.status, "block:", rc.blockNumber, "fee:", rc.fee) } // Transfer 10 USDC var r2 = exchange.IO("transfer", TO, "10", "USDC") Log(r2 ? r2.txHash : GetLastError()) }

Returns

TypeDescription

object / null value

When the transaction is broadcast successfully, returns {txHash, from, to, token, tokenAddress, amount, raw}: txHash is the transaction hash, amount is the amount transferred (in human-readable units), raw is the same amount as a decimal string in the smallest unit, and tokenAddress is null when the native coin is transferred. The function only waits for the broadcast, not for the transaction to be confirmed on-chain; check the on-chain result with exchange.IO("receipt", ...). On failure it returns null, and GetLastError() gives the reason.

Arguments

NameTypeRequiredDescription

k

string

Yes

Always transfer, which runs a transfer.

to

string

Yes

Recipient address: a 20-byte hexadecimal address that starts with 0x. It must be an address on the same chain as the exchange object.

amount

string / number

Yes

Amount to transfer, in human-readable units (for example, "0.05" means 0.05 ETH). Passing it as a string is recommended, because the system then converts it exactly using the token's decimals. If it has more decimal places than the token supports, an error is raised right away; it is never silently truncated. Set it to all to transfer everything: for the native coin, the maximum fee for this transaction is reserved and the rest is transferred; for a token, the whole balance is transferred.

token

string

No

Token to transfer. It can be a token name (such as USDC, resolved the same way as token names in trading pairs: built-in or registered tokens in the token table, plus tokens in the official token list; see exchange.IO("token", ...)) or a token contract address. If it is omitted, the native coin is transferred.

See Also

Remarks

In the following cases an error is raised before signing and no transaction is sent: an invalid address format, the zero address, a transfer to the wallet itself, an amount of 0, an amount larger than the balance, or a token that cannot be identified.

When the whole native-coin balance is transferred (all) on an EIP-1559 chain, the maximum fee quoted for this transaction is reserved. Because the fee actually charged is lower than the reserve, a very small balance stays in the wallet.

The priority fee (tip) is the larger of the node's suggested value and the median priority fee in recent blocks. This keeps a transaction from staying unconfirmed for a long time when the node suggests 0.

A transfer is a real on-chain transaction and cannot be reversed once sent. Before sending to an exchange deposit address, make sure the exchange accepts deposits on this chain.