Bitcoin Metaprotocols Canister Usage Guide
Overview
The Bitcoin Metaprotocols Canister is an Internet Computer (ICP) canister that provides indexing services for Bitcoin metaprotocols, specifically focused on Bitcoin inscriptions. It leverages the Maestro API to fetch and process Bitcoin metaprotocol data, providing structured access to inscription information associated with Bitcoin addresses and UTXOs. Maestro Official Deployed Canister: iayqr-yaaaa-aaaar-qbopq-caiKey Features
- Address Inscriptions: Get all inscriptions associated with a Bitcoin address
- UTXO Inscriptions: Get inscriptions for specific transaction outputs
- Collection Metadata: Fetch collection symbols and floor prices
- Authorization: Built-in access control for authorized callers only
Prerequisites
- A Maestro API key
- Rust - Install Rust
- DFX - Install DFX
- WebAssembly target for Rust:
- Additional tools for Candid generation:
didc
binary from Candid releasesic-wasm
:cargo install ic-wasm
candid-extractor
:cargo install candid-extractor
Authorization
The canister implements access control through a hardcoded list of authorized principals. As it currently exists, only the following principals can call the canister methods:- Maestro principals
- Liquidium principals
- Other authorized entities
Deployment Guide
Local Development Deployment
Note: If the--network
argument is not provided, it defaults to the public playground. For local deployments use --network=local
. For mainnet use --network=ic
.
1. Setup identity (Optional)
Create a new dedicated identity, or: Use the default one for local development:2. Start Local ICP Subnet
In a separate terminal window, start the local Internet Computer subnet. This will create a local canister execution environment and web server processes. This enables you to test your dapps during development.3. Create and Deploy Canister
Create the development canister: Creates an empty canister and associates the assigned Canister ID to the canister name.- A
.did
file is a text file that contains a Candid service description, written either manually or generated from a canister’s code. - It describes the public methods, arguments, and return types of a canister.
dfx canister deploy
to combine the following steps in the future:
dfx canister create <canister_name>
dfx build
dfx canister install <canister_name>
4. Render the Canister
After starting the local ICP subnet, we can leverage Candid UI to interact with our canister directly within the browser.canisterId
query parameter with value: u6s2n-gx777-77774-qaaba-cai
; this is Candid’s canister that is necessary in order to render our canister’s functionality.
Note: ICP’s canister IDs are non-deterministic, so you may need to replace the above uxrrr-q7777-77774-qaaaq-cai
canister ID with the ID that is generated from the Create and Deploy canister step if you are not wiping the subnet state for consecutive deployments.
Canister Interaction
The canister is designed to work with Bitcoin mainnet data through the Maestro API. Note: Regtest support would require modifications to the API endpoints or the use of a regtest-compatible indexing service.Available Methods
The canister exposes the following public methods:1. get_address_inscriptions
Retrieves all inscriptions associated with a Bitcoin address. Method:get_address_inscriptions(address: text, count: text) -> (Result)
Parameters:
address
: Bitcoin address (e.g., “bc1pa2lw8d6u3kkexzqn9hqgzultkzjjc9rxtveldes68ryfdq8tmslqwfuccl”)count
: Maximum number of inscriptions to return (e.g., “10”)
AddressInscriptions
containing:
data
: Array of inscription detailslast_updated
: Block information when data was last updatednext_cursor
: Pagination cursor for additional results
2. get_utxo_inscriptions
Retrieves inscriptions for a specific UTXO (transaction output). Method:get_utxo_inscriptions(tx_hash: text, output_index: text) -> (Result_1)
Parameters:
tx_hash
: Transaction hashoutput_index
: Output index within the transaction
UtxoInscriptions
containing:
data
: Array of inscription details for the UTXOlast_updated
: Block informationnext_cursor
: Pagination cursor
3. set_api_key
Sets the Maestro API key for the canister (admin only). Method:set_api_key(key: text) -> (Result_2)
Parameters:
key
: Maestro API key string
4. get_api_key
Retrieves the current API key (admin only, query method). Method:get_api_key() -> (text)
Returns: Current API key string
Authorization: Only authorized principals can call this method.
Example Usage:
Data Structures
AddressInscription
UtxoInscription
LastUpdated
Troubleshooting
Common Issues
-
“Unauthorized” Error
- Ensure your principal is in the authorized callers list
- Use
dfx identity get-principal
to check your principal ID
-
API Key Issues
- Verify the API key is set correctly
- Ensure you have a valid Maestro API key
- Check that the API key has sufficient permissions
-
Deployment Issues
- Ensure all prerequisites are installed
- Run
make generate_did
before deployment - Check that the WebAssembly target is installed
Getting Canister Information
Cycle Management
The canister uses cycles for HTTP outcalls to the Maestro API. Monitor cycle usage:API Rate Limits and Costs
- Each HTTP request to Maestro API consumes cycles (approximately 1B cycles per request)
- The canister makes multiple API calls per inscription to fetch complete data:
- Address inscriptions API call
- Inscription info API call (per inscription)
- Collection stats API call (per collection)
- OMB color group API call (per inscription)
- Plan cycle usage accordingly based on expected query volume
Debugging
Enable debug logging in the canister by checking theic_cdk::println!
statements in the source code. These will output to the replica logs during development.
- Cycleops for monitoring and topping up canisters.