0

i wanted to move token from one account to the other but the transaction is pending, what should i do?

 pragma solidity ^0.4.24;

contract smart{
event TransformToken(
    address _source,
    address _destination,
    uint amount
    );
mapping (address => uint)account;

function showToken(address _address)public view returns(uint){
 uint token=account[_address];
 return (token);

}
function addToken(address _address,uint amount)public{
 account[_address]+=amount;
 }
 function subToken(address _address,uint amount)public{
 account[_address]-=amount;
}

 function transfer(address _address,uint amount)public view returns(uint){
   addToken(_address,amount);
   subToken(msg.sender,amount);
   emit TransformToken(msg.sender,_address,amount);
   return showToken(_address);
   } 
  }

token pendding

  • Well your transfer function is useless here, as it is a view. It will not save anything to contract and won't emit events, so TransformToken event will not be fired, addToken and subToken functions will not increase actual values in contract storage. – Maxpeinas Sep 25 '18 at 13:52
1

you are declaring transfer as a view function, this prevents it from altering state. It should work if you remove the view modifier.

https://solidity.readthedocs.io/en/v0.4.24/contracts.html#view-functions

| improve this answer | |

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.