0

I am trying to deploy a contract to Rinkeby using Node and Truffle but I get a lengthy error:

Truncated Error:

    Attempting to deploy from account 'MYACCOUNT#'
    [object Object]
    [object Object]
    //... error body is too long to fit

    ^
    RuntimeError: abort([object Object]).Build with - s ASSERTIONS = 1
for more info.
at process.abort(/Users/ntg / Desktop / Inbox / node_modules / solc / soljson.js: 1: 13939)
at process.emit(events.js: 314: 20)
at process.emit(/Users/ntg / Desktop / Inbox / node_modules / source - map - support / source - map - support.js: 495: 21)
at processPromiseRejections(internal / process / promises.js: 245: 33)
at processTicksAndRejections(internal / process / task_queues.js: 94: 32)
at runNextTicks(internal / process / task_queues.js: 62: 3)
at listOnTimeout(internal / timers.js: 520: 9)
at processTimers(internal / timers.js: 494: 7)

Package.JSON

{
  "name": "inbox",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@truffle/hdwallet-provider": "^1.2.1",
    "ganache-cli": "^6.12.1",
    "mocha": "^8.2.1",
    "solc": "^0.8.0",
    "web3": "^1.3.1"
  }
}

Deploy.js

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

const provider = new HDWalletProvider(
    'my mnemonic phrase',
    'https://rinkeby.infura.io/v3/myKey'
);

// instantiate with hdwallet
const web3 = new Web3(provider);


const deploy = async () => {

      // get list of all accounts
      const accounts = await web3.eth.getAccounts();

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

      const result = await new web3.eth.Contract(abi)
     .deploy({data: '0x' + bytecode, arguments: ['Hi there!']}) 
     .send({from: accounts[0]}); 

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


deploy();

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: {
            '*': {
                '*': [ '*' ]
            }
        }
    }
};


// parses solidity to English and strings 
var output = JSON.parse(solc.compile(JSON.stringify(input)));

var outputContracts = output.contracts['inbox.sol']['Inbox']

// spits out ABI interface
exports.abi = outputContracts.abi;

// exports bytecode from smart contract
exports.bytecode = outputContracts.evm.bytecode.object;

Contract - inbox.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

contract Inbox {
    string public message;

    constructor (string memory initialMessage) {
        message = initialMessage;
    }

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

}
4
  • It worked as expected on ganache, I'd guess the problem is with rinkeby, so check if the gas price and gas limit are enough to have the transaction mined quickly. – Ismael Jan 4 at 5:14
  • I tried but that didn't solve the problem. I can't even find anything on this runtime error either. – ThomSides Jan 4 at 16:32
  • Can you also show your truffle.config.js file here, or atleast tell its configurations. – Anupam Kumar Apr 5 at 19:15
  • Can you also show you truffle migrations scripts? – Anupam Kumar Apr 5 at 19:16
0

ok, this is not a solution but just adding a bit of information that may help in solving this. Apologies for writing an answer but I can't write comments so this is the only way. The error body that is too long to fit is actually the whole file soljson.js from the solc package in your node-modules. It may be a versioning issue between the packages. Given that the same code runs fine with ganache, it may be that the problem is with truffle hdwallet or infura. It would seem that the soljson file is actually wrapping the error code. Here is a reference to that issue: https://github.com/ethereum/solc-js/issues/493

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.