Skip to main content

Submitting transactions

Advanced
Bitcoin
Tutorial

To submit transactions to the Bitcoin network, the Bitcoin integration API exposes the bitcoin_send_transaction method.

Submitting transactions

The following snippet shows how to send a signed transaction to the Bitcoin network.

The Bitcoin Testnet API is currently disabled and the ckTestBTC minter canister has been stopped. This is temporary and they will be re-enabled in the future.

Learn more.

 type ManagementCanisterActor = actor {
bitcoin_send_transaction : SendTransactionRequest -> async ();
};

let management_canister_actor : ManagementCanisterActor = actor("aaaaa-aa");

public func send_transaction(network : Network, transaction : [Nat8]) : async () {
let transaction_fee =
SEND_TRANSACTION_BASE_COST_CYCLES + transaction.size() * SEND_TRANSACTION_COST_CYCLES_PER_BYTE;

ExperimentalCycles.add(transaction_fee);
await management_canister_actor.bitcoin_send_transaction({
network;
transaction;
})
};
View in the full example.

Resources