Hello!
I’m having an issue deploying my ERC-721 smart contract to the mainnet using Truffle.
Everything goes fine, but in the end, I receive this “insufficient funds for gas * price + value” error. Should I mention, that I definitely have enough ETH.
It happened to me twice with different ERC721 smart-contracts. Both contracts were successfully deployed in fact. They are working just fine, I’m only not able to interact with them using truffle console.
Environment
I’m using Truffle v5.1.65 (core: 5.1.65)
OpenZeppelin contracts 3.4.0
I set up the environment according to OZ guides https://docs.openzeppelin.com/learn
Details
Both times I have absolutely the same situation.
Contracts were tested locally using Ganache, then successfully deployed to Rinkeby network and tested there.
However, when deploying to the Mainnet, I’m getting this error.
Contracts work on the mainnet, I can verify them with etherscan and interact with them using web3.js and etherscan Read\Write interface.
But why am I getting this error?
Code to reproduce
Here is my truffle configuration file for the last migration:
const { alchemyApiKeyRinkeby, alchemyApiKeyMain, mnemonic } = require('./secrets.json');
const HDWalletProvider = require('@truffle/hdwallet-provider');
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
gasPrice: 140000000000, // 140 gwei
},
rinkeby: {
provider: () => new HDWalletProvider(
mnemonic, `https://eth-rinkeby.alchemyapi.io/v2/${alchemyApiKeyRinkeby}`
),
network_id: 4,
from: '0x23048031ccBCD47B365b126cF67451151DC8eB82',
gasPrice: 140000000000, //140 gwei
confirmations: 2,
skipDryRun: true
},
mainnet: {
provider: () => new HDWalletProvider(
mnemonic, `https://eth-mainnet.alchemyapi.io/v2/${alchemyApiKeyMain}`
),
network_id: 1,
from: '0x23048031ccBCD47B365b126cF67451151DC8eB82',
gasPrice: 165000000000, //165 gwei
confirmations: 2,
skipDryRun: true
},
},
mocha: {
},
compilers: {
solc: {
version: "0.7.0", // Fetch exact version from solc-bin (default: truffle's version)
}
}
};
deploy.js
const Plushies = artifacts.require("Plushies");
module.exports = async function (deployer) {
// here we pass arguments for constructor
await deployer.deploy(Plushies, "some_address", "https://plushies.io/json/");
};
Here is the deployment log:
npx truffle migrate --network mainnet
Compiling your contracts...
===========================
> Compiling ./contracts/Plushies.sol
> Artifacts written to /Users/user/Local_docs/plushies/build/contracts
> Compiled successfully using:
- solc: 0.7.0+commit.9e61f92b.Emscripten.clang
Starting migrations...
======================
> Network name: 'mainnet'
> Network id: 1
> Block gas limit: 12481654 (0xbe7476)
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
> transaction hash: 0x952afb1a30e3079ed87b438cec548ac84932030a37027cd0b19930028d31c6cf
> Blocks: 1 Seconds: 12
> contract address: 0xe4A7bc71667f36950456B71EC53578A0B79818f9
> block number: 12140756
> block timestamp: 1617109493
> account: 0x23048031ccBCD47B365b126cF67451151DC8eB82
> balance: 1.269153085
> gas used: 186951 (0x2da47)
> gas price: 165 gwei
> value sent: 0 ETH
> total cost: 0.030846915 ETH
Pausing for 2 confirmations...
------------------------------
> confirmation number: 1 (block: 12140757)
> confirmation number: 2 (block: 12140758)
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.030846915 ETH
2_deploy.js
===========
Deploying 'Plushies'
--------------------
> transaction hash: 0x69e6ee817a1f42aa401cf845db9a1af76a8f106b5caf4acf545a09944a71ab79
> Blocks: 7 Seconds: 108
> contract address: 0x2f53f8470527bd4a39Bc204597ca2A16Bb1a7020
> block number: 12140770
> block timestamp: 1617109703
> account: 0x23048031ccBCD47B365b126cF67451151DC8eB82
> balance: 0.42647185
> gas used: 5064824 (0x4d4878)
> gas price: 165 gwei
> value sent: 0 ETH
> total cost: 0.83569596 ETH
Pausing for 2 confirmations...
------------------------------
> confirmation number: 2 (block: 12140772)
⠸ Saving migration to chain.
insufficient funds for gas * price + value
Truffle v5.1.65 (core: 5.1.65)
Thank you very much!