requestExecute
Requests execution of a L2 transaction from L1.
Usage
import { account, walletClient, zksyncClient } from './config'
const hash = await walletClient.requestExecute({
account,
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n
})
Account Hoisting
If you do not wish to pass an account
to every requestExecute
, you can also hoist the Account on the Wallet Client (see config.ts
).
import { walletClient, zksyncClient } from './config'
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n
})
Returns
The Transaction hash.
Parameters
client
- Type:
Client
The L2 client for fetching data from L2 chain.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n
})
contractAddress
- Type:
Address
The L2 contract to be called.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n
})
calldata
- Type:
Hex
The input of the L2 transaction.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n
})
l2Value (optional)
- Type:
bigint
The msg.value
of L2 transaction.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n
})
l2GasLimit (optional)
- Type:
bigint
Maximum amount of L2 gas that transaction can consume during execution on L2.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n
})
mintValue (optional)
- Type:
bigint
The amount of base token that needs to be minted on non-ETH-based L2.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n,
mintValue: 100_000n
})
factoryDeps (optional)
- Type:
Hex[]
An array of L2 bytecodes that will be marked as known on L2.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n,
factoryDeps: ['0x...']
})
operatorTip (optional)
- Type:
bigint
The tip the operator will receive on top of the base cost of the transaction. Currently, ZKsync node do not consider this tip.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n,
operatorTip: 100_000n
})
gasPerPubdataByte (optional)
- Type:
bigint
The L2 gas price for each published L1 calldata byte.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n,
gasPerPubdataByte: 250_000_000_000n
})
refundRecipient (optional)
- Type:
Address
- Default:
walletClient.account
The address on L2 that will receive the refund for the transaction.
If the transaction fails, it will also be the address to receive l2Value
.
const hash = await walletClient.requestExecute({
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n,
refundRecipient: '0x...'
})
chain (optional)
- Type:
Chain
- Default:
walletClient.chain
The target chain. If there is a mismatch between the wallet's current chain & the target chain, an error will be thrown.
import { zksync } from 'viem/chains'
const hash = await walletClient.requestExecute({
chain: zksync,
client: zksyncClient,
contractAddress: await zksyncClient.getBridgehubContractAddress(),
calldata: '0x',
l2Value: 7_000_000_000n,
l2GasLimit: 900_000n
})