question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VM Exception while processing transaction: revert

See original GitHub issue
  • I’ve asked for help in the Truffle Gitter before filing this issue.

Issue

When i try to sendTransaction from address to my Contract i get the following error:

VM Exception while processing transaction: revert

Steps to Reproduce from test issue repository

1.Clone this repository http://gitlab.youvolio.com/kristiyan.tachev/truffle-contracts-issue 2.npm i 3.npm run migrate 4(optional). tsc . 5. Or skip 4 and execute directly npm start it will start index.js which is compiled from index.ts 6. It should show error like in the title

Steps to Reproduce from scratch

1.npm init

2.truffle init

3.truffle compile

4.truffle migrate

5.Import json file generated from builds

pragma solidity ^0.4.13;

import 'zeppelin-solidity/contracts/token/MintableToken.sol';

contract Coin is MintableToken {
  string public name = "COIN";
  string public symbol = "CTP";
  uint8 public decimals = 18;
}

CONTRACT 
pragma solidity ^0.4.13;

import './Coin.sol';
import 'zeppelin-solidity/contracts/crowdsale/Crowdsale.sol';


contract CoinCrowdsale is Crowdsale {

  function CoinCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) 
    Crowdsale(_startTime, _endTime, _rate, _wallet) {          
  }

  // creates the token to be sold.
  // override this method to have crowdsale of a specific MintableToken token.
  function createTokenContract() internal returns (MintableToken) {
    return new Coin();
  }
}


import * as CoinCrowdsale from './contracts/CoinCrowdsale';
import * as truffleContract from 'truffle-contract';
import * as Web3 from 'web3';
import { HttpProvider, Personal, Provider, Providers, Account, Eth, Utils} from 'web3/types';

const web3: Web3 = new Web3();
const provider: HttpProvider = new web3.providers.HttpProvider("http://localhost:8545");

let ContractCrowdsaleInstance;
const TruffleContractCrowdsaleInstance = truffleContract(CoinCrowdsale);
TruffleContractCrowdsaleInstance.setProvider(provider);

TruffleContractCrowdsaleInstance.deployed()
.then(async instance => {
     ContractCrowdsaleInstance = instance;
     const transaction = {
           from: "0xf17f52151EbEF6C7334FAD080c5704D77216b732",
           value: web3.utils.toWei(5, "ether")
     }
     const tx = await instance.sendTransaction(transaction);
     console.log(tx);
})

The address generated above is automatically provided by Genache Elektron App screenshot from 2018-01-14 20-03-10

screenshot from 2018-01-15 01-27-01

When i try to send transaction it breaks with the following error:

screenshot from 2018-01-14 16-09-33

Expected Behavior

When sending transaction from contract to an address there should be no error message and amount of tokens should be transferred to address purchased and ether needs to be transferred to contract owner balance. Previews week it was working fine and transaction was passing now contract is deployed and again i cannot send transaction to my contract…

Environment

  • Operating System: Linux
  • Truffle version: 4.0.4
  • Ethereum client: Web3
  • node version: 7.9.0 / 8.9.4
  • npm version: 5.6.0
  • genache web app version: 1.0.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

54reactions
Stradivariocommented, Jan 17, 2018

Guys this is INSANE!!!

I just put as a last chance try! PARAMETER GAS to sendTransaction Oh my god and it is fucking working!!! I am soo soo happy !!

Anyway if someone have the same problem try to put gas as a parameter with appropriate amount 👍

this.rawTruffleInstance.sendTransaction({from: address, value: web3.utils.toWei(amount, “ether”), gas: “220000”})

48 Hours to catch this miss understanding i can’t believe it really…

10reactions
benjamincburnscommented, Jan 17, 2018

You might also be wondering “why did it revert instead of fail with ‘Out of gas?’” The best I can tell is that before running some operations the solidity runtime checks whether or not you’ve allowed enough gas for that operation to succeed and reverts if not. This saves you the cost of the transaction failure, but makes debugging the problem a little difficult.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: VM Exception while processing transaction: revert.
This error happens when a function call jumps out of bounds (e.g array out of bounds). This is done to punish the caller...
Read more >
Lesson 8 - Error: VM Exception while processing transaction ...
Lesson 8 - Error: VM Exception while processing transaction: reverted with reason string 'You need to spend more ETH!'
Read more >
Truffle Error- VM Exception while processing transaction: revert
And I am trying to buy token on my client side application.So there is transaction failed.And this error comes VM Exception while processing ......
Read more >
VM Exception while processing transaction: revert
☑ This error means your transaction failed. ☑ It's very generic, so don't expect to find a copy-paste solution on google. ☑ Let's...
Read more >
Chainlink Returned error: VM Exception while processing ...
It's due to the contract you are trying to call not being available on the VM you are using. You'll need to switch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found