1

How can i call second function so that it could return key_Number and key name ?

function TransferKey (address receiver, string _name, uint Key_Number) 
    public  {
    name = _name;
    assert (Keys[msg.sender] != 0);
    if(Keys[msg.sender] <= Key_Number)  return;
    //This function is anytime a node wanner send keys
    //It checks if the keys of the sender is less than the Key_Number
    //This code reduces the number of keys in possession of the the sender by one
    Keys[msg.sender] -= Key_Number;
    //This code also increases the address by the number sent  
    Keys[receiver] += Key_Number; 
    emit sent( msg.sender, receiver,Key_Number);

AND this is function that should return the uint and the string value of the transfer key

    function NumberOfKeysInPossession(address account) public view returns ( uint, string ) {
         //This function return Key_Number of a given account.
         return Keys[account] , keys[_name];
         //It checks the number of keys owned by a particular account.
    }
  • 1
    What is your question? – Raghav Sood Aug 1 '18 at 11:57
  • How can i call second function so that it could return key_Number and key name ? – Seth Livingston Aug 1 '18 at 12:00
0

You will have to provide _name as a parameter in NumberOfKeysInPossession() . I suppose you intended to use _name from transferKey()(just an assumption without any knowledge of the rest of your smart contract's logic) but there it's out of scope, of course. And by the way, the mapping Keysalready exists, how can/ should there be another keys in lowercase ? Anyway, it's expecting a parameter which your function doesn't provide.

Try going with something like

function NumberOfKeysInPossession(address account someType _someParam) public view returns ( uint, string ) {
     //This function return Key_Number of a given account.
     return Keys[account] , someMapping[_someParamBeingOfExpectedType];
     //It checks the number of keys owned by a particular account.
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.