I'm a beginner in blockchain and facing a huge problem while deploying my smart contract with Truffle.
first my simple contract...
pragma solidity ^0.8.10;
contract Inbox{
string public message;
constructor(string memory initialMessage){
message = initialMessage;
}
function setMessage(string memory newMessage) public {
message = newMessage;
}
}
then my deploy.js script, I'm using Rinkeby testnetwork/web3/truffle-hd-wallet.
const HDWalletProvider = require('@truffle/hdwallet-provider');
const Web3 = require('web3');
const { interface, bytecode } = require('./compile');
const provider = new HDWalletProvider(
'My mnemonic',
'https://rinkeby.infura.io/v3/MY-INFURA-PROJECT-ID'
);
const web3 = new Web3(provider);
const deploy = async () => {
const accounts = await web3.eth.getAccounts();
console.log('Attempting to deploy from account ', accounts[0] ); //working till here fine
const result = await new web3.eth.Contract(interface)
.deploy({data: '0x' + bytecode, arguments: ['Hi there!']})
.send({gas: '5000000000', from: accounts[0]});
console.log('contract deployed to', result.options.address);
};
deploy();
I'm deploying like this but getting errors in number form and those numbers are flowing without stopping. Please help me. The error is given below in picture form because I'm unable to describe it in words.
the error.
{ code: -32000, message: 'insufficient funds for gas * price + value' }
My compile.js
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');
var input = {
language: 'Solidity',
sources: {
'inbox.sol' : {
content: source
}
},
settings: {
outputSelection: {
'*': {
'*': [ '*' ]
}
}
}
};
const output = JSON.parse(solc.compile(JSON.stringify(input)));
const interface = output.contracts['inbox.sol'].Inbox.abi;
const bytecode =
output.contracts['inbox.sol'].Inbox.evm.bytecode.object;
module.exports = {
interface,
bytecode
};
gas: "5000000"
.