Private
foreignPrivate
layer1This call will perform an ERC-20 approve
action on the tokens to grant the Token Bridge contract the ability bridge your tokens. This method is invoked with:
TokenBridgeForeignSide.getSupportedTokens
method to get a list of supported tokens.wei
) and as string.a promise that includes a web3 transaction receipt, from which you can obtain the transaction hash, ethereum events, and other details about the transaction https://web3js.readthedocs.io/en/v1.3.4/web3-eth-contract.html#id37.
let txnReceipt = await tokenBridge.unlockTokens(
"0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa",
new BN("1000000000000000000") // this is 1 token in wei
);
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThis call will invoke the token bridge contract to relay tokens that have been unlocked in layer 1 and relay them to layer 2. It is always a good idea to relay the same number of tokens that were just unlocked. So if you unlocked 10 tokens, then you should subsequently relay 10 tokens. Once the tokens have been relayed to the layer 2 network they will be deposited in a Gnosis safe that you control in layer 2. You can use the Safes.view
to obtain the address of the safe that you control in layer 2. Your safe will be reused for any subsequent tokens that you bridge into layer 2.
a promise that includes a web3 transaction receipt, from which you can obtain the transaction hash, ethereum events, and other details about the transaction https://web3js.readthedocs.io/en/v1.3.4/web3-eth-contract.html#id37.
let txnReceipt = await tokenBridge.relayTokens(
"0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa", // token address
"0x7cc103485069bbba15799f5dac5c42e7bbb48b4d064e61548022bf04db1bfc19", // layer 2 recipient address
new BN("1000000000000000000") // this is 1 token in wei
);
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThis call will allow the recipient of tokens bridge from layer 2 to layer 1 to be able to claim their bridge tokens in layer 1.
let txnReceipt = await tokenBridge.claimBridgedTokens(messageId, encodedData, signatures);
a promise for a web3 transaction receipt.
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsPrivate
getPrivate
getGenerated using TypeDoc
The
TokenBridgeForeignSide
API is used to bridge tokens into the layer 2 network in which the Card Protocol runs. TheTokenBridgeForeignSide
API can be obtained fromgetSDK()
with aWeb3
instance that is configured to operate on a layer 1 network (like Ethereum Mainnet or Kovan).Example
Remarks
Note: To accommodate the fix for infura block mismatch errors (made in CS-2391), we are waiting one extra block for all layer 1 transactions.