Skip to main content

Module: assetBridger/erc20Bridger

AdminErc20Bridger

Admin functionality for the token bridge

Extends

Constructors

constructor()

new AdminErc20Bridger(childChain): AdminErc20Bridger

Bridger for moving ERC20 tokens back and forth between parent-to-child

Parameters
ParameterType
childChainArbitrumNetwork
Returns

AdminErc20Bridger

Inherited from

Erc20Bridger.constructor

Source

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

Properties

PropertyTypeDescription
nativeToken?stringIn case of a chain that uses ETH as its native/gas token, this is either undefined or the zero address

In case of a chain that uses an ERC-20 token from the parent chain as its native/gas token, this is the address of said token on the parent chain

Accessors

nativeTokenIsEth

protected get nativeTokenIsEth(): boolean
Source

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

Inherited from

Erc20Bridger.nativeTokenIsEth

Methods

approveGasToken()

approveGasToken(params): Promise< ContractTransaction >

Approves the custom gas token to be spent by the relevant gateway on the parent chain

Parameters
ParameterTypeDescription
paramsApproveParamsOrTxRequest
Returns

Promise< ContractTransaction >

Inherited from

Erc20Bridger.approveGasToken

Source

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


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:321


checkChildChain()

protected checkChildChain(sop): Promise< void >

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

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise< void >

Inherited from

Erc20Bridger.checkChildChain

Source

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


checkParentChain()

protected checkParentChain(sop): Promise< void >

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

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise< void >

Inherited from

Erc20Bridger.checkParentChain

Source

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


deposit()

deposit(params): Promise< ParentContractCallTransaction >

Execute a token deposit from parent to child chain

Parameters
ParameterTypeDescription
paramsErc20DepositParams | ParentToChildTxReqAndSignerProvider
Returns

Promise< ParentContractCallTransaction >

Inherited from

Erc20Bridger.deposit

Source

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


getApproveGasTokenRequest()

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

Creates a transaction request for approving the custom gas token to be spent by the relevant gateway on the parent chain

Parameters
ParameterTypeDescription
paramsProviderTokenApproveParams
Returns

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

Inherited from

Erc20Bridger.getApproveGasTokenRequest

Source

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


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:288


getChildERC20Address()

getChildERC20Address(erc20ParentAddress, parentProvider): Promise< string >

Get the corresponding child chain token address for the provided parent chain token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
parentProviderProvider
Returns

Promise< string >

Inherited from

Erc20Bridger.getChildERC20Address

Source

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


getChildTokenContract()

getChildTokenContract(childProvider, l2TokenAddr): L2GatewayToken

Get the child chain 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
childProviderProvider
l2TokenAddrstring
Returns

L2GatewayToken

Inherited from

Erc20Bridger.getChildTokenContract

Source

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


getDepositRequest()

getDepositRequest(params): Promise< ParentToChildTransactionRequest >

Get the arguments for calling the deposit function

Parameters
ParameterTypeDescription
paramsDepositRequest
Returns

Promise< ParentToChildTransactionRequest >

Inherited from

Erc20Bridger.getDepositRequest

Source

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


getL1GatewayAddress()

getL1GatewayAddress(erc20ParentAddress, parentProvider): Promise< string >

Get the address of the l1 gateway for this token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
parentProviderProvider
Returns

Promise< string >

Inherited from

Erc20Bridger.getL1GatewayAddress

Source

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


getL1GatewaySetEvents()

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

Get all the gateway set events on the L1 gateway router

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

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

Source

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


getL2GatewayAddress()

getL2GatewayAddress(erc20ParentAddress, childProvider): Promise< string >

Get the address of the l2 gateway for this token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
childProviderProvider
Returns

Promise< string >

Inherited from

Erc20Bridger.getL2GatewayAddress

Source

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


getL2GatewaySetEvents()

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

Get all the gateway set events on the L2 gateway router

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

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

Source

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


getL2WithdrawalEvents()

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

Get the child chain events created by a withdrawal

Parameters
ParameterTypeDescription
childProviderProvider
gatewayAddressstring
filterobject
filter.fromBlockBlockTag-
filter.toBlock?BlockTag-
parentTokenAddress?string
fromAddress?string
toAddress?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:349


getParentERC20Address()

getParentERC20Address(erc20ChildChainAddress, childProvider): Promise< string >

Get the corresponding parent chain address for the provided child chain token Validates the returned address against the child chain router to ensure it is correctly mapped to the provided erc20ChildChainAddress

Parameters
ParameterTypeDescription
erc20ChildChainAddressstring
childProviderProvider
Returns

Promise< string >

Inherited from

Erc20Bridger.getParentERC20Address

Source

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


getParentTokenContract()

getParentTokenContract(parentProvider, parentTokenAddr): 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
parentProviderProvider
parentTokenAddrstring
Returns

