1

Below is my solidity function. This function is payable. I am extracting the value from the msg object and transferring.

    function getStudent(string _searchHash) payable public {
      var searchHash = _searchHash;
      university.transfer(msg.value);
      for(uint i=0; i<students.length; i++)
      {
          if (keccak256(students[i].hash) == keccak256(searchHash))
          {
              emit foundStudentInfo(students[i].fname, students[i].year, university.balance);
          }
      }
      emit foundStudentInfo("Failed","Failed",university.balance);
  }
}

Hopping that the account balance of the university variable is increasing every time i call the above function.

Below is my code from JS. This code opens the metamask but i do not see the Amount column. I only can enter the gas value. So not sure if Amout should come in metamask somewhere as it comes while doing the transactions or it will be part of gas value. After transaction, my university account balance remains same it does not change.

function temp (){
     var etherAmount = web3.toBigNumber(0.1);
     var weiValue = web3.toWei(etherAmount,'ether');
     console.log('weiValue ->  '+weiValue);
     Student.getStudent(hashCode,{from:web3.eth.accounts[0],gas:'195253', value:weiValue}, function(error, result){
        if(!error)
        {
            console.log('result in callback  -> ' + result);
        }
        else
        console.error(error);
    });
}

   temp();

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.