erc20Bridger
Classes
AdminErc20Bridger
Admin functionality for the token bridge
Extends
Constructors
new AdminErc20Bridger()
new AdminErc20Bridger(l2Network: L2Network): AdminErc20Bridger
Bridger for moving ERC20 tokens back and forth between L1 to L2
Parameters
Parameter | Type |
---|---|
l2Network | L2Network |
Returns
Inherited from
Source
assetBridger/erc20Bridger.ts:186
Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
l1Network | readonly | L1Network | L2Network | Parent chain for the given Arbitrum chain, can be an L1 or an L2 | Erc20Bridger .l1Network |
nativeToken? | readonly | 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 | Erc20Bridger .nativeToken |
Accessors
nativeTokenIsEth
get protected nativeTokenIsEth(): boolean
Whether the chain uses ETH as its native/gas token
Returns
boolean
Source
assetBridger/assetBridger.ts:75
Methods
approveGasToken()
approveGasToken(params: ApproveParamsOrTxRequest): 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
Erc20Bridger
. approveGasToken
Source
assetBridger/erc20Bridger.ts:255
approveToken()
approveToken(params: ApproveParamsOrTxRequest): 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
assetBridger/erc20Bridger.ts:316
checkL1Network()
protected checkL1Network(sop: SignerOrProvider): Promise<void>
Check the signer/provider matches the l1Network, throws if not
Parameters
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
<void
>
Inherited from
Source
assetBridger/assetBridger.ts:59
checkL2Network()
protected checkL2Network(sop: SignerOrProvider): Promise<void>
Check the signer/provider matches the l2Network, throws if not
Parameters
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
<void
>
Inherited from
Source
assetBridger/assetBridger.ts:67
deposit()
deposit(params: Erc20DepositParams | L1ToL2TxReqAndSignerProvider): Promise<L1ContractCallTransaction>
Execute a token deposit from L1 to L2
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20DepositParams | L1ToL2TxReqAndSignerProvider |
Returns
Promise
<L1ContractCallTransaction
>
Inherited from
Source
assetBridger/erc20Bridger.ts:722
getApproveGasTokenRequest()
getApproveGasTokenRequest(params: ProviderTokenApproveParams): 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
assetBridger/erc20Bridger.ts:239
getApproveTokenRequest()
getApproveTokenRequest(params: ProviderTokenApproveParams): 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
assetBridger/erc20Bridger.ts:283
getDepositRequest()
getDepositRequest(params: DepositRequest): Promise<L1ToL2TransactionRequest>
Get the arguments for calling the deposit function
Parameters
Parameter | Type | Description |
---|---|---|
params | DepositRequest |
Returns
Promise
<L1ToL2TransactionRequest
>
Inherited from
Erc20Bridger
. getDepositRequest
Source
assetBridger/erc20Bridger.ts:616
getL1ERC20Address()
getL1ERC20Address(erc20L2Address: string, l2Provider: Provider): 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
Parameter | Type | Description |
---|---|---|
erc20L2Address | string | |
l2Provider | Provider |
Returns
Promise
<string
>
Inherited from
Erc20Bridger
. getL1ERC20Address
Source
assetBridger/erc20Bridger.ts:486
getL1GatewayAddress()
getL1GatewayAddress(erc20L1Address: string, l1Provider: Provider): Promise<string>
Get the address of the l1 gateway for this token
Parameters
Parameter | Type | Description |
---|---|---|
erc20L1Address | string | |
l1Provider | Provider |
Returns
Promise
<string
>
Inherited from
Erc20Bridger
. getL1GatewayAddress
Source
assetBridger/erc20Bridger.ts:205
getL1GatewaySetEvents()
getL1GatewaySetEvents(l1Provider: Provider, filter: object): Promise<object[]>
Get all the gateway set events on the L1 gateway router
Parameters
Parameter | Type | Description |
---|---|---|
l1Provider | Provider | |
filter | object | - |
filter.fromBlock | BlockTag | - |
filter.toBlock | BlockTag | - |
Returns
Promise
<object
[]>
Source
assetBridger/erc20Bridger.ts:988
getL1TokenContract()
getL1TokenContract(l1Provider: Provider, l1TokenAddr: string): 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 |
---|---|---|
l1Provider | Provider | |
l1TokenAddr | string |
Returns
ERC20
Inherited from
Erc20Bridger
. getL1TokenContract
Source
assetBridger/erc20Bridger.ts:453
getL2ERC20Address()
getL2ERC20Address(erc20L1Address: string, l1Provider: Provider): Promise<string>
Get the corresponding L2 for the provided L1 token
Parameters
Parameter | Type | Description |
---|---|---|
erc20L1Address | string | |
l1Provider | Provider |
Returns
Promise
<string
>
Inherited from
Erc20Bridger
. getL2ERC20Address
Source
assetBridger/erc20Bridger.ts:463
getL2GatewayAddress()
getL2GatewayAddress(erc20L1Address: string, l2Provider: Provider): Promise<string>
Get the address of the l2 gateway for this token
Parameters
Parameter | Type | Description |
---|---|---|
erc20L1Address | string | |
l2Provider | Provider |
Returns
Promise
<string
>
Inherited from
Erc20Bridger
. getL2GatewayAddress
Source
assetBridger/erc20Bridger.ts:223
getL2GatewaySetEvents()
getL2GatewaySetEvents(
l2Provider: Provider,
filter: object,
customNetworkL2GatewayRouter?: string): Promise<object[]>
Get all the gateway set events on the L2 gateway router
Parameters
Parameter | Type |
---|---|
l2Provider | Provider |
filter | object |
filter.fromBlock | BlockTag |
filter.toBlock ? | BlockTag |
customNetworkL2GatewayRouter ? | string |
Returns
Promise
<object
[]>
Source
assetBridger/erc20Bridger.ts:1011
getL2TokenContract()
getL2TokenContract(l2Provider: Provider, l2TokenAddr: string): 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
Parameter | Type | Description |
---|---|---|
l2Provider | Provider | |
l2TokenAddr | string |
Returns
L2GatewayToken
Inherited from
Erc20Bridger
. getL2TokenContract
Source
assetBridger/erc20Bridger.ts:437
getL2WithdrawalEvents()
getL2WithdrawalEvents(
l2Provider: Provider,
gatewayAddress: string,
filter: object,
l1TokenAddress?: string,
fromAddress?: string,
toAddress?: string): Promise<object & object[]>
Get the L2 events created by a withdrawal
Parameters
Parameter | Type | Description |
---|---|---|
l2Provider | Provider | |
gatewayAddress | string | |
filter | object | |
filter.fromBlock | BlockTag | - |
filter.toBlock ? | BlockTag | - |
l1TokenAddress ? | string | |
fromAddress ? | string | |
toAddress ? | string | - |
Returns
Promise
<object
& object
[]>
Inherited from
Erc20Bridger
. getL2WithdrawalEvents
Source
assetBridger/erc20Bridger.ts:342
getWithdrawalRequest()
getWithdrawalRequest(params: Erc20WithdrawParams): Promise<L2ToL1TransactionRequest>
Get the arguments for calling the token withdrawal function
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20WithdrawParams |
Returns
Promise
<L2ToL1TransactionRequest
>
Inherited from
Erc20Bridger
. getWithdrawalRequest
Source
assetBridger/erc20Bridger.ts:758
l1TokenIsDisabled()
l1TokenIsDisabled(l1TokenAddress: string, l1Provider: Provider): Promise<boolean>
Whether the token has been disabled on the router
Parameters
Parameter | Type | Description |
---|---|---|
l1TokenAddress | string | |
l1Provider | Provider |
Returns
Promise
<boolean
>
Inherited from
Erc20Bridger
. l1TokenIsDisabled
Source
assetBridger/erc20Bridger.ts:525
registerCustomToken()
registerCustomToken(
l1TokenAddress: string,
l2TokenAddress: string,
l1Signer: Signer,
l2Provider: Provider): 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
Parameter | Type | Description |
---|---|---|
l1TokenAddress | string | Address 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. |
l2TokenAddress | string | Address 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. |
l1Signer | Signer | The signer with the rights to call registerTokenOnL2 on the l1 token |
l2Provider | Provider | Arbitrum rpc provider |
Returns
Promise
<L1ContractTransaction
<L1TransactionReceipt
>>
Source
assetBridger/erc20Bridger.ts:866
setGateways()
setGateways(
l1Signer: Signer,
l2Provider: Provider,
tokenGateways: TokenAndGateway[],
options?: GasOverrides): Promise<L1ContractCallTransaction>
Register the provided token addresses against the provided gateways
Parameters
Parameter | Type | Description |
---|---|---|
l1Signer | Signer | |
l2Provider | Provider | |
tokenGateways | TokenAndGateway [] | |
options ? | GasOverrides | - |
Returns
Promise
<L1ContractCallTransaction
>
Source
assetBridger/erc20Bridger.ts:1043
withdraw()
withdraw(params: L2ToL1TxReqAndSigner | OmitTyped<Erc20WithdrawParams, "from"> & object): Promise<L2ContractTransaction>
Withdraw tokens from L2 to L1
Parameters
Parameter | Type | Description |
---|---|---|
params | L2ToL1TxReqAndSigner | OmitTyped <Erc20WithdrawParams , "from" > & object |
Returns
Promise
<L2ContractTransaction
>
Inherited from
Source
assetBridger/erc20Bridger.ts:818
fromProvider()
static fromProvider(l2Provider: Provider): Promise<Erc20Bridger>
Instantiates a new Erc20Bridger from an L2 Provider
Parameters
Parameter | Type | Description |
---|---|---|
l2Provider | Provider |
Returns
Promise
<Erc20Bridger
>
Inherited from
Source
assetBridger/erc20Bridger.ts:195
Erc20Bridger
Bridger for moving ERC20 tokens back and forth between L1 to L2
Extends
AssetBridger
<Erc20DepositParams
|L1ToL2TxReqAndSignerProvider
,OmitTyped
<Erc20WithdrawParams
,"from"
> |L2ToL1TransactionRequest
>
Extended by
Constructors
new Erc20Bridger()
new Erc20Bridger(l2Network: L2Network): Erc20Bridger
Bridger for moving ERC20 tokens back and forth between L1 to L2
Parameters
Parameter | Type |
---|---|
l2Network | L2Network |
Returns
Overrides
AssetBridger< Erc20DepositParams | L1ToL2TxReqAndSignerProvider, OmitTyped<Erc20WithdrawParams, 'from'> | L2ToL1TransactionRequest >.constructor
Source
assetBridger/erc20Bridger.ts:186
Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
l1Network | readonly | L1Network | L2Network | Parent chain for the given Arbitrum chain, can be an L1 or an L2 | AssetBridger .l1Network |
nativeToken? | readonly | 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 | AssetBridger .nativeToken |
Accessors
nativeTokenIsEth
get protected nativeTokenIsEth(): boolean
Whether the chain uses ETH as its native/gas token
Returns
boolean
Source
assetBridger/assetBridger.ts:75
Methods
approveGasToken()
approveGasToken(params: ApproveParamsOrTxRequest): 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
assetBridger/erc20Bridger.ts:255
approveToken()
approveToken(params: ApproveParamsOrTxRequest): 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
assetBridger/erc20Bridger.ts:316
checkL1Network()
protected checkL1Network(sop: SignerOrProvider): Promise<void>
Check the signer/provider matches the l1Network, throws if not
Parameters
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
<void
>
Inherited from
Source
assetBridger/assetBridger.ts:59
checkL2Network()
protected checkL2Network(sop: SignerOrProvider): Promise<void>
Check the signer/provider matches the l2Network, throws if not
Parameters
Parameter | Type | Description |
---|---|---|
sop | SignerOrProvider |
Returns
Promise
<void
>
Inherited from
Source
assetBridger/assetBridger.ts:67
deposit()
deposit(params: Erc20DepositParams | L1ToL2TxReqAndSignerProvider): Promise<L1ContractCallTransaction>
Execute a token deposit from L1 to L2
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20DepositParams | L1ToL2TxReqAndSignerProvider |
Returns
Promise
<L1ContractCallTransaction
>
Overrides
Source
assetBridger/erc20Bridger.ts:722
getApproveGasTokenRequest()
getApproveGasTokenRequest(params: ProviderTokenApproveParams): 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
assetBridger/erc20Bridger.ts:239
getApproveTokenRequest()
getApproveTokenRequest(params: ProviderTokenApproveParams): 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
assetBridger/erc20Bridger.ts:283
getDepositRequest()
getDepositRequest(params: DepositRequest): Promise<L1ToL2TransactionRequest>
Get the arguments for calling the deposit function
Parameters
Parameter | Type | Description |
---|---|---|
params | DepositRequest |
Returns
Promise
<L1ToL2TransactionRequest
>
Source
assetBridger/erc20Bridger.ts:616
getDepositRequestCallValue()
private getDepositRequestCallValue(depositParams: OmitTyped<L1ToL2MessageGasParams, "deposit">): BigNumber | BigNumber
Get the call value for the deposit transaction request
Parameters
Parameter | Type | Description |
---|---|---|
depositParams | OmitTyped <L1ToL2MessageGasParams , "deposit" > |
Returns
BigNumber
| BigNumber
Source
assetBridger/erc20Bridger.ts:558
getDepositRequestOutboundTransferInnerData()
private getDepositRequestOutboundTransferInnerData(depositParams: OmitTyped<L1ToL2MessageGasParams, "deposit">): string
Get the data
param for call to outboundTransfer
Parameters
Parameter | Type | Description |
---|---|---|
depositParams | OmitTyped <L1ToL2MessageGasParams , "deposit" > |
Returns
string
Source
assetBridger/erc20Bridger.ts:581
getL1ERC20Address()
getL1ERC20Address(erc20L2Address: string, l2Provider: Provider): 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
Parameter | Type | Description |
---|---|---|
erc20L2Address | string | |
l2Provider | Provider |
Returns
Promise
<string
>
Source
assetBridger/erc20Bridger.ts:486
getL1GatewayAddress()
getL1GatewayAddress(erc20L1Address: string, l1Provider: Provider): Promise<string>
Get the address of the l1 gateway for this token
Parameters
Parameter | Type | Description |
---|---|---|
erc20L1Address | string | |
l1Provider | Provider |
Returns
Promise
<string
>
Source
assetBridger/erc20Bridger.ts:205
getL1TokenContract()
getL1TokenContract(l1Provider: Provider, l1TokenAddr: string): 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 |
---|---|---|
l1Provider | Provider | |
l1TokenAddr | string |
Returns
ERC20
Source
assetBridger/erc20Bridger.ts:453
getL2ERC20Address()
getL2ERC20Address(erc20L1Address: string, l1Provider: Provider): Promise<string>
Get the corresponding L2 for the provided L1 token
Parameters
Parameter | Type | Description |
---|---|---|
erc20L1Address | string | |
l1Provider | Provider |
Returns
Promise
<string
>
Source
assetBridger/erc20Bridger.ts:463
getL2GatewayAddress()
getL2GatewayAddress(erc20L1Address: string, l2Provider: Provider): Promise<string>
Get the address of the l2 gateway for this token
Parameters
Parameter | Type | Description |
---|---|---|
erc20L1Address | string | |
l2Provider | Provider |
Returns
Promise
<string
>
Source
assetBridger/erc20Bridger.ts:223
getL2TokenContract()
getL2TokenContract(l2Provider: Provider, l2TokenAddr: string): 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
Parameter | Type | Description |
---|---|---|
l2Provider | Provider | |
l2TokenAddr | string |
Returns
L2GatewayToken
Source
assetBridger/erc20Bridger.ts:437
getL2WithdrawalEvents()
getL2WithdrawalEvents(
l2Provider: Provider,
gatewayAddress: string,
filter: object,
l1TokenAddress?: string,
fromAddress?: string,
toAddress?: string): Promise<object & object[]>
Get the L2 events created by a withdrawal
Parameters
Parameter | Type | Description |
---|---|---|
l2Provider | Provider | |
gatewayAddress | string | |
filter | object | |
filter.fromBlock | BlockTag | - |
filter.toBlock ? | BlockTag | - |
l1TokenAddress ? | string | |
fromAddress ? | string | |
toAddress ? | string | - |
Returns
Promise
<object
& object
[]>
Source
assetBridger/erc20Bridger.ts:342
getWithdrawalRequest()
getWithdrawalRequest(params: Erc20WithdrawParams): Promise<L2ToL1TransactionRequest>
Get the arguments for calling the token withdrawal function
Parameters
Parameter | Type | Description |
---|---|---|
params | Erc20WithdrawParams |
Returns
Promise
<L2ToL1TransactionRequest
>
Source
assetBridger/erc20Bridger.ts:758
isWethGateway()
private isWethGateway(gatewayAddress: string, l1Provider: Provider): Promise<boolean>
Is this a known or unknown WETH gateway
Parameters
Parameter | Type | Description |
---|---|---|
gatewayAddress | string | |
l1Provider | Provider |
Returns
Promise
<boolean
>
Source
assetBridger/erc20Bridger.ts:411
l1TokenIsDisabled()
l1TokenIsDisabled(l1TokenAddress: string, l1Provider: Provider): Promise<boolean>
Whether the token has been disabled on the router
Parameters
Parameter | Type | Description |
---|---|---|
l1TokenAddress | string | |
l1Provider | Provider |
Returns
Promise
<boolean
>
Source
assetBridger/erc20Bridger.ts:525
looksLikeWethGateway()
private looksLikeWethGateway(potentialWethGatewayAddress: string, l1Provider: Provider): Promise<boolean>
Does the provided address look like a weth gateway
Parameters
Parameter | Type | Description |
---|---|---|
potentialWethGatewayAddress | string | |
l1Provider | Provider |
Returns
Promise
<boolean
>
Source
assetBridger/erc20Bridger.ts:381
withdraw()
withdraw(params: L2ToL1TxReqAndSigner | OmitTyped<Erc20WithdrawParams, "from"> & object): Promise<L2ContractTransaction>
Withdraw tokens from L2 to L1
Parameters
Parameter | Type | Description |
---|---|---|
params | L2ToL1TxReqAndSigner | OmitTyped <Erc20WithdrawParams , "from" > & object |
Returns
Promise
<L2ContractTransaction
>
Overrides
Source
assetBridger/erc20Bridger.ts:818
fromProvider()
static fromProvider(l2Provider: Provider): Promise<Erc20Bridger>
Instantiates a new Erc20Bridger from an L2 Provider
Parameters
Parameter | Type | Description |
---|---|---|
l2Provider | Provider |
Returns
Promise
<Erc20Bridger
>