ERC20

Inherited from

Erc20Bridger.getParentTokenContract

Source

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


getWithdrawalRequest()

getWithdrawalRequest(params): Promise< ChildToParentTransactionRequest >

Get the arguments for calling the token withdrawal function

Parameters
ParameterTypeDescription
paramsErc20WithdrawParams
Returns

Promise< ChildToParentTransactionRequest >

Inherited from

Erc20Bridger.getWithdrawalRequest

Source

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


parentTokenIsDisabled()

parentTokenIsDisabled(parentTokenAddress, parentProvider): Promise< boolean >

Whether the token has been disabled on the router

Parameters
ParameterTypeDescription
parentTokenAddressstring
parentProviderProvider
Returns

Promise< boolean >

Inherited from

Erc20Bridger.parentTokenIsDisabled

Source

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


registerCustomToken()

registerCustomToken(
parentTokenAddress,
childTokenAddress,
parentSigner,
childProvider): Promise< ParentContractTransaction< ParentTransactionReceipt > >

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
parentTokenAddressstringAddress of the already deployed parent token. Must inherit from https://developer.offchainlabs.com/docs/sol_contract_docs/md_docs/arb-bridge-peripherals/tokenbridge/ethereum/icustomtoken.
childTokenAddressstringAddress of the already deployed child token. Must inherit from https://developer.offchainlabs.com/docs/sol_contract_docs/md_docs/arb-bridge-peripherals/tokenbridge/arbitrum/iarbtoken.
parentSignerSignerThe signer with the rights to call registerTokenOnL2 on the parent token
childProviderProviderArbitrum rpc provider
Returns

Promise< ParentContractTransaction< ParentTransactionReceipt > >

Source

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


setGateways()

setGateways(
parentSigner,
childProvider,
tokenGateways,
options?): Promise< ParentContractCallTransaction >

Register the provided token addresses against the provided gateways

Parameters
ParameterTypeDescription
parentSignerSigner
childProviderProvider
tokenGatewaysTokenAndGateway[]
options?GasOverrides-
Returns

Promise< ParentContractCallTransaction >

Source

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


withdraw()

withdraw(params): Promise< ChildContractTransaction >

Withdraw tokens from child to parent chain

Parameters
ParameterTypeDescription
paramsChildToParentTxReqAndSigner | OmitTyped< Erc20WithdrawParams, "from" > & {childSigner: Signer;}
Returns

Promise< ChildContractTransaction >

Inherited from

Erc20Bridger.withdraw

Source

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


fromProvider()

static fromProvider(childProvider): Promise< Erc20Bridger >

Instantiates a new Erc20Bridger from a child provider

Parameters
ParameterTypeDescription
childProviderProvider
Returns

Promise< Erc20Bridger >

Inherited from

Erc20Bridger.fromProvider

Source

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


Erc20Bridger

Bridger for moving ERC20 tokens back and forth between parent-to-child

Extends

Constructors

constructor()

new Erc20Bridger(childChain): Erc20Bridger

Bridger for moving ERC20 tokens back and forth between parent-to-child

Parameters
ParameterType
childChainArbitrumNetwork
Returns

Erc20Bridger

Overrides

AssetBridger< Erc20DepositParams | ParentToChildTxReqAndSignerProvider, OmitTyped<Erc20WithdrawParams, 'from'> | ChildToParentTransactionRequest >.constructor

Source

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

Properties

PropertyTypeDescription
nativeToken?stringIn case of a chain that uses ETH as its native/gas token, this is either undefined or the zero address

In case of a chain that uses an ERC-20 token from the parent chain as its native/gas token, this is the address of said token on the parent chain

Accessors

nativeTokenIsEth

protected get nativeTokenIsEth(): boolean
Source

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

Inherited from

AssetBridger.nativeTokenIsEth

Methods

approveGasToken()

approveGasToken(params): Promise< ContractTransaction >

Approves the custom gas token to be spent by the relevant gateway on the parent chain

Parameters
ParameterTypeDescription
paramsApproveParamsOrTxRequest
Returns

Promise< ContractTransaction >

Source

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


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:321


checkChildChain()

protected checkChildChain(sop): Promise< void >

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

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise< void >

Inherited from

AssetBridger.checkChildChain

Source

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


checkParentChain()

protected checkParentChain(sop): Promise< void >

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

Parameters
ParameterTypeDescription
sopSignerOrProvider
Returns

Promise< void >

Inherited from

AssetBridger.checkParentChain

Source

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


deposit()

deposit(params): Promise< ParentContractCallTransaction >

Execute a token deposit from parent to child chain

Parameters
ParameterTypeDescription
paramsErc20DepositParams | ParentToChildTxReqAndSignerProvider
Returns

