# How to get bitcoin working inside a canister

**URL:** <https://forum.dfinity.org/t/how-to-get-bitcoin-working-inside-a-canister/14339>\
**Category:** Developers\
**Created:** [July 15, 2022, 12:40pm UTC](https://forum.dfinity.org/t/how-to-get-bitcoin-working-inside-a-canister/14339 "2022-07-15T12:40:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pramitgaha](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/pramitgaha/32/11659_2.png) [@pramitgaha](https://forum.dfinity.org/u/pramitgaha)\
**Post date:** [July 15, 2022, 12:40pm UTC](https://forum.dfinity.org/t/how-to-get-bitcoin-working-inside-a-canister/14339/1 "2022-07-15T12:40:55Z")

</div>

seeing example and demo, I saw that user deposit btc from a btc wallet to the canister.  
is this the only way to do that?  
Q1: Can this be done like, " user calls a function of a canister and that function handles the deposit of the btc on the behalf of user?"

Q2:

```nohighlight
pub struct SendTransactionRequest {
    pub transaction: Vec<u8>,
    pub network: Network,
}

```

here what data is passed in the transaction field?  
address of the receiver? amount to be send to the receiver?  
combination of amount + receiver address ?

---

<div class="post-metadata">

**Author:** ![Benjamin\_Loison](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/benjamin_loison/32/4860_2.png) [@Benjamin\_Loison](https://forum.dfinity.org/u/Benjamin_Loison)\
**Post date:** [July 18, 2022, 8:04am UTC](https://forum.dfinity.org/t/how-to-get-bitcoin-working-inside-a-canister/14339/2 "2022-07-18T08:04:06Z")

</div>

Q1:

As far as I know the only way to get bitcoins on a canister is by making a user send bitcoins from his wallet to the Bitcoin canister address.

Q2:

As described in [the Internet Computer Interface Specification](https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-bitcoin_send_transaction), `bitcoin_send_transaction` requires to:

> specify a `blob` of a Bitcoin [signed] transaction

You can find out the format of a Bitcoin transaction [here](https://en.bitcoin.it/wiki/Transaction).  
So in addition to other fields as described above, the address of the receiver and the amount to be send to the receiver are part of the Bitcoin transaction.  
These **two draft PRs** adding more detailed examples in [Rust](https://github.com/dfinity/examples/pull/280/files#diff-8c69dea28fd2d109074bc9f748f1b98eb3ce19f689f811add46983c452103845R32-R99) and [Motoko](https://github.com/dfinity/examples/pull/281/files#diff-5b452b3947288002cd0b0bf245010061a0f4ad295a469135b7d388cd2f0c2d2aR57-R96) may give you a precise idea on how to broadcast to the Bitcoin network a Bitcoin transaction.

Don’t hesitate to let us know if you have some questions following these readings.
