I was trying to fund a campaign created with a funding goal 10000000000000000000 and funding cap 10000000000000000000 by calling the payable method contributeMsgValue with parameter["100000000000000000"] and value 100000000000000000 but I am receiving this error in Remix.

transact to StandardCampaign.contributeMsgValue errored: VM error: revert. revert The transaction has been reverted to the initial state.

contract Campaign is Owned, Campaign {
  enum Stages {
  modifier atStage(Stages _expectedStage) {
    if (stage() != uint256(_expectedStage)) {
    } else {
  modifier validContribution() {
    if (msg.value == 0
      || amountRaised + msg.value > fundingCap
      || amountRaised + msg.value = expiry
      && earlySuccess == false
      && amountRaised = expiry && amountRaised >= fundingGoal)
      || earlySuccess == true
      || amountRaised >= fundingCap) {
      return uint256(Stages.CrowdfundSuccess);
  function contributeMsgValue(uint256[] _amounts)
    returns (uint256 contributionID) {
    contributionID = contributions.length++;
    contributions[contributionID] = Contribution({
        sender: msg.sender,
        value: msg.value,
        created: block.number
    amountRaised += msg.value;
    if (enhancer.notate(msg.sender, msg.value, block.number, _amounts)) {
      earlySuccess = true;
  function StandardCampaign(string _name,
    uint256 _expiry,
    uint256 _fundingGoal,
    uint256 _fundingCap,
    address _beneficiary,
    address _owner,
    address _enhancer) public {
    name = _name;
    expiry = _expiry;
    fundingGoal = _fundingGoal;
    fundingCap = _fundingCap;
    beneficiary = _beneficiary;
    owner = _owner;
    created = block.number;
    enhancer = Enhancer(_enhancer);
  struct Contribution {
    address sender;
    uint256 value;
    uint256 created;
  uint256[] defaultAmounts;
  Enhancer public enhancer;
  bool public earlySuccess;
  address public owner;
  uint256 public fundingGoal;
  uint256 public fundingCap;
  uint256 public amountRaised;
  uint256 public expiry;
  uint256 public created;
  address public beneficiary;
  Contribution[] public contributions;
  mapping(address => uint256[]) public contributionsBySender;
  mapping(uint256 => address) public refundClaimAddress;
  mapping(uint256 => bool) public refundsClaimed;
  string public name;

Am I missing any code here or calling the function in a incorrect way?

2 Answers 2


You can actually debug your transaction in remix and you will figured out why is not working. Somehow the two modifier don't pass and the transaction is reverted.

If you comment this two modifier from the function contributeMsgValue it will work properly.


you just need to check the modifier and fix it.

  • Thanks for your answer. I commented the modifiers and tried executing it. I am able to see that the contribution is successfully done but the contributionID remains 0 and also I am getting this 'VM error: revert' in Remix which is reverting the state because of which contributions become 0.
    – Sumukha
    Commented Mar 23, 2018 at 4:01
  • Solved it! There was an issue with enhancer.notate method.
    – Sumukha
    Commented Mar 23, 2018 at 4:33

In initial state (after deploying) contributions.length = 0. Executing contributionID = contributions.length++; returns the value 0 (set contributionID to 0) and afterwards increases the lenght of the array by 1. That is why the first contribution ID will be 0.

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.