btc.sendTransaction
Send BTC chain transactions via the btc object.
Usage
Transfer BTC
ts
const result = await Turing.btc.sendTransaction({
toAddress: "bc1qxyz...",
amount: "100000", // 100000 satoshis
broadcastEnabled: true,
});
if (result.txid) {
console.log("Transaction hash:", result.txid);
}Without Broadcasting
ts
const result = await Turing.btc.sendTransaction({
toAddress: "bc1qxyz...",
amount: "100000",
broadcastEnabled: false,
});
if (result.txraw) {
console.log("Raw transaction data:", result.txraw);
}Parameters
ts
interface BtcSendTransaction {
toAddress: string; // Recipient address
amount: string; // Transfer amount in satoshis
broadcastEnabled?: boolean; // Whether to broadcast, defaults to true
}| Field | Type | Description |
|---|---|---|
toAddress | string | Recipient BTC address |
amount | string | Transfer amount in satoshis |
broadcastEnabled | boolean | (Optional) Whether to broadcast the transaction. Defaults to true |
Returns
ts
interface BtcSendTransactionResponse {
txid?: string; // Transaction hash (returned on successful broadcast)
txraw?: string; // Raw transaction data (returned when broadcastEnabled is false)
error?: string; // Error message
}| Field | Type | Description |
|---|---|---|
txid | string | Transaction hash on successful broadcast |
txraw | string | Raw transaction data when broadcastEnabled is false |
error | string | Error message if the transaction fails |
Error Handling
ts
const result = await Turing.btc.sendTransaction({
toAddress: "bc1qxyz...",
amount: "100000",
});
if (result.error) {
console.error("Transaction failed:", result.error);
return;
}
console.log("Success! txid:", result.txid);Live Example
Live Example
Turing.btc.sendTransaction()
Unknown
Use the wallet control in the top navigation before running this example.
Active Wallet NetworkUnknown
Switch the wallet to BTC or All networks first.
Switch the wallet to BTC or All networks first.
Code Preview
const result = await Turing.btc.sendTransaction({
"toAddress": "1BitcoinEaterAddressDontSendf59kuE",
"amount": "100000",
"broadcastEnabled": false
});
console.log(result);