humanwhoexplores / smart-contracts

this repo contains my workbook for practicing smart contracts
0 stars 0 forks source link

Error: insufficient funds for gas * price + value : while deploying the contract #11

Closed humanwhoexplores closed 3 years ago

humanwhoexplores commented 3 years ago

I get the above mentioned error

while deploying my contract I deploy my contract by hitting the command $ node deploy.js

humanwhoexplores commented 3 years ago

Q.) What is the account from which the deployment was made ?

humanwhoexplores commented 3 years ago

Added a line to check the balance of the account

`const deploy = async () => { const accounts = await web3.eth.getAccounts();

console.log("All the accounts we got are ", accounts); console.log("Attempting to deploy from account", accounts[0]);

this is the line

let balance = await web3.eth.getBalance(accounts[0]); console.log("The balance is ", balance);

const result = await new web3.eth.Contract(JSON.parse(interface)) .deploy({ data: bytecode, arguments: ["Hi there!"] }) .send({ gas: "1000000", from: accounts[0] });

console.log("Contract deployed to", result.options.address); };`

BRO : this is not my MetaMask's Acct. : IT should be All the accounts we got are [ '0xB3870FD16fe62235017D440E3539Df784Dd4c36D' ] Attempting to deploy from account 0xB3870FD16fe62235017D440E3539Df784Dd4c36D The balance is 0

humanwhoexplores commented 3 years ago

Next :-

humanwhoexplores commented 3 years ago

Added deploy.js in this commit

https://github.com/humanwhoexplores/smart-contracts/commit/ba86e11888e8add4eeec4d65bf8c6bb0e1c8d41d

humanwhoexplores commented 3 years ago

Bro : Added this code

var mnemonic = "SCRAP DISH BROCCOLI UPDATE LOUNGE AFRAID ARREST KNOW RENEW LEADER SUNSET COPY";
var infura_provider_url = "https://rinkeby.infura.io/v3/7985ca9520d8459b9e3ef03d4ecbe81c";

const provider = new HDWalletProvider( mnemonic, infura_provider_url);

The mnemonic is of my MetaMask Account :- but the account it get is not my account :: Why ??

humanwhoexplores commented 3 years ago

Confirmed two times : the MNEMONIC is CORRECT

humanwhoexplores commented 3 years ago

It works when i am testing it Locally : with Ganache Cli ! Let me take some insights from there.

humanwhoexplores commented 3 years ago

Still Troubleshooting

humanwhoexplores commented 3 years ago

Done : - One LITTLE ISSUE

var mnemonic = 'scrap dish broccoli update lounge afraid arrest know renew leader sunset copy'; I wrote it in :- UPPER CASE it should be in LOWER CASE

humanwhoexplores commented 3 years ago

I got this while carefully auditing https://www.udemy.com/course/ethereum-and-solidity-the-complete-developers-guide/learn/lecture/9020488#overview

Back to Basics :-

humanwhoexplores commented 3 years ago

The commit that solved the issue :- https://github.com/humanwhoexplores/smart-contracts/commit/fed1d1f07fdb9e57493bd9fbf119b050f2f42830