Introduction
The Build on Dogecoin book is intended for developers to explain how smart contracts on the Internet Computer, often referred as canisters, can interact with the Dogecoin blockchain.
Background
Through a protocol-level integration with the Dogecoin network, canisters deployed on ICP can interact with the Dogecoin network directly without using a bridge or oracle.
To interact with the Dogecoin blockchain, your canister will make use of the following:
-
Dogecoin canister: Think of it as your decentralized gateway to reach the Dogecoin blockchain. This canister provides an API that can be used by others to query information about the Dogecoin network state, for example, unspent transaction outputs (UTXOs), block headers, or the balance of any Dogecoin address; and to send transactions to the network.
-
Threshold ECDSA: Your canister can have a secret key that is stored in a secure and decentralized manner using chain-key cryptography (several such keys can be computed by key derivation). Messages sent by the canister can be signed using this key, enabling your canister to send signed transactions to the Dogecoin network through the Dogecoin canister.
To submit a Dogecoin transaction from a canister, the following steps are typically performed:
- Request a public key from the threshold ECDSA API
- Derive a Dogecoin address from the public key
- Read UTXOs from the Dogecoin API
- Build the transaction payload
- Sign the transaction using the threshold ECDSA API
- Submit the transaction to the Dogecoin API
Getting Started
First, set up your development environment. Then, to build canisters interacting with the Dogecoin network, you will need to know how to:
-
Generate a Dogecoin address. Dogecoin addresses are necessary for your canister to sign transactions and hold DOGE. A canister can have multiple addresses.
-
Create a Dogecoin transaction. Dogecoin transactions spend UTXOs and create new UTXOs. A UTXO is the output of a Dogecoin transaction. It exists until it is used as the input of another transaction.
-
Sign the transaction using threshold ECDSA API. All inputs of a transaction must be signed before the transaction can be submitted to the Dogecoin network.
-
Submit the transaction by sending a request to the Dogecoin API that specifies the blob of the transaction and the target Dogecoin network (mainnet or regtest).
-
Read information from the Dogecoin network, such as UTXOs, address balances, or block headers.
Additional resources
Building Dogecoin applications is not trivial. Itβs beneficial to understand core Bitcoin concepts which underpin Dogecoin, including transactions, UTXOs, the Script language, and hash formats.