2

How do I keep the fork mainnet use the latest block using web3? I need to fork mainnet to latest block before I send the transaction What originally i do is just run the ganache fork command which only have the state the block the time i ran it and use

// at some conditions
const localWeb3 = new Web3( // connect to forked net
    new Web3.providers.WebsocketProvider('ws://localhost:8546') // port of forked mainnet ganache
)
// do the transaction

What I tried

// at some conditions
const localWeb3 = new Web3( // connect to forked net
    ganache.provider( {fork: "myalchemyprovider"} ) 
// do the transaction

or with
    ganache.provider( {fork: web3.currentProvider} ) // no good since i dont have archive mode of eth node 

what is the correct way to do this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.