Custom mode
Apart from the opinionated initialization functions, the SDK provides a flexible TBTC.initializeCustom function for advanced users.
Using locally deployed tBTC contracts and local Bitcoin network
import * as ethers from "ethers"
import {
TBTC,
TBTCContracts,
EthereumBridge,
EthereumTBTCToken,
EthereumTBTCVault,
EthereumWalletRegistry,
ElectrumClient,
} from "@keep-network/tbtc-v2.ts"
// Create an Ethers provider. Pass the URL of your local Ethereum node.
const provider = new ethers.providers.JsonRpcProvider("...")
// Create an Ethers signer. Pass the private key and the above provider.
const signer = new ethers.Wallet("...", provider)
// Create a reference to your locally deployed tBTC contracts.
// ABI will be loaded from the following contract packages:
// - @keep-network/tbtc-v2
// - @keep-network/ecdsa
const tbtcContracts: TBTCContracts = {
bridge: new EthereumBridge({address: "...", signerOrProvider: signer}),
tbtcToken: new EthereumTBTCToken({address: "...", signerOrProvider: signer}),
tbtcVault: new EthereumTBTCVault({address: "...", signerOrProvider: signer}),
walletRegistry: new EthereumWalletRegistry({address: "...", signerOrProvider: signer})
}
// Create an Electrum Bitcoin client pointing to your local regtest node.
const bitcoinClient = ElectrumClient.fromUrl("...")
// Initialize the SDK.
const sdk = await TBTC.initializeCustom(tbtcContracts, bitcoinClient)Using a custom Bitcoin client instead of the automatically configured one
Using mock tBTC contracts and mock Bitcoin network
Last updated
Was this helpful?