Skip to main content

Module: assetBridger/erc20Bridger

AdminErc20Bridger

Admin functionality for the token bridge

Extends

Constructors

constructor()

new AdminErc20Bridger(l2Network): AdminErc20Bridger

Bridger for moving ERC20 tokens back and forth between L1 to L2

Parameters
ParameterType
l2NetworkL2Network
Returns

AdminErc20Bridger

Inherited from

Erc20Bridger.constructor

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:181

Methods

approveToken()

approveToken(params): Promise< ContractTransaction >

Approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.

Parameters
ParameterTypeDescription
paramsApproveParamsOrTxRequest
Returns

Promise\< ContractTransaction >

Inherited from

Erc20Bridger.approveToken

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:269


checkL1Network()

protected checkL1Network(sop): Promise< void >

Check the signer/provider matches the l1Network, throws if not

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise\< void >

Inherited from

Erc20Bridger.checkL1Network

Source

arbitrum-sdk/src/lib/assetBridger/assetBridger.ts:48


checkL2Network()

protected checkL2Network(sop): Promise< void >

Check the signer/provider matches the l2Network, throws if not

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise\< void >

Inherited from

Erc20Bridger.checkL2Network

Source

arbitrum-sdk/src/lib/assetBridger/assetBridger.ts:56


deposit()

deposit(params): Promise< L1ContractCallTransaction >

Execute a token deposit from L1 to L2

Parameters
ParameterTypeDescription
paramsErc20DepositParams | L1ToL2TxReqAndSignerProvider
Returns

Promise\< L1ContractCallTransaction >

Inherited from

Erc20Bridger.deposit

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:604


getApproveTokenRequest()

getApproveTokenRequest(params): Promise< Required< Pick< TransactionRequest, "data" | "value" | "to" > > >

Get a tx request to approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.

Parameters
ParameterTypeDescription
paramsProviderTokenApproveParams
Returns

Promise\< Required\< Pick\< TransactionRequest, "data" | "value" | "to" > > >

Inherited from

Erc20Bridger.getApproveTokenRequest

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:236


getDepositRequest()

getDepositRequest(params): Promise< L1ToL2TransactionRequest >

Get the arguments for calling the deposit function

Parameters
ParameterTypeDescription
paramsDepositRequest
Returns

Promise\< L1ToL2TransactionRequest >

Inherited from

Erc20Bridger.getDepositRequest

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:506


getL1ERC20Address()

getL1ERC20Address(erc20L2Address, l2Provider): Promise< string >

Get the corresponding L1 for the provided L2 token Validates the returned address against the l2 router to ensure it is correctly mapped to the provided erc20L2Address

Parameters
ParameterTypeDescription
erc20L2Addressstring
l2ProviderProvider
Returns

Promise\< string >

Inherited from

Erc20Bridger.getL1ERC20Address

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:434


getL1GatewayAddress()

getL1GatewayAddress(erc20L1Address, l1Provider): Promise< string >

Get the address of the l1 gateway for this token

Parameters
ParameterTypeDescription
erc20L1Addressstring
l1ProviderProvider
Returns

Promise\< string >

Inherited from

Erc20Bridger.getL1GatewayAddress

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:200


getL1GatewaySetEvents()

getL1GatewaySetEvents(l1Provider, filter): Promise< {gateway: string; l1Token: string;}[] >

Get all the gateway set events on the L1 gateway router

Parameters
ParameterTypeDescription
l1ProviderProvider
filterobject-
filter.fromBlockBlockTag-
filter.toBlockBlockTag-
Returns

Promise\< {gateway: string; l1Token: string;}[] >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:864


getL1TokenContract()

getL1TokenContract(l1Provider, l1TokenAddr): ERC20

Get the L1 token contract at the provided address Note: This function just returns a typed ethers object for the provided address, it doesnt check the underlying form of the contract bytecode to see if it's an erc20, and doesn't ensure the validity of any of the underlying functions on that contract.

Parameters
ParameterTypeDescription
l1ProviderProvider
l1TokenAddrstring
Returns

ERC20

Inherited from

Erc20Bridger.getL1TokenContract

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:401


getL2ERC20Address()

getL2ERC20Address(erc20L1Address, l1Provider): Promise< string >

