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
Parameter | Type |
---|---|
childChain | ArbitrumNetwork |
Returns
Inherited from
Source
arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:189
Properties
Property | Type | Description |
---|---|---|
nativeToken ? | string | In case of a chain that uses ETH as its native/gas token, this is either undefined or the zero addressIn 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
Methods
approveGasToken()
approveGasToken(params): Promise< ContractTransaction >
Approves the custom gas token to be spent by the relevant gateway on the parent chain
Parameters
Parameter | Type | Description |
---|---|---|
params | ApproveParamsOrTxRequest |
Returns
Promise
< ContractTransaction
>
Inherited from
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
Parameter | Type | Description |
---|---|---|
params | ApproveParamsOrTxRequest |
Returns
Promise
< ContractTransaction
>
Inherited from
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
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
< void
>
Inherited from
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
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
< void
>
Inherited from
Source
arbitrum-sdk/src/lib/assetBridger/assetBridger.ts:49
deposit()
deposit(params): Promise< ParentContractCallTransaction >
Execute a token deposit from parent to child chain
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20DepositParams | ParentToChildTxReqAndSignerProvider |
Returns
Promise
< ParentContractCallTransaction
>
Inherited from
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
Parameter | Type | Description |
---|---|---|
params | ProviderTokenApproveParams |
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
Parameter | Type | Description |
---|---|---|
params | ProviderTokenApproveParams |
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
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
parentProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
childProvider | Provider | |
l2TokenAddr | string |
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
Parameter | Type | Description |
---|---|---|
params | DepositRequest |
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
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
parentProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
parentProvider | Provider | |
filter | object | - |
filter.fromBlock | BlockTag | - |
filter.toBlock | BlockTag | - |
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
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
childProvider | Provider |
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
Parameter | Type |
---|---|
childProvider | Provider |
filter | object |
filter.fromBlock | BlockTag |
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
Parameter | Type | Description |
---|---|---|
childProvider | Provider | |
gatewayAddress | string | |
filter | object | |
filter.fromBlock | BlockTag | - |
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
Parameter | Type | Description |
---|---|---|
erc20ChildChainAddress | string | |
childProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
parentProvider | Provider | |
parentTokenAddr | string |
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
Parameter | Type | Description |
---|---|---|
params | Erc20WithdrawParams |
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
Parameter | Type | Description |
---|---|---|
parentTokenAddress | string | |
parentProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
parentTokenAddress | string | Address 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. |
childTokenAddress | string | Address 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. |
parentSigner | Signer | The signer with the rights to call registerTokenOnL2 on the parent token |
childProvider | Provider | Arbitrum 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
Parameter | Type | Description |
---|---|---|
parentSigner | Signer | |
childProvider | Provider | |
tokenGateways | TokenAndGateway [] | |
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
Parameter | Type | Description |
---|---|---|
params | ChildToParentTxReqAndSigner | OmitTyped < Erc20WithdrawParams , "from" > & {childSigner : Signer ;} |
Returns
Promise
< ChildContractTransaction
>
Inherited from
Source
arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:836
fromProvider()
static fromProvider(childProvider): Promise< Erc20Bridger >
Instantiates a new Erc20Bridger from a child provider
Parameters
Parameter | Type | Description |
---|---|---|
childProvider | Provider |
Returns
Promise
< Erc20Bridger
>
Inherited from
Source
arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:198
Erc20Bridger
Bridger for moving ERC20 tokens back and forth between parent-to-child
Extends
AssetBridger
<Erc20DepositParams
|ParentToChildTxReqAndSignerProvider
,OmitTyped
<Erc20WithdrawParams
,"from"
> |ChildToParentTransactionRequest
>
Constructors
constructor()
new Erc20Bridger(childChain): Erc20Bridger
Bridger for moving ERC20 tokens back and forth between parent-to-child
Parameters
Parameter | Type |
---|---|
childChain | ArbitrumNetwork |
Returns
Overrides
AssetBridger< Erc20DepositParams | ParentToChildTxReqAndSignerProvider, OmitTyped<Erc20WithdrawParams, 'from'> | ChildToParentTransactionRequest >.constructor
Source
arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:189
Properties
Property | Type | Description |
---|---|---|
nativeToken ? | string | In case of a chain that uses ETH as its native/gas token, this is either undefined or the zero addressIn 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
Methods
approveGasToken()
approveGasToken(params): Promise< ContractTransaction >
Approves the custom gas token to be spent by the relevant gateway on the parent chain
Parameters
Parameter | Type | Description |
---|---|---|
params | ApproveParamsOrTxRequest |
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
Parameter | Type | Description |
---|---|---|
params | ApproveParamsOrTxRequest |
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
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
< void
>
Inherited from
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
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
< void
>
Inherited from
Source
arbitrum-sdk/src/lib/assetBridger/assetBridger.ts:49
deposit()
deposit(params): Promise< ParentContractCallTransaction >
Execute a token deposit from parent to child chain
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20DepositParams | ParentToChildTxReqAndSignerProvider |
Returns
Promise
< ParentContractCallTransaction
>
Overrides
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
Parameter | Type | Description |
---|---|---|
params | ProviderTokenApproveParams |
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
Parameter | Type | Description |
---|---|---|
params | ProviderTokenApproveParams |
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
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
parentProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
childProvider | Provider | |
l2TokenAddr | string |
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
Parameter | Type | Description |
---|---|---|
params | DepositRequest |
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
Parameter | Type | Description |
---|---|---|
depositParams | OmitTyped < 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
Parameter | Type | Description |
---|---|---|
depositParams | OmitTyped < 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
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
parentProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
erc20ParentAddress | string | |
childProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
childProvider | Provider | |
gatewayAddress | string | |
filter | object | |
filter.fromBlock | BlockTag | - |
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
Parameter | Type | Description |
---|---|---|
erc20ChildChainAddress | string | |
childProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
parentProvider | Provider | |
parentTokenAddr | string |
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
Parameter | Type | Description |
---|---|---|
params | Erc20WithdrawParams |
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
Parameter | Type | Description |
---|---|---|
gatewayAddress | string | |
parentProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
potentialWethGatewayAddress | string | |
parentProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
parentTokenAddress | string | |
parentProvider | Provider |
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
Parameter | Type | Description |
---|---|---|
params | ChildToParentTxReqAndSigner | OmitTyped < Erc20WithdrawParams , "from" > & {childSigner : Signer ;} |
Returns
Promise
< ChildContractTransaction
>
Overrides
Source
arbitrum-sdk/src/lib/assetBridger/erc20Bridger.ts:836
fromProvider()
static fromProvider(childProvider): Promise< Erc20Bridger >
Instantiates a new Erc20Bridger from a child provider
Parameters
Parameter | Type | Description |
---|---|---|
childProvider | Provider |
Returns
Promise
< Erc20Bridger
>