Bridge
Serves as a facilitator of deposits and withdrawals between Bitcoin and Citrea. It verifies Bitcoin transactions for deposits and manages withdrawal requests to be processed on the Bitcoin network.
You can find the contract in the address 0x31000...0002
, here.
Deposit Structure
The following is an explanation regarding the TransactionParams
structure, which is used to represent deposits made to Citrea from the Bitcoin network using Clementine.
Parameters | Description |
---|---|
| Version field of a transaction |
| Marker + Flag of a segregated witness transaction |
| Transaction inputs |
| Transaction outputs |
| Transaction witness |
| Transaction locktime |
| The proof's intermediate nodes |
| Block Height |
| The leaf's index in the tree (0-indexed) |
To understand more, please check the way deposit params are used along with the BitcoinLightClient
contract from both our documentation and explorer.
State Structure
A flag indicating whether the contract has been initialized.
The address of the privileged operator who can process user deposits.
A list of values indicating if a operator is marked as malicious.
The fixed amount for deposits and withdrawals, set to 10 ether (cBTC) for Citrea Testnet.
Index of the latest processed deposit.
The prefix part of deposit script for all L1 (Bitcoin) deposits.
The suffix part of the deposit script that follows the receiver address.
Script that is used for "slash or take" transactions on Bitcoin. These transactions are sent after an operator proves that they covered a withdrawal through declareWithdrawFiller
and it is used as a part of the process that enables the operator to get back the amount they covered from N-of-N multisig on Bitcoin.
An array to store ANYONE_CAN_PAY
UTXOs on Bitcoin that are utilized as withdraw intents that are covered by operators later on. This stored UTXO information is used to prove that an operator covered a certain withdrawal through declareWithdrawFiller
.
A mapping that maps the transaction IDs of deposit transactions on Bitcoin to their deposit IDs on Citrea side.
A mapping that maps the withdraw ID to operator ID that covered the withdrawal with that withdraw ID.
Access Control Structure
Ensures that only the system caller (0xdeaDDeADDEaDdeaDdEAddEADDEAdDeadDEADDEaD
) can call the function.
Ensures that only the designated operator can call the function.
Ensures that only the contract owner can call the function (inherited from Ownable).
Functions
Initializes the bridge contract and sets the initial deposit script parameters.
Parameters | Description |
---|---|
| The prefix part of deposit script for all L1 (Bitcoin) deposits. |
| The suffix part of the deposit script that follows the receiver address |
| The fixed amount for deposits and withdrawals, set to 10 ether (cBTC) for Citrea Testnet. |
Updates the expected deposit script parameters.
Parameters | Description |
---|---|
| The prefix part of new deposit script for all L1 (Bitcoin) deposits. |
| The suffix part of the new deposit script that follows the receiver address. |
Updates the expected slash or take script. See slashOrTakeScript
in State Structure
for detailed information.
Parameters | Description |
---|---|
| New expected slash or take script. |
Processes a deposit from Bitcoin to Citrea by verifying the Bitcoin transaction and sending configured bridge amount of cBTC to the recipient. Can only be called by the designated operator.
Parameters | Description |
---|---|
| Struct containing deposit transaction details from Bitcoin |
Accepts configured bridge amount of cBTC from the sender and records a withdrawal request to be processed on Bitcoin. This recording is done by storing a UTXO consisting of a txId
and an outputId
which is the input for the ANYONE_CAN_PAY
withdraw transaction on Bitcoin.
Parameters | Description |
---|---|
| Transaction ID for the input of the withdraw transaction on Bitcoin |
| Output index for the input of the withdraw transaction on Bitcoin |
Batch version of withdraw
that can accept multiple withdrawal requests at once.
Parameters | Description |
---|---|
| Array of transaction IDs for the inputs of the withdraw transactions on Bitcoin |
| Array of output indexes for the inputs of the withdraw transactions on Bitcoin |
Returns the total number of withdrawal requests made so far.
Returns | Description |
---|---|
| The count of withdrawals happened so far |
Sets the operator address that can process user deposits.
Parameters | Description |
---|---|
| Address of the privileged operator |
Stores which operator filled a certain withdraw request. Operators should make sure this function is called before sending a "slash or take" transaction on Bitcoin to avoid being marked as malicious.
Parameters | Description |
---|---|
| Struct containing withdraw transaction details from Bitcoin |
| Input of the withdraw transaction that corresponds to the stored UTXO for the withdraw request denoted with |
| The ID of stored withdraw request |
Marks an operator as malicious if they sent a "slash or take" transaction on Bitcoin without first proving that they covered a withdrawal through declareWithdrawFiller
. This information is later on used as evidence in the process of BitVM challenges on the Bitcoin side to prevent the operator stealing user funds from N-of-N multisig, as not being able to successfully call declareWithdrawFiller
indicates that the operator is trying to claim funds from multisig even though they didn't cover a withdrawal request.
Parameters | Description |
---|---|
| Struct containing slash or take transaction details from Bitcoin |
Reverts if the provided transaction is not properly structured or not an actual Bitcoin transaction that happened according to BitcoinLightClient
.
Parameters | Description |
---|---|
| Struct containing transaction details from Bitcoin |
Returns | Description |
---|---|
| Witness transaction ID of the provided transaction |
| Number of inputs of the provided transaction |
Extracts the recipient from a given script.
Parameters | Description |
---|---|
| The script to be processed |
Returns | Description |
---|---|
| The recipient |
Events
Emitted when a deposit is successfully processed.
Parameters | Description |
---|---|
| The witness transaction ID of the Bitcoin transaction |
| The transaction ID of the Bitcoin transaction |
| The Citrea address receiving the deposited cBTC |
| The timestamp of the deposit |
| The ID of the deposit |
Emitted when a withdrawal request is recorded.
Parameters | Description |
---|---|
| UTXO to store for the withdrawal request |
| The index of the withdrawal in the |
| The timestamp of the |
Emitted when the deposit script parameters are updated.
Parameters | Description |
---|---|
| The new script prefix |
| The new script suffix |
Emitted when the operator address is updated.
Parameters | Description |
---|---|
| The previous operator address |
| The new operator address |
Emitted when the operator filled a withdrawal request is declared.
Parameters | Description |
---|---|
| The withdraw ID |
| ID of the operator that filled the withdrawal request |
Emitted when an operator is marked as malicious.
Parameters | Description |
---|---|
| ID of the operator that is marked as malicious |
Emitted when slash or take script is updated.
Parameters | Description |
---|---|
| New expected slash or take script |
Last updated