Get the corresponding L2 for the provided L1 token

Parameters
ParameterTypeDescription
erc20L1Addressstring
l1ProviderProvider
Returns

Promise\< string >

Inherited from

Erc20Bridger.getL2ERC20Address

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:411


getL2GatewayAddress()

getL2GatewayAddress(erc20L1Address, l2Provider): Promise< string >

Get the address of the l2 gateway for this token

Parameters
ParameterTypeDescription
erc20L1Addressstring
l2ProviderProvider
Returns

Promise\< string >

Inherited from

Erc20Bridger.getL2GatewayAddress

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:218


getL2GatewaySetEvents()

getL2GatewaySetEvents(
l2Provider,
filter,
customNetworkL2GatewayRouter?): Promise< {gateway: string; l1Token: string;}[] >

Get all the gateway set events on the L2 gateway router

Parameters
ParameterType
l2ProviderProvider
filterobject
filter.fromBlockBlockTag
filter.toBlock?BlockTag
customNetworkL2GatewayRouter?string
Returns

Promise\< {gateway: string; l1Token: string;}[] >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:887


getL2TokenContract()

getL2TokenContract(l2Provider, l2TokenAddr): L2GatewayToken

Get the L2 token contract at the provided address Note: This function just returns a typed ethers object for the provided address, it doesnt check the underlying form of the contract bytecode to see if it's an erc20, and doesn't ensure the validity of any of the underlying functions on that contract.

Parameters
ParameterTypeDescription
l2ProviderProvider
l2TokenAddrstring
Returns

L2GatewayToken

Inherited from

Erc20Bridger.getL2TokenContract

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:385


getL2WithdrawalEvents()

getL2WithdrawalEvents(
l2Provider,
gatewayAddress,
filter,
l1TokenAddress?,
fromAddress?): Promise< {_amount: BigNumber; _exitNum: BigNumber; _from: string; _l2ToL1Id: BigNumber; _to: string; l1Token: string;} & {txHash: string;}[] >

Get the L2 events created by a withdrawal

Parameters
ParameterTypeDescription
l2ProviderProvider
gatewayAddressstring
filterobject
filter.fromBlockBlockTag-
filter.toBlock?BlockTag-
l1TokenAddress?string
fromAddress?string
Returns

Promise\< {_amount: BigNumber; _exitNum: BigNumber; _from: string; _l2ToL1Id: BigNumber; _to: string; l1Token: string;} & {txHash: string;}[] >

Inherited from

Erc20Bridger.getL2WithdrawalEvents

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:295


getWithdrawalRequest()

getWithdrawalRequest(params): Promise< L2ToL1TransactionRequest >

Get the arguments for calling the token withdrawal function

Parameters
ParameterTypeDescription
paramsErc20WithdrawParams
Returns

Promise\< L2ToL1TransactionRequest >

Inherited from

Erc20Bridger.getWithdrawalRequest

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:640


l1TokenIsDisabled()

l1TokenIsDisabled(l1TokenAddress, l1Provider): Promise< boolean >

Whether the token has been disabled on the router

Parameters
ParameterTypeDescription
l1TokenAddressstring
l1ProviderProvider
Returns

Promise\< boolean >

Inherited from

Erc20Bridger.l1TokenIsDisabled

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:473


registerCustomToken()

registerCustomToken(
l1TokenAddress,
l2TokenAddress,
l1Signer,
l2Provider): Promise< L1ContractTransaction< L1TransactionReceipt > >

Register a custom token on the Arbitrum bridge See https://developer.offchainlabs.com/docs/bridging_assets#the-arbitrum-generic-custom-gateway for more details

Parameters
ParameterTypeDescription
l1TokenAddressstringAddress of the already deployed l1 token. Must inherit from https://developer.offchainlabs.com/docs/sol_contract_docs/md_docs/arb-bridge-peripherals/tokenbridge/ethereum/icustomtoken.
l2TokenAddressstringAddress of the already deployed l2 token. Must inherit from https://developer.offchainlabs.com/docs/sol_contract_docs/md_docs/arb-bridge-peripherals/tokenbridge/arbitrum/iarbtoken.
l1SignerSignerThe signer with the rights to call registerTokenOnL2 on the l1 token
l2ProviderProviderArbitrum rpc provider
Returns

