frBTC Smart Contract
The frBTC synthetic asset is powered by a smart contract running on the Alkanes metaprotocol. This contract is responsible for minting, burning, and managing the supply of frBTC in a trustless and transparent manner.
Contract ABI
The frBTC smart contract exposes the following methods, each identified by a unique opcode:
| Method | Opcode | Parameters |
|---|---|---|
initialize | 0 | None |
set_signer | 1 | vout: u128 |
wrap | 77 | None |
unwrap | 78 | vout: u128 |
set_premium | 4 | premium: u128 |
get_signer | 103 | None |
get_pending_payments | 101 | None |
get_name | 99 | None |
get_symbol | 100 | None |
get_decimals | 102 | None |
get_premium | 104 | None |
Key Methods
wrap (Opcode 77)
The wrap method is the entry point for converting native Bitcoin (BTC) into frBTC. This is an atomic and permissionless process that occurs within a single Bitcoin transaction:
- A user creates a Bitcoin transaction that sends BTC to the FROST-controlled multisig wallet.
- In the same transaction, the user includes a call to the
wrapmethod of thefrBTCsmart contract. - The
fr-btcalkane smart contract validates the transaction, and if the correct amount of BTC has been sent to the multisig, it mints an equivalent amount offrBTCto the user's address.
This atomic nature of the wrapping process ensures that users can instantly and trustlessly convert their BTC into frBTC.
unwrap (Opcode 78)
The unwrap method is used to convert frBTC back into native BTC. This process is orchestrated by the SUBFROST nodes running the subfrost_consensus.wasm program:
- A user initiates an unwrap by calling the
unwrapmethod on thefrBTCsmart contract. This burns theirfrBTCand creates a burn request in the contract's storage. - The SUBFROST consensus nodes monitor the
frBTCcontract for new burn requests. - When a new burn request is detected, the consensus nodes cooperatively sign a Bitcoin transaction to send the corresponding amount of BTC from the FROST-controlled multisig wallet to the user's specified Bitcoin address.
This trust-minimized process ensures that users can always redeem their frBTC for native BTC.
set_signer (Opcode 1)
This method is used to set the public key of the FROST signing group that is authorized to sign unwrapping transactions. This is a privileged operation that can only be called by the owner of the frBTC contract.
get_pending_payments (Opcode 101)
This method allows anyone to query the frBTC contract for a list of pending unwrapping requests. This provides transparency into the unwrapping process and allows users to track the status of their requests.
frBTC in subfrost-cli
The subfrost-cli provides a set of commands for interacting with the frBTC smart contract. These commands allow you to:
- Call a method: The
subfrost-cli contract callcommand allows you to call any method of thefrBTCsmart contract. - Query a method: The
subfrost-cli contract querycommand allows you to query any read-only method of thefrBTCsmart contract.
Calling the wrap Method
Here is an example of how to use the subfrost-cli to call the wrap method:
subfrost-cli contract call --contract <contract-address> --method wrap --amount 1.0
This command will create a Bitcoin transaction that calls the wrap method of the frBTC smart contract and locks 1.0 BTC by sending it to the FROST-controlled multisig wallet.
Calling the unwrap Method
Here is an example of how to use the subfrost-cli to call the unwrap method:
subfrost-cli contract call --contract <contract-address> --method unwrap --amount 1.0 --address <your-bitcoin-address>
This command will create a Bitcoin transaction that calls the unwrap method of the frBTC smart contract and burns 1.0 frBTC. The SUBFROST consensus nodes will then sign a Bitcoin transaction to send 1.0 BTC to your Bitcoin address.