Example Implementation
This is a short example implementation of a teleportation script that teleports 1 DAI from Arbitrum One to Ethereum Mainnet.
For more examples, check out the demo repository.
import { TeleportBridge } from 'teleport-sdk'
// assume getSigner returns a ethers.js Signer
import getSigner from 'src/getMetamaskSigner'
// get a hold of a signer
const signer = getSigner()
// initialize a bridge object
const bridge = new TeleportBridge({
srcDomain: 'arbitrum',
})
// get fees to be paid for teleporting 1 DAI
const amounts = await bridge.getAmounts(
ethers.constants.WeiPerEther()
)
// start teleporting 1 DAI
const bridgeCall = await bridge.initTeleport({
sender: signer,
receiverAddress: signer.address,
amount: ethers.constants.WeiPerEther(),
})
// recover the TeleportGUID from our sent transaction
const guid = await bridge.getTeleportGUIDFromTxHash(
call.tx.hash
)
// collect attestations from the Maker Oracle network
const attestations = await bridge.getAttestations(
call.tx.hash
)
// send the GUID and attestations to a relayer and wait until the transaction has been posted
await bridge.relayMintWithOracles(
receiver: signer.address,
teleportGUID: guid,
signatures: attestations,
relayFee: amounts.relayFee
)