Promise\< L1ContractTransaction\< L1TransactionReceipt > >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:742


setGateways()

setGateways(
l1Signer,
l2Provider,
tokenGateways,
options?): Promise< L1ContractCallTransaction >

Register the provided token addresses against the provided gateways

Parameters
ParameterTypeDescription
l1SignerSigner
l2ProviderProvider
tokenGatewaysTokenAndGateway[]
options?GasOverrides-
Returns

Promise\< L1ContractCallTransaction >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:919


withdraw()

withdraw(params): Promise< L2ContractTransaction >

Withdraw tokens from L2 to L1

Parameters
ParameterTypeDescription
paramsL2ToL1TxReqAndSigner | OmitTyped\< Erc20WithdrawParams, "from" > & {l2Signer: Signer;}
Returns

Promise\< L2ContractTransaction >

Inherited from

Erc20Bridger.withdraw

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:694


fromProvider()

static fromProvider(l2Provider): Promise< Erc20Bridger >

Instantiates a new Erc20Bridger from an L2 Provider

Parameters
ParameterTypeDescription
l2ProviderProvider
Returns

Promise\< Erc20Bridger >

Inherited from

Erc20Bridger.fromProvider

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:190


Erc20Bridger

Bridger for moving ERC20 tokens back and forth between L1 to L2

Extends

Constructors

constructor()

new Erc20Bridger(l2Network): Erc20Bridger

Bridger for moving ERC20 tokens back and forth between L1 to L2

Parameters
ParameterType
l2NetworkL2Network
Returns

Erc20Bridger

Overrides

AssetBridger\< Erc20DepositParams | L1ToL2TxReqAndSignerProvider, OmitTyped\<Erc20WithdrawParams, 'from'> | L2ToL1TransactionRequest >.constructor

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:181

Methods

approveToken()

approveToken(params): Promise< ContractTransaction >

Approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.

Parameters
ParameterTypeDescription
paramsApproveParamsOrTxRequest
Returns

Promise\< ContractTransaction >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:269


checkL1Network()

protected checkL1Network(sop): Promise< void >

Check the signer/provider matches the l1Network, throws if not

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise\< void >

Inherited from

AssetBridger.checkL1Network

Source

arbitrum-sdk/src/lib/assetBridger/assetBridger.ts:48


checkL2Network()

protected checkL2Network(sop): Promise< void >

Check the signer/provider matches the l2Network, throws if not

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise\< void >

Inherited from

AssetBridger.checkL2Network

Source

arbitrum-sdk/src/lib/assetBridger/assetBridger.ts:56


deposit()

deposit(params): Promise< L1ContractCallTransaction >

Execute a token deposit from L1 to L2

Parameters
ParameterTypeDescription
paramsErc20DepositParams | L1ToL2TxReqAndSignerProvider
Returns

Promise\< L1ContractCallTransaction >

Overrides

AssetBridger.deposit

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:604


getApproveTokenRequest()

getApproveTokenRequest(params): Promise< Required< Pick< TransactionRequest, "data" | "value" | "to" > > >

Get a tx request to approve tokens for deposit to the bridge. The tokens will be approved for the relevant gateway.

Parameters
ParameterTypeDescription
paramsProviderTokenApproveParams
Returns

Promise\< Required\< Pick\< TransactionRequest, "data" | "value" | "to" > > >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:236


getDepositRequest()

getDepositRequest(params): Promise< L1ToL2TransactionRequest >

Get the arguments for calling the deposit function

Parameters
ParameterTypeDescription
paramsDepositRequest
Returns

Promise\< L1ToL2TransactionRequest >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:506


getL1ERC20Address()

getL1ERC20Address(erc20L2Address, l2Provider): Promise< string >

Get the corresponding L1 for the provided L2 token Validates the returned address against the l2 router to ensure it is correctly mapped to the provided erc20L2Address

Parameters
ParameterTypeDescription
erc20L2Addressstring
l2ProviderProvider
Returns

Promise\< string >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:434


getL1GatewayAddress()

getL1GatewayAddress(erc20L1Address, l1Provider): Promise< string >

Get the address of the l1 gateway for this token

Parameters
ParameterTypeDescription
erc20L1Addressstring
l1ProviderProvider
Returns

