I tested the contract using Remix Javascript VM, Injected Web3(Ropsten) and in-built Ganache client from Embark Framework(4.0). Always getting infinite gas usage. Can someone please help me? This is my contract code:

pragma solidity 0.5.0;

contract SimpleStorage {
    uint prize = 100;
    function() external payable {}

   function prizeDistribution() public payable {
  • It is working fine on mine, are you sending some ethers using fallback function before executing prizeDistribution ? Because if not, then your contract doesn't have enough Wei to transfer. Also the difference of prize and price is bugging me. – sp4c3 Feb 18 '19 at 12:36
  • @sp4c3 Its working in Remix after calling fallback before prizeDistribution. But its still throwing errors in Truffle as well as Embark. Truffle:truffle(ganache)>instance.prizeDistribution.call() Error: Returned error: VM Exception while processing transaction: revert – shscs911 Feb 19 '19 at 3:57
  • Here instance.prizeDistribution.call() should cause an error. You are trying to transfer 100 Wei from contract balance to another account. But your contract doesn't have 100 Wei as balance. – Iftifar Taz Feb 19 '19 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.