I was just trying to deploy a new contract on the Ethereum MAIN-Net
(not Ropsten
, Rinkeby
or the other test-nets) - and I’m getting this strange error:
Message: sender doesn't have enough funds to send tx.
The upfront cost is: 159840000000000000 and the sender's account
only has: 158236521250000000
The reason I’m finding this strange is cause while I do indeed have only 0.158 ETH
in my account - about $21.60 using today’s rate, which of course isn’t much, those funds should still be plenty enough for simple contract deployments. Especially considering the following:
-I deployed this very same contract - successfully - to:
- My local Development Network (
Ganache
) - where theTotal Cost
came back at0.01332576 ETH
(about $1.80) - The
Rospten Network
- whereTotal Cost
came back at0.01342176 ETH
- about $1.83
While I know there's obviously going to be a difference between the various test-nets and the REAL Ethereum Blockchain, it can’t really be like $2 on one and more than $21 on the other, can it? That’s like 1,050% higher.
Is there some other thing going on here that I'm not aware of?
Would really appreciate any insights into what's causing this.
=================================
UPDATE:
As per @smarx suggestion, I'm adding some code & context:
TOOLS:
-I'm using Truffle
to deploy my contracts.
-Running ganache
locally on my MacBookPro
-Running Truffle Version
returns:
Truffle v5.0.4 (core: 5.0.4)<br/>
Solidity v0.5.0 (solc-js)<br/>
Node v11.10.0<br/>
Here's my deploying code - my truffle.json
file.
require('dotenv').config();
const HDWalletProvider = require('truffle-hdwallet-provider');
module.exports = {
networks: {
mainnet: {
provider: function () {
return new HDWalletProvider(
process.env.PRODUCTION_MNENOMIC,
"https://mainnet.infura.io/vs/${process.env.INFURA_API_KEY}",
15
)
},
from: "0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
network_id: 1,
gas: 7992000,
gasPrice: 20000000000,
confirmations: 2
},
ropsten: {
provider: function () {
return new HDWalletProvider(
process.env.DEV_MNENOMIC,
"https://ropsten.infura.io/${process.env.INFURA_API_KEY}"
)
},
network_id: 3,
gas: 8000000,
gasPrice: 20000000000
},
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*" // Match any network id
},
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
}
}
As mentioned before, this code worked perfectly on both my local Ganache
deployment as well as my remote Ropsten
deployment. I also used this exact same code successfully in the past - as in last week - to deploy contracts to mainnet
, so I know it has worked and is good for at least some deployments - and I thought it'd be for all of them.
Hope this sheds a lot of light. If more info is needed, please let me know specifics.
======================
UPDATE#2 - thought I'd throw in the exact copy of the error truffle
is giving me:
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" could not deploy due to insufficient funds
* Account: 0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Balance: 158236521250000000 wei
* Message: sender doesn't have enough funds to send tx. The upfront cost is: 159840000000000000 and the sender's account only has: 158236521250000000
* Try:
+ Using an adequately funded account
+ If you are using a local Geth node, verify that your node is synced.
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:364:1
at processTicksAndRejections (internal/process/next_tick.js:81:5)
Truffle v5.0.4 (core: 5.0.4)
Node v11.10.0