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
When i try to send transaction it breaks with the following error:
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:
- Created 6 years ago
- Comments:13 (6 by maintainers)
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 👍
48 Hours to catch this miss understanding i can’t believe it really…
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.