Initializing the SDK
Once you have installed the SDK, you can start building your application.
The main class you will interact with is the TeleportBridge.
import { TeleportBridge } from 'teleport-sdk'
Getting a TeleportBridge instance
The TeleportBridge requires some arguments in its constructor, namely a Source Domain and a Source Domain Provider. Supported source domains are
* optimism
* arbitrum
* optimism-goerli-testnet
* arbitrum-goerli-testnet
Wherever providers are omitted from the TeleportBridge
constructor, a default provider will be used.
The Source Domain Provider should be an ethers.js
Provider
.
To continue teleportation, you should connect to the user's wallet and pass the signer to functions that result in an on-chain call being made. The SDK will take care of proposing transactions to the user.
The Destination Domain Provider is required in case relayers can't be used to relay the transaction on the destination domain. See Receiving Teleported Funds.
You can omit the Destination Domain when using one of the supported domains as your source domain and the SDK will select the parent network as the destination domain. For example, if you select arbitrum
as your source domain, the SDK will select Mainnet as the destination.
// Create a TeleportBridge object that handles Fast Withdrawals from Arbitrum to Mainnet.
import { TeleportBridge } from 'teleport-sdk'
const bridge = new TeleportBridge({
srcDomain: 'abritrum',
srcDomainProvider: <network provider from ethers.js>
})