Service exposing features related to tBTC v2 deposits.
- generateDepositReceipt
- initiateCrossChainDeposit
- initiateDeposit
- initiateDepositWithProxy
- setDefaultDepositor
• new DepositsService(tbtcContracts
, bitcoinClient
, crossChainContracts
): DepositsService
Name | Type |
---|---|
tbtcContracts |
TBTCContracts |
bitcoinClient |
BitcoinClient |
crossChainContracts |
(_ : "Base" ) => undefined | CrossChainContracts |
src/services/deposits/deposits-service.ts:51
• Private
Readonly
#crossChainContracts: (_
: "Base"
) => undefined
| CrossChainContracts
▸ (_
): undefined
| CrossChainContracts
Gets cross-chain contracts for the given supported L2 chain.
Name | Type | Description |
---|---|---|
_ |
"Base" |
Name of the L2 chain for which to get cross-chain contracts. |
undefined
| CrossChainContracts
Cross-chain contracts for the given L2 chain or undefined if not initialized.
src/services/deposits/deposits-service.ts:49
• Private
#defaultDepositor: undefined
| ChainIdentifier
Chain-specific identifier of the default depositor used for deposits initiated by this service.
src/services/deposits/deposits-service.ts:42
• Private
Readonly
bitcoinClient: BitcoinClient
Bitcoin client handle.
src/services/deposits/deposits-service.ts:37
• Private
Readonly
depositRefundLocktimeDuration: 23328000
Deposit refund locktime duration in seconds. This is 9 month in seconds assuming 1 month = 30 days
src/services/deposits/deposits-service.ts:29
• Private
Readonly
tbtcContracts: TBTCContracts
Handle to tBTC contracts.
src/services/deposits/deposits-service.ts:33
▸ generateDepositReceipt(bitcoinRecoveryAddress
, depositor
, extraData?
): Promise
<DepositReceipt
>
Name | Type |
---|---|
bitcoinRecoveryAddress |
string |
depositor |
ChainIdentifier |
extraData? |
Hex |
Promise
<DepositReceipt
>
src/services/deposits/deposits-service.ts:183
▸ initiateCrossChainDeposit(bitcoinRecoveryAddress
, l2ChainName
): Promise
<Deposit
>
Initiates the tBTC v2 cross-chain deposit process. A cross-chain deposit is a deposit that targets an L2 chain other than the L1 chain the tBTC system is deployed on. Such a deposit is initiated using a transaction on the L2 chain. To make it happen, the given L2 cross-chain contracts must be initialized along with a L2 signer first.
THIS IS EXPERIMENTAL CODE THAT CAN BE CHANGED OR REMOVED IN FUTURE RELEASES. IT SHOULD BE USED ONLY FOR INTERNAL PURPOSES AND EXTERNAL APPLICATIONS SHOULD NOT DEPEND ON IT. CROSS-CHAIN SUPPORT IS NOT FULLY OPERATIONAL YET.
Name | Type | Description |
---|---|---|
bitcoinRecoveryAddress |
string |
P2PKH or P2WPKH Bitcoin address that can be used for emergency recovery of the deposited funds. |
l2ChainName |
"Base" |
Name of the L2 chain the deposit is targeting. |
Promise
<Deposit
>
Handle to the initiated deposit process.
Throws
Throws an error if one of the following occurs: - There are no active wallet in the Bridge contract - The Bitcoin recovery address is not a valid P2(W)PKH - The cross-chain contracts for the given L2 chain are not initialized - The L2 deposit owner cannot be resolved. This typically happens if the L2 cross-chain contracts operate with a read-only signer whose address cannot be resolved.
See
for cross-chain contracts initialization.
Dev
This is actually a call to initiateDepositWithProxy with a built-in depositor proxy.
src/services/deposits/deposits-service.ts:163
▸ initiateDeposit(bitcoinRecoveryAddress
, extraData?
): Promise
<Deposit
>
Initiates the tBTC v2 deposit process.
Name | Type | Description |
---|---|---|
bitcoinRecoveryAddress |
string |
P2PKH or P2WPKH Bitcoin address that can be used for emergency recovery of the deposited funds. |
extraData? |
Hex |
Optional 32-byte extra data to be included in the deposit script. Cannot be equal to 32 zero bytes. |
Promise
<Deposit
>
Handle to the initiated deposit process.
Throws
Throws an error if one of the following occurs: - The default depositor is not set - There are no active wallet in the Bridge contract - The Bitcoin recovery address is not a valid P2(W)PKH - The optional extra data is set but is not 32-byte or equals to 32 zero bytes.
src/services/deposits/deposits-service.ts:76
▸ initiateDepositWithProxy(bitcoinRecoveryAddress
, depositorProxy
, extraData?
): Promise
<Deposit
>
Initiates the tBTC v2 deposit process using a depositor proxy. The depositor proxy initiates minting on behalf of the user (i.e. original depositor) and receives minted TBTC. This allows the proxy to provide additional services to the user, such as routing the minted TBTC tokens to another protocols, in an automated way.
Name | Type | Description |
---|---|---|
bitcoinRecoveryAddress |
string |
P2PKH or P2WPKH Bitcoin address that can be used for emergency recovery of the deposited funds. |
depositorProxy |
DepositorProxy |
Depositor proxy used to initiate the deposit. |
extraData? |
Hex |
Optional 32-byte extra data to be included in the deposit script. Cannot be equal to 32 zero bytes. |
Promise
<Deposit
>
Handle to the initiated deposit process.
See
DepositorProxy
Throws
Throws an error if one of the following occurs: - There are no active wallet in the Bridge contract - The Bitcoin recovery address is not a valid P2(W)PKH - The optional extra data is set but is not 32-byte or equals to 32 zero bytes.
src/services/deposits/deposits-service.ts:115
▸ setDefaultDepositor(defaultDepositor
): void
Sets the default depositor used for deposits initiated by this service.
Name | Type | Description |
---|---|---|
defaultDepositor |
ChainIdentifier |
Chain-specific identifier of the default depositor. |
void
Dev
Typically, there is no need to use this method when DepositsService is orchestrated automatically. However, there are some use cases where setting the default depositor explicitly may be useful. Make sure you know what you are doing while using this method.