Why is deploying to Mainnet using Truffle so difficult?
Here is a rundown of trying to deploy to Mainnet...
- Current Gasprice is 110 Wei. Therefore
110000000000 wei
Let's plug that in..
mainnet: {
provider: () =>
new HDWalletProvider({
mnemonic: { phrase: process.env.MNEMONIC },
providerOrUrl: process.env.RPC_URL_1_WSS,
}),
network_id: 1,
from: process.env.DEPLOYERS_ADDRESS,
gasPrice: 110000000000, /* GAS PRICE!! */
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: false, public nets )
},
},
- Let's get the gas cost estimate of deploying. This will be set in
gas
parameter oftruffle-config
.
NODE_ENV=production truffle migrate --network mainnet --dry-run
Summary
=======
> Total deployments: 2
> Final cost: 0.001403824 ETH
0.001403824 ETH is $2.04.
So that's probably wrong.
‼️FAIL‼️
- Second try. Ok the dry run wasn't useful for getting gas estimates. I'll leave
gas
blank and try to deploy with justgasPrice
.
Results in..
Message: insufficient funds for gas * price + value
‼️FAIL‼️
- Ok, I'm since the
dry-run
didn't give a useful estimate for what the contract costs to deploy, I'll just guess based on other contracts. Going to add thegas
parameter here.
mainnet: {
provider: () =>
new HDWalletProvider({
mnemonic: { phrase: process.env.MNEMONIC },
providerOrUrl: process.env.RPC_URL_1_WSS,
}),
network_id: 1,
from: process.env.DEPLOYERS_ADDRESS,
gasPrice: 110000000000, /* GAS PRICE!! */
gas: 140000000000000000, / That's about $200 in Wei/
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: false, public nets )
},
},
RuntimeError: abort(Error: Assertion failed). Build with -s ASSERTIONS=1 for more info.
.
‼️FAIL AGAIN‼️
- Third attempt. Ok, going to try to just leave
gas
andgasPrice
blank..
Block timesout in 750 seconds
.
‼️FAIL‼️
Trying on Remix..
- Set provider to Injected Web3
- Set network to Mainnet
- Deploy
- Cost $135
This is great, but now I'm not using Truffle's migrations, and it isn't as easy to use Remix ABI with Truffle.
I'm really really prefer Truffle to just work.
Why is Truffle sooooo difficult to use when deploying to Mainnet? It is impossible to deploy to Mainnet.