2

I'm developing a simple smart contract in Solidity and running it on the Goerli testnet. Prior to the merge, I was able to use Rinkeby and it had negligible gas fees. With Goerli, a simple tx seems to take 2 - 4 GoerliETH in gas, and any faucets I find online only give me around 0.2 GoerliETH at a time.

I'm using MetaMask as a wallet, so it's automatically calculating gas fees. It doesn't allow me to set them too low, so I never have enough GoerliETH for a simple tx, so it's basically impossible to develop unless I use a local VM.

enter image description here

How can I get unblocked from development but still use an Ethereum testnet? Thanks in advance!

2
  • 3
    There are other testnet like sepolia, use a test client like ganache, use your own private test network. There's also some L2 chain with a test network like mumbai.
    – Ismael
    Nov 22, 2022 at 7:01
  • I use Alchemy and Hardhat combination for testing and deployment with a connected metamask wallet address and was able to make several deployments and method calls with just 1 GoerliETH in my wallet the whole time. Hardhat provides ways to optimize your code in its configuration settings and also gives you good gas estimate information while testing so you can optimize your contract and used storage.
    – Udo E.
    Feb 23, 2023 at 23:35

3 Answers 3

2

I think you should use Foundry and fork the testnet (or event mainnet of your choice).

See: https://book.getfoundry.sh/

It's super easy and makes testing one hundred time faster. The code looks something like this to fork a chain:

 function testWrappedMaticAddress() public {
        //Created a local fork of the polygon mainnet in one line, at the 32821975 block
        vm.createSelectFork(vm.envString("ETH_RPC_URL"), 32821975);
        
        //The address of the wMatic contract, that has a lot of wmatic 
        address wMaticOwner = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270;

        //The next calls will be made by this wMaticOwner's address
        vm.startPrank()

That way, I can fork the chain, find an address with lots of assets I want to make my test on (in this case wmatic), and I can start a prank to pretend to be this address and do my test with thousand of tokens.

Hope this helps you develop and test!

1
  • Need to pass the address in startPrank(wMaticOwner)
    – Saad Suri
    Sep 17, 2023 at 16:24
1

As of October 2022, Ethernaut is now working on the following L1, L2 and sidechain testnets 🚀 Goerli Sepolia Mumbai - Polygon Goerli - Arbitrum Goerli - Optimism

As of March 2023, I recommend using Sepolia instead of Goerli. Goerli has huge gas fees right now.

0

Change your gas fee setting when the gas fee approval pops up I just had it trying to charge me 0.2 to 0.4 and change the settings on the gwei to lower values and got it down to 0.003 So try that and I hope it help's

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.