getTimeToProve
Gets time until the L2 withdrawal transaction is ready to be proved. Used for the Withdrawal flow.
Internally calls getTimeToNextL2Output.
Usage
import { account, publicClientL1, publicClientL2 } from './config'
const receipt = await publicClientL2.getTransactionReceipt({
hash: '0x7b5cedccfaf9abe6ce3d07982f57bcb9176313b019ff0fc602a0b70342fe3147'
})
const {
interval,
seconds,
timestamp
} = await publicClientL1.getTimeToProve({
receipt,
targetChain: publicClientL2.chain,
}) Returns
{ interval: number, seconds: number, timestamp: number }
intervalbetween L2 outputs – the max time to wait for transaction to be proved.- Estimated
secondsuntil the transaction can be proved. - Estimated
timestampof when the transaction can be proved.
Parameters
receipt
- Type:
TransactionReceipt
The transaction receipt.
const time = await publicClientL1.getTimeToProve({
receipt,
targetChain: optimism,
}) targetChain
- Type:
Chain
The L2 chain.
const time = await publicClientL1.getTimeToProve({
l2BlockNumber,
targetChain: optimism,
})intervalBuffer (optional)
- Type:
number - Default:
1.1
The buffer to account for discrepencies between non-deterministic time intervals.
const time = await publicClientL1.getTimeToProve({
intervalBuffer: 1.2,
l2BlockNumber,
targetChain: optimism,
}) l2OutputOracleAddress (optional)
- Type:
Address - Default:
targetChain.contracts.l2OutputOracle[chainId].address
The address of the L2 Output Oracle contract. Defaults to the L2 Output Oracle contract specified on the targetChain.
If a l2OutputOracleAddress is provided, the targetChain parameter becomes optional.
const time = await publicClientL1.getTimeToProve({
l2BlockNumber,
l2OutputOracleAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed'
})