Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 114 characters in body
Source Link
const HDWalletProvider=require('truffle-hdwallet-provider');

const Web3=require('web3');

const{interface,bytecode}=require('./compile');

const provider=new HDWalletProvider(
    'rotate private anger humor social predict title//i pearput numbermy firmaccount mercyprase reopen','https://sepolia.infura.io/v3/9d4945325d2c4515a117aaafa6b5af54'here
);

const web3 =new Web3(provider);

const deploy= async()=>{

    const accounts=await web3.eth.getAccounts(); 

    console.log('Attempting to deploy from account',accounts[0]);

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

    console.log('Contract deployed to',result.options.address);

};
deploy();
const HDWalletProvider=require('truffle-hdwallet-provider');

const Web3=require('web3');

const{interface,bytecode}=require('./compile');

const provider=new HDWalletProvider(
    'rotate private anger humor social predict title pear number firm mercy reopen','https://sepolia.infura.io/v3/9d4945325d2c4515a117aaafa6b5af54'
);

const web3 =new Web3(provider);

const deploy= async()=>{

    const accounts=await web3.eth.getAccounts(); 

    console.log('Attempting to deploy from account',accounts[0]);

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

    console.log('Contract deployed to',result.options.address);

};
deploy();
const HDWalletProvider=require('truffle-hdwallet-provider');

const Web3=require('web3');

const{interface,bytecode}=require('./compile');

const provider=new HDWalletProvider(
    //i put my account prase here
);

const web3 =new Web3(provider);

const deploy= async()=>{

    const accounts=await web3.eth.getAccounts(); 

    console.log('Attempting to deploy from account',accounts[0]);

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

    console.log('Contract deployed to',result.options.address);

};
deploy();
Source Link

cant deploy my contract and getting same error

I am new to solidity . I am trying to learn solidity following a course . I trying to deploy my contract . I am getting same error again and again . I have tried some solution with same title I found here . It seems not work .

The error says :

Error: insufficient funds for gas * price + value

I am stuck with this error for so long .

My sepolia test network balance is 0.0022 ,do I have to get more ?

here is deploy.js file

const HDWalletProvider=require('truffle-hdwallet-provider');

const Web3=require('web3');

const{interface,bytecode}=require('./compile');

const provider=new HDWalletProvider(
    'rotate private anger humor social predict title pear number firm mercy reopen','https://sepolia.infura.io/v3/9d4945325d2c4515a117aaafa6b5af54'
);

const web3 =new Web3(provider);

const deploy= async()=>{

    const accounts=await web3.eth.getAccounts(); 

    console.log('Attempting to deploy from account',accounts[0]);

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

    console.log('Contract deployed to',result.options.address);

};
deploy();

my main contract :

pragma solidity >=0.4.26;

contract Inbox {
    string public message;

    constructor(string memory intialmsg) public{
        message = intialmsg;
    }

    function setmessage(string memory newMessage) public {
        message = newMessage;
    }
}

My compile.js file

const path= require('path');
const fs= require('fs');

const solc=require('solc');



const inboxPath=path.resolve(__dirname,'contracts','Inbox.sol');

const source = fs.readFileSync(inboxPath,'utf-8');

module.exports = solc.compile(source,1).contracts[':Inbox'];
console.log( solc.compile(source,1).contracts[':Inbox']);

My package.js file

{
  "name": "inbox",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ganache-cli": "^6.12.2",
    "mocha": "^10.2.0",
    "openzeppelin-solidity": "^4.6.0",
    "solc": "^0.4.26",
    "truffle-hdwallet-provider": "^1.0.17",
    "web3": "^1.0.0-beta.26"
  }
}

Thanks a lot .Dont want to give up on my journey .