Skip to main content

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:

MethodOpcodeParameters
initialize0None
set_signer1vout: u128
wrap77None
unwrap78vout: u128
set_premium4premium: u128
get_signer103None
get_pending_payments101None
get_name99None
get_symbol100None
get_decimals102None
get_premium104None

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:

  1. A user creates a Bitcoin transaction that sends BTC to the FROST-controlled multisig wallet.
  2. In the same transaction, the user includes a call to the wrap method of the frBTC smart contract.
  3. The fr-btc alkane smart contract validates the transaction, and if the correct amount of BTC has been sent to the multisig, it mints an equivalent amount of frBTC to 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:

  1. A user initiates an unwrap by calling the unwrap method on the frBTC smart contract. This burns their frBTC and creates a burn request in the contract's storage.
  2. The SUBFROST consensus nodes monitor the frBTC contract for new burn requests.
  3. 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 call command allows you to call any method of the frBTC smart contract.
  • Query a method: The subfrost-cli contract query command allows you to query any read-only method of the frBTC smart 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.