I’m new with ethereum.
I’m definitely struggling with the last 4 parameter of this function, so I’m asking the problem directly.
mapping(address => uint256) nonces;
/*
* Proxy transfer token. When some users of the ethereum account has no ether,
* he or she can authorize the agent for broadcast transactions, and agents may charge agency fees
* @param _from
* @param _to
* @param _value
* @param fee
* @param _v
* @param _r
* @param _s
*/
function transferProxy(address _from, address _to, uint256 _value, uint256 _fee,
uint8 _v,bytes32 _r, bytes32 _s) public transferAllowed(_from) returns (bool){
if(balances[_from] < _fee + _value) revert();
uint256 nonce = nonces[_from];
bytes32 h = keccak256(_from,_to,_value,_fee,nonce);
if(_from != ecrecover(h,_v,_r,_s)) revert(); // THE PROBLEM I’m STUCK ON SEVERAL HOURS IS HERE.
if(balances[_to] + _value < balances[_to]
|| balances[msg.sender] + _fee < balances[msg.sender]) revert();
balances[_to] += _value;
Transfer(_from, _to, _value);
balances[msg.sender] += _fee;
Transfer(_from, msg.sender, _fee);
balances[_from] -= _value + _fee;
nonces[_from] = nonce + 1;
return true;
}
- First, keccak256 takes normally only one argument (the data to hash). I have no idea what using multiple parameters does. Adding the data ? If yes how ? Hashing the hashs ? all at once or rehashing after each results ?
- Second thing, I think that in order to get
_v
I need to use web3.eth.sign withweb3.eth.sign("0x395BE1C1Eb316f82781462C4C028893e51d8b2a5",keccak256("data"))
. But if it‘s not the case, I don’t know what I need to use - Third, no idea about
_r
is about. - Four, I think to understand
_s
is about an HTtp callback (by reading documentation). But it seems that I cannot just left it to 0 since I don’t know what to callback. - AND THE HArdest thing. How to determine exactly the nonce parameters in keccak256 ? (even If I have no idea on how to call it), because I’m having a hard time at understanding what
mapping(address => uint256) nonces;
anduint256 nonce = nonces[_from];
really do. And obviously I need to know the value in order to set_v
_r
_s