0

i have contract which looks like following

pragma solidity ^0.4.8;

contract Rental {
    struct PaidRent {
        uint id;
        uint value;
    }
    PaidRent[] public paidrents;
    event RentPaid(bool Status);
    function payRent() public payable returns(bool status) {

        if(owner.send(msg.value)) {
          RentPaid(true);
          return true;
        } else {
          RentPaid(false);
          return false;
        }

    }
}

i am calling this function from my service using web3 in following way

paymyRent(contractInstance, rent) {
    console.log('in paymyrent');
    let eventlistenenr = contractInstance.RentPaid();
    eventlistenenr.watch(function (error, result) {
      if (!error) {
        console.log(result.args);
      } else {
        console.log(error);
      }
    });


    contractInstance.payRent({from: this.web3.eth.accounts[0],
      gas:4665270, value: this.web3.toWei(rent, "ether")});
}

but upon sybmitting my transaction from metamask transaction is being failed. here is the screenshot of a transaction detail enter image description here

any help is really appreciated :)

5
  • could you paste here the tx hash? And, are you sure it's the correct contract deployed? I tested it and it works fine. Commented Apr 18, 2018 at 19:33
  • @EliDrion here is the TxHash :0x730c634b581fcdad81ba53829a6611e9b598383572e78ff4332f15a6645afdca Commented Apr 18, 2018 at 20:19
  • yes. it is the correct contract deployed. when i call other functions of contract it is returning expected result Commented Apr 18, 2018 at 20:20
  • Hard to know. It works well. Commented Apr 18, 2018 at 20:39
  • thanks man. i deployed a new contract and it is working fine now. don't know what was wrong with previous contract. Commented Apr 18, 2018 at 20:55

0

Your Answer

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