Promise\< string >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:200


getL1TokenContract()

getL1TokenContract(l1Provider, l1TokenAddr): ERC20

Get the L1 token contract at the provided address Note: This function just returns a typed ethers object for the provided address, it doesnt check the underlying form of the contract bytecode to see if it's an erc20, and doesn't ensure the validity of any of the underlying functions on that contract.

Parameters
ParameterTypeDescription
l1ProviderProvider
l1TokenAddrstring
Returns

ERC20

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:401


getL2ERC20Address()

getL2ERC20Address(erc20L1Address, l1Provider): Promise< string >

Get the corresponding L2 for the provided L1 token

Parameters
ParameterTypeDescription
erc20L1Addressstring
l1ProviderProvider
Returns

Promise\< string >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:411


getL2GatewayAddress()

getL2GatewayAddress(erc20L1Address, l2Provider): Promise< string >

Get the address of the l2 gateway for this token

Parameters
ParameterTypeDescription
erc20L1Addressstring
l2ProviderProvider
Returns

Promise\< string >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:218


getL2TokenContract()

getL2TokenContract(l2Provider, l2TokenAddr): L2GatewayToken

Get the L2 token contract at the provided address Note: This function just returns a typed ethers object for the provided address, it doesnt check the underlying form of the contract bytecode to see if it's an erc20, and doesn't ensure the validity of any of the underlying functions on that contract.

Parameters
ParameterTypeDescription
l2ProviderProvider
l2TokenAddrstring
Returns

L2GatewayToken

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:385


getL2WithdrawalEvents()

getL2WithdrawalEvents(
l2Provider,
gatewayAddress,
filter,
l1TokenAddress?,
fromAddress?): Promise< {_amount: BigNumber; _exitNum: BigNumber; _from: string; _l2ToL1Id: BigNumber; _to: string; l1Token: string;} & {txHash: string;}[] >

Get the L2 events created by a withdrawal

Parameters
ParameterTypeDescription
l2ProviderProvider
gatewayAddressstring
filterobject
filter.fromBlockBlockTag-
filter.toBlock?BlockTag-
l1TokenAddress?string
fromAddress?string
Returns

Promise\< {_amount: BigNumber; _exitNum: BigNumber; _from: string; _l2ToL1Id: BigNumber; _to: string; l1Token: string;} & {txHash: string;}[] >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:295


getWithdrawalRequest()

getWithdrawalRequest(params): Promise< L2ToL1TransactionRequest >

Get the arguments for calling the token withdrawal function

Parameters
ParameterTypeDescription
paramsErc20WithdrawParams
Returns

Promise\< L2ToL1TransactionRequest >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:640


isWethGateway()

private isWethGateway(gatewayAddress, l1Provider): Promise< boolean >

Is this a known or unknown WETH gateway

Parameters
ParameterTypeDescription
gatewayAddressstring
l1ProviderProvider
Returns

Promise\< boolean >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:359


l1TokenIsDisabled()

l1TokenIsDisabled(l1TokenAddress, l1Provider): Promise< boolean >

Whether the token has been disabled on the router

Parameters
ParameterTypeDescription
l1TokenAddressstring
l1ProviderProvider
Returns

Promise\< boolean >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:473


looksLikeWethGateway()

private looksLikeWethGateway(potentialWethGatewayAddress, l1Provider): Promise< boolean >

Does the provided address look like a weth gateway

Parameters
ParameterTypeDescription
potentialWethGatewayAddressstring
l1ProviderProvider
Returns

Promise\< boolean >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:329


withdraw()

withdraw(params): Promise< L2ContractTransaction >

Withdraw tokens from L2 to L1

Parameters
ParameterTypeDescription
paramsL2ToL1TxReqAndSigner | OmitTyped\< Erc20WithdrawParams, "from" > & {l2Signer: Signer;}
Returns

Promise\< L2ContractTransaction >

Overrides

AssetBridger.withdraw

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:694


fromProvider()

static fromProvider(l2Provider): Promise< Erc20Bridger >

Instantiates a new Erc20Bridger from an L2 Provider

Parameters
ParameterTypeDescription
l2ProviderProvider
Returns

Promise\< Erc20Bridger >

Source

arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:190