Skip to main content

Submitting transactions

Advanced
Bitcoin
Tutorial

Overview

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.

 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