-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Description
the code:
` const maxBaseFeeInFutureBlock = FlashbotsBundleProvider.getMaxBaseFeeInFutureBlock(block.baseFeePerGas, BLOCKS_IN_THE_FUTURE)
//定义一个eip1559交易
const eip1559Transaction = {
to: '0xC1c4301C5bd4eBe2C04817aC815AaceB4DeDA8DB',
type: 2,
maxFeePerGas: PRIORITY_FEE.add(maxBaseFeeInFutureBlock),
maxPriorityFeePerGas: PRIORITY_FEE,
gasLimit: 100000,
data: '0x',
chainId: 5,
value: ethers.utils.parseEther("0.1105"),
nonce:mNonce
}
//签名绑定包
const signedTransactions = await flashbotsProvider.signBundle([
{
signer: wallet,
transaction: eip1559Transaction
}
])
//模拟
const targetBlockNumber = block.number + BLOCKS_IN_THE_FUTURE
const simulation = await flashbotsProvider.simulate(signedTransactions, targetBlockNumber)
// Using TypeScript discrimination
if ('error' in simulation) {
console.warn(`Simulation Error: ${simulation.error.message}`)
process.exit(1)
} else {
console.log(`Simulation Success: ${JSON.stringify(simulation, null, 2)}`)
}
`
Metadata
Metadata
Assignees
Labels
No labels