Promise< ParentContractCallTransaction >

Overrides

AssetBridger.deposit

Source

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


getApproveGasTokenRequest()

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

Creates a transaction request for approving the custom gas token to be spent by the relevant gateway on the parent chain

Parameters
ParameterTypeDescription
paramsProviderTokenApproveParams
Returns

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

Source

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


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:288


getChildERC20Address()

getChildERC20Address(erc20ParentAddress, parentProvider): Promise< string >

Get the corresponding child chain token address for the provided parent chain token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
parentProviderProvider
Returns

Promise< string >

Source

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


getChildTokenContract()

getChildTokenContract(childProvider, l2TokenAddr): L2GatewayToken

Get the child chain 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
childProviderProvider
l2TokenAddrstring
Returns

L2GatewayToken

Source

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


getDepositRequest()

getDepositRequest(params): Promise< ParentToChildTransactionRequest >

Get the arguments for calling the deposit function

Parameters
ParameterTypeDescription
paramsDepositRequest
Returns

Promise< ParentToChildTransactionRequest >

Source

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


getDepositRequestCallValue()

private getDepositRequestCallValue(depositParams): BigNumber | BigNumber

Get the call value for the deposit transaction request

Parameters
ParameterTypeDescription
depositParamsOmitTyped< ParentToChildMessageGasParams, "deposit" >
Returns

BigNumber | BigNumber

Source

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


getDepositRequestOutboundTransferInnerData()

private getDepositRequestOutboundTransferInnerData(depositParams): string

Get the data param for call to outboundTransfer

Parameters
ParameterTypeDescription
depositParamsOmitTyped< ParentToChildMessageGasParams, "deposit" >
Returns

string

Source

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


getL1GatewayAddress()

getL1GatewayAddress(erc20ParentAddress, parentProvider): Promise< string >

Get the address of the l1 gateway for this token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
parentProviderProvider
Returns

Promise< string >

Source

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


getL2GatewayAddress()

getL2GatewayAddress(erc20ParentAddress, childProvider): Promise< string >

Get the address of the l2 gateway for this token

Parameters
ParameterTypeDescription
erc20ParentAddressstring
childProviderProvider
Returns

Promise< string >

Source

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


getL2WithdrawalEvents()

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

Get the child chain events created by a withdrawal

Parameters
ParameterTypeDescription
childProviderProvider
gatewayAddressstring
filterobject
filter.fromBlockBlockTag-
filter.toBlock?BlockTag-
parentTokenAddress?string
fromAddress?string
toAddress?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:349


getParentERC20Address()

getParentERC20Address(erc20ChildChainAddress, childProvider): Promise< string >

Get the corresponding parent chain address for the provided child chain token Validates the returned address against the child chain router to ensure it is correctly mapped to the provided erc20ChildChainAddress

Parameters
ParameterTypeDescription
erc20ChildChainAddressstring
childProviderProvider
Returns

Promise< string >

Source

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


getParentTokenContract()

getParentTokenContract(parentProvider, parentTokenAddr): 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
parentProviderProvider
parentTokenAddrstring
Returns

ERC20

Source

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


getWithdrawalRequest()

getWithdrawalRequest(params): Promise< ChildToParentTransactionRequest >

Get the arguments for calling the token withdrawal function

Parameters
ParameterTypeDescription
paramsErc20WithdrawParams
Returns

Promise< ChildToParentTransactionRequest >

Source

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


isWethGateway()

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

Is this a known or unknown WETH gateway

Parameters
ParameterTypeDescription
gatewayAddressstring
parentProviderProvider
Returns

Promise< boolean >

Source

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


looksLikeWethGateway()

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

Does the provided address look like a weth gateway

Parameters
ParameterTypeDescription
potentialWethGatewayAddressstring
parentProviderProvider
Returns

Promise< boolean >

Source

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


parentTokenIsDisabled()

parentTokenIsDisabled(parentTokenAddress, parentProvider): Promise< boolean >

Whether the token has been disabled on the router

Parameters
ParameterTypeDescription
parentTokenAddressstring
parentProviderProvider
Returns

Promise< boolean >

Source

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


withdraw()

withdraw(params): Promise< ChildContractTransaction >

Withdraw tokens from child to parent chain

Parameters
ParameterTypeDescription
paramsChildToParentTxReqAndSigner | OmitTyped< Erc20WithdrawParams, "from" > & {childSigner: Signer;}
Returns

Promise< ChildContractTransaction >

Overrides

AssetBridger.withdraw

Source

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


fromProvider()

static fromProvider(childProvider): Promise< Erc20Bridger >

Instantiates a new Erc20Bridger from a child provider

Parameters
ParameterTypeDescription
childProviderProvider
Returns

Promise< Erc20Bridger >

Source

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