I create a very simple contract as follows:

pragma solidity >=0.4.24 <0.6.0; 
contract Test {

// There is minimum and maximum bets.
uint constant MIN_BET = 0.01 ether;
uint constant MAX_AMOUNT = 300000 ether;

// 测试1
function getTest(uint modulo) external payable {

    // Validate input data ranges.
    uint amount = msg.value;
    require (modulo > 1 && modulo <= 100, "Modulo should be within range.");
    require (amount >= MIN_BET && amount <= MAX_AMOUNT, "Amount should be within range.");


Then I used truffle compile, truffle migrate, after that, I wrote a test file as followa:

const assert = require('assert');
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));
const json = require('../build/contracts/Test.json');
const utils = require('ethereumjs-util');
let accounts;
let contract;
let manager;
let result;
const interface = json['abi'];
const bytecode = json['bytecode'];
const address = '0x059F708ffFB51719074349A172838285BF1C33BF';
beforeEach(async () => {
accounts = await web3.eth.getAccounts();
manager = accounts[0];
contract = new web3.eth.Contract(interface, address, {from: manager});
describe('Test', () => {
it('get test', async () => {
result = await contract.methods.getTest(100).send({
from: manager,
value: web3.utils.toWei('0.01', 'ether'),
gas: 500000
console.log('### result:');

I ran "mocha test", then got this:

Error: Transaction has been reverted by the EVM: {
"transactionHash":"0x6a21a921326725709e1d1cd549b862e9abc5faf691886d5c6d9081b89a2e9ff2", "transactionIndex": 0,
"blockHash":"0x8ee0d6f54d2ea010d782400fa348e8b253e66a2f4ed54e04f36d992d326c5662", "blockNumber": 6, "from": "0x99aa63cceea343c81ccff19e9366a67a5d3635cc", "to": "0x059f708fffb51719074349a172838285bf1c33bf", "gasUsed": 21772,
"cumulativeGasUsed": 21772, "contractAddress": null, "logs": [], "status": true, "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "v": "0x1b", "r": "0xda47199fde41e787bffb63ef1ab2275362914ccb673aac1333911f4f6f30997e", "s": "0x38faafb77a25155c758d7c3fc998b8c9486c83136ef8dbd445c1be4996041dfc"

1 Answer 1


This is because of the issue with the version of web3 you are using. Try [email protected].
you can find the details here: could not be able to change my setmessage because (Transaction has been reverted by the EVM:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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