I think what you are looking for is creating a local fork of mainnet or testnet. I would personally recommend using foundry for this, but other tools are capable of forking too. Foundry ships with a command called anvil that creates a local node. It forks EVM-compatible networks (more here)
- Run anvil and specify an RPC endpoint. It fetches blockchain state over instead of starting from an empty state.
anvil --fork-url https://ethereum.publicnode.com - Copy and use the local RPC endpoint in your script that is presented once Anvil is running. It's usually listening on
127.0.0.1:8545. - Test your script, ensuring it's pointed to the right RPC and uses the correct account.
All changes you make on this endpoint are local to you. You can use the same contract address and accounts if you'd like. However, I do recommend using one of the generated accounts that was presented to you by anvil. This is to avoid scenarios of running the script on the mainnet by mistake. It's just a good practice to have different RPC endpoints and accounts for testing.
contract.function().call().await?;as shown here with the get_reserves() call gakonst.com/ethers-rs/providers/http.html#basic-usage Alternatively you can start up a local hardhat/foundry node with network forking enabled, however static calls would probably be better for your use case.