0

I am doing an online course and trying to deploy using node. Can anyone help ID what I might be doing wrong. Thank you for any help! The error is below, followed by the js code.

iii@iii:~/Digital Ledger/inbox$ node deploy.js


Attempting to deploy from account 0xd268143B6FBD9BC6533F778052710C962eaAa68C
(node:18067) UnhandledPromiseRejectionWarning: Error: The contract code couldn't be stored, please check your gas limit.
    at Object.TransactionError (/home/iii/Digital Ledger/inbox/node_modules/web3-core-helpers/src/errors.js:93:21)
    at Object.ContractCodeNotStoredError (/home/iii/Digital Ledger/inbox/node_modules/web3-core-helpers/src/errors.js:102:21)
    at /home/iii/Digital Ledger/inbox/node_modules/web3-core-method/src/index.js:394:40
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:18067) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 15)
(node:18067) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.



const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const { interface, bytecode } = require('./compile');

const provider = new HDWalletProvider('olive comic debate nominee various affair order margin fiscal zoo rocket sibling', 'https://rinkeby.infura.io/v3/0cfbe0ad9aa14310a1aab91c683d735c');

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: bytecode, arguments: ['Hi'] })
      .send({ gas: '1000000', from: accounts[0] });

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

};
deploy();
  • What does the constructor do? Which version of solc are you using? – Ismael Jun 17 at 3:43
  • 1. I am not sure. 2. How do I find out which version? – Benzle Jun 17 at 13:44
  • Sorry without more information it is hard to help you. The error is during deployment so it is possible it is in the contract's constructor. Other thing that can be wrong are: gas being too low, using the wrong version of the solc compiler, using the wrong function to compile, using the wrong version of web3js. – Ismael Jun 17 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.