Unable to deploy an ERC 720 token in Mumbai Test says insufficient funds - ethereum

I was trying to deploy an ERC 721 token using truffle in Polygon's mumbai testnet.
And i have 2.8296 Matic in my metasmask wallet which i got from their faucet. But when i try to run
truffle migrate --network matic
it says
Error: *** Deployment Failed ***
"Migrations" could not deploy due to insufficient funds
* Account: 0x12aADAdd301d22c941DACF2cfa7A9e2019972F61
* Balance: 0 wei
* Message: insufficient funds for gas * price + value
* Try:
+ Using an adequately funded account
+ If you are using a local Geth node, verify that your node is synced.
Am i doing something wrong? What sould be the gas and gas price i should mention in truffle config file.
Here is my truffle-config file
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)
},
matic: {
provider: () => new HDWalletProvider(process.env.MNEMONIC, `https://rpc-mumbai.maticvigil.com/v1/91fdbb5c2f37c699621ss7d2b8b127fc1a123060
`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},

enter image description here
I am pretty sure there is no balance of this account 0x12aADAdd301d22c941DACF2cfa7A9e2019972F61 in Mumbai-Testnet

Related

Truffle: Sender doesn't have enough funds to send tx

I'm trying to migrate/test my smart contract on ropsten network using this config:
networks: {
ropsten: {
provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/${infuraKey}`),
network_id: 3, // Ropsten's id
gas: 3000000,
}
},
running truffle migrate --network ropsten
but I keep getting this error:
Error: *** Deployment Failed ***
"Migrations" could not deploy due to insufficient funds
* Account: **address**
* Balance: 0 wei
* Message: sender doesn't have enough funds to send tx. The upfront cost is: 6000000000000000 and the sender's account only has: 0
How do I show truffle I have sufficient funds?
Your Ropsten account needs to have ETH in order to interact with the network.

INFURA: sender account not recognized

I am trying to deploy my contract but it returns this error
truffle migrate --network ropsten --reset
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
Error: Error: Error: *** Deployment Failed ***
"Migrations" -- sender account not recognized.
truffle_config.js
ropsten: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/<PROJECTID>")
},
network_id: "*",
gas: 4000000,
from: "0x4e2f89...."
}
By default, the HDWalletProvider will use the address of the first
address that's generated from the mnemonic. If you pass in a specific
index, it'll use that address instead.
So if you are using address that isn't the first address from this mnemonic you should ether specify the address
HDWalletProvider(mnemonic, "ropsten.infura.io/v3/<PROJECTID>", indexOfYourAddress)
or unlock multiple addresses by putting number to the forth parameter
HDWalletProvider(mnemonic, "ropsten.infura.io/v3/<PROJECTID>",0, numberOfAddresses)

How to fix "Unknown network "ganache". See your Truffle configuration file for available networks."

I'm trying to deploy a contract to rinkeby. I'm using the following command:
$ truffle migrate --networks rinkeby
Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Voting.sol
> Artifacts written to ./public/contracts/build/
> Compiled successfully using:
- solc: 0.5.8+commit.23d335f2.Emscripten.clang
Unknown network "ganache". See your Truffle configuration file for available networks.
Truffle v5.0.22 (core: 5.0.22)
Node v11.6.0
It works witch ganache-cli but it doesn't work with rinkeby, because its giving me the error of Unknown network "ganache". See your Truffle configuration file for available networks as showed in the result above.
This is my truffle-config.js:
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
contracts_build_directory: path.join(__dirname, "./public/contracts/build/"),
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: 1000,
gas: 4612388,
gasPrice: 25000000000,
total_accounts: 20,
mnemonic
},
rinkeby: {
provider: () => new HDWalletProvider(mnemonic, infuraURL),
network_id: 4,
gas: 4612388,
gasPrice: 25000000000,
},
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
}
};
For anyone having this error, my problem was that I was writting wrong the command. The correct form should be:
truffle migrate --network rinkeby # Network is without the 's'

Testing Deployed Smart Contract on Truffle

I'm having trouble testing a contract using truffle. I have the latest version of truffle installed as well a TestRPC.
It's to my understanding that the latest version of truffle comes with a client for testing SmartContracts so TestRPC isn't needed any more.
I have a simple contract my Migrations looks like so:
var Migrations = artifacts.require("./Migrations.sol");
var OrdersFacilitator = artifacts.require("./OrdersFacilitator.sol")
module.exports = function(deployer) {
deployer.deploy(Migrations);
deployer.deploy(OrdersFacilitator);
};
When I run truffle develop I see that 10 test accounts are created.
Accounts:
(0) 0x627306090abab3a6e1400e9345bc60c78a8bef57
(1) 0xf17f52151ebef6c7334fad080c5704d77216b732
//...
My Truffle js is configured like so:
networks: {
development: {
host: "localhost",
port: 9545,
network_id: "*"
}
}
When I run the name of my contracts I can see its deployed with the information:
//...
class_defaults:
{ from: '0x627306090abab3a6e1400e9345bc60c78a8bef57',
gas: 6721975,
gasPrice: 100000000000 },
currentProvider:
HttpProvider {
host: 'http://127.0.0.1:9545/',
timeout: 0,
user: undefined,
password: undefined,
headers: undefined,
send: [Function],
sendAsync: [Function],
_alreadyWrapped: true },
network_id: '4447' }
the Network Id and the port seem to match the configuration fine, and I can see the information when I type the contract name, However when I try to gain access to it though
var facilitator;
OrdersFacilitator.deployed().then(x => facilitator = x);
I Get an Error:
OrdersFacilitator has not been deployed to detected network (network/artifact mismatch)
I've tried deleting the build folder and migrating all with the --reset flag but that doesn't seem to work. How can I Tested my deployed contract
I've seen similar issues withe Truffle projects attempting the same thing. The solution may be to reset the project to a non-cached state.
You can try running truffle compile (and/or truffle migrate) with the --reset flag. This will remove the build dir and recompile everything.
To fix the issue I've explicitly set the network options and network id.
//Start Test RPC with an Explicit Network
testrpc --network-id 1337
Then I've created an explicit network for TestRPC:
networks: {
testrpc:{
host: "localhost",
port: 8545,
network_id: "1337"
}
}
Now when I Migrate Explicitly to my new network:
truffle migrate --network testrpc --reset
truffle console --network testrpc
This seems to map properly to the correct network

Unable to run truffle#2.1.2 migrate --network live. "Exceeds block gas limit"

I am using truffle#2.1.2 to deploy smart contracts against a localhost:8545 geth#1.5.9-stable rpc, using an account that is funded with Ether has been unlocked using personal.unlockAccount on the geth console.
I have also tried the same against a remote Parity node via RPC, but this is the latest which I am rather stuck with.
truffle.js
module.exports = {
build: {
"index.html": "index.html",
"app.js": [
"javascripts/app.js"
],
"app.css": [
"stylesheets/app.css"
],
"images/": "images/"
},
rpc: {
host: "localhost",
port: 8545
},
networks: {
"ropsten": {
network_id: 3,
port: 8548, // ssh tunnelled to AWS geth/parity node localhost:8545
from: "0x4f000Bcf4641E2fDcE85BF26A694b053996850D4"
},
"live": {
network_id: 1,
port: 8545,
from: "0x00269400181f1B379784BD8cDF786bb20e91Bdef",
gas: 4612388,
gasPrice: 2776297000 // taken from Parity startup log message "Updated conversion rate to Ξ1 = US$42.88 (2776297000 wei/gas)"
}
}
};
truffle migrate --network live
Running migration: 1_initial_migration.js
Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Exceeds block gas limit
at Object.module.exports.InvalidResponse (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/errors.js:35:16)
at /home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/requestmanager.js:86:36
at request.onreadystatechange (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:114:13)
at dispatchEvent (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
at setState (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
at IncomingMessage.<anonymous> (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:926:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
I have tried adjusting gas and gasPrice, but am unable to find values that have any affect.
How can I solve this problem, or are there alternative contract deployment methods I should look into?
Kind Regards.
I was able to solve this by simply setting gas: 3000000 in the network config.
"live": {
network_id: 1,
port: 8545,
from: "0x00269400181f1B379784BD8cDF786bb20e91Bdef",
gas: 3000000
}
It cost about 0.5 ETH to run migrations and took several minutes.
In my case the problem was generated by a user's empty balance.
so check your balances using the following function :
function checkAllBalances() {
var totalBal = 0;
for (var acctNum in eth.accounts) {
var acct = eth.accounts[acctNum];
var acctBal = web3.fromWei(eth.getBalance(acct), "ether");
totalBal += parseFloat(acctBal);
console.log(" eth.accounts[" + acctNum + "]: \t" + acct + " \tbalance: " + acctBal + " ether");
}
console.log(" Total balance: " + totalBal + " ether");
};
checkAllBalances();
if the balance is 0 mine some blocks or edit your genesis file.
I solve the same problem by indicate the network id when calling truffle,as:
truffle migrate --network live
and you should modify "from" tag in truffle.js with your unlocked account.
Simple solution: : add gas: 500000 ,(don`t forget to add comma at the last) in truffle.js
module.exports = {
networks: {
development: {
host: "localhost",
port: 8001,
network_id: 1234, // Match any network id
gas: 500000
}
}
};