Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

"Transaction has been reverted by the EVM" deploying contract with version higher than 1.0.0-beta.46 #2560

@iccicci

Description

@iccicci

Description

Even if following the doc, I get the error in subject if I try to use a Web3 version higher than 1.0.0-beta.46

Expected behavior

Simply "42" as output.

Actual behavior

With version "1.0.0-beta.46": simply "42" as output.
With version higher that "1.0.0-beta.46" (beta[47, 50] when I write) following error:

Deploying contract Error: Transaction has been reverted by the EVM:
{
  "transactionHash": "0x529b02d61d0484ab9229eec76583bfa10b712f8fa9158f9683282c008edef315",
  "transactionIndex": 0,
  "blockHash": "0x8ff40212e949b855054da8255ee93eff718360ad030f7230bb4a8be515931512",
  "blockNumber": 12,
  "from": "0x993505074674e20472e6a501ef1219f2df7d6e7e",
  "to": null,
  "gasUsed": 103535,
  "cumulativeGasUsed": 103535,
  "contractAddress": "0x42E96A5Ff0801BC0A45b66344cBCfF8a80Aa2F7A",
  "logs": [],
  "status": true,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "v": "0x1b",
  "r": "0x4e4e887da0d461dcefda452f2953eed8797f5a2f9dcd8d0092bee6b23b466a0f",
  "s": "0x0ceb42646f3bc220bb8a14d6df25fb84e3961940a000e9dd6d0c54a5f74ad00e"
}

Steps to reproduce the behavior

In an empty directory create following two files:

package.json

{
	"name": "report",
	"version": "0.0.0",
	"description": "report",
	"engines": {
		"node": ">=8.0"
	},
	"license": "MIT",
	"dependencies": {
		"web3": "1.0.0-beta.50",
		"ganache-cli": "6.4.1"
	}
}

report.js

"use strict";

const cp = require("child_process");
const fs = require("fs");
const bc = cp.spawn("./node_modules/.bin/ganache-cli");
const Web3 = require("web3");

// read the relevant part of solc output
const input = JSON.parse(fs.readFileSync(0, "utf-8")).contracts["<stdin>:x"];
const abi = JSON.parse(input.abi);

bc.on("error", err => console.log("Launching ganache-cli", err, process.nextTick(process.exit.bind())));
bc.stdout.on("data", data => {
  // ganache-cli is ready to accept commands
  if(data.toString().indexOf("Listening") !== -1) {
    const end = bc.kill.bind(bc);
    const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

    web3.eth.getAccounts((err, accounts) => {
      if(err) return console.log("Getting accounts", err, end());

      const tx = new web3.eth.Contract(abi).deploy({ arguments: [], data: input.bin }).send({ from: accounts[0], gas: 4700000, gasPrice: "30000000000" });

      tx.on("error", err => console.log("Deploying contract", err, end()));
      tx.on("receipt", receipt => {
        const contract = new web3.eth.Contract(abi, receipt.contractAddress);

        contract.methods.g(21).call({}, (err, res) => {
          if(err) return console.log("Calling 'g(21)'", err, end());

          console.log(res.ret);
          end();
        });
      });
    });
  }
});

Then issue following two commands:

$ npm instal
$ echo 'contract x { constructor() public {} function g(uint32 a) public pure returns(uint32 ret) { ret = a + 21; } }' | solc - --combined-json abi,bin | node report.js

Please note the the reason I'm reporting the problem here is that only changing Web3 version to
"1.0.0-beta.46" everything works as expected.

Versions

  • web3.js: 1.0.0-beta.47 (or higher)
  • nodejs: v9.11.2
  • solc: 0.5.5+commit.47a71e8f.Linux.g++
  • ethereum node: "ganache-cli": "6.4.1"

Thank you all,
iCC

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions