parameters should i pass for v,r,s? Any help is appreciated!
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
Also can this be exploited so random user approves the tokens for another user to spend and then transfer them to his account via the transferFrom() function?
Its the signature you are going to pass
(v,r,s) are ECDSA components (digital signature)
Can this be exploited so users gets approval for spend on random addresses and withdraw each others tokens via transferFrom() function, because they will now have the allowances reuqired?
Without the user signing the permit data using his wallet, no
There are many attack vectors one can use to trick victims. However, the function alone is safe
can they use the 0x0 address as owner so they 'mint' them tokens from the -x- address?
So what i understand from this so far is - anyone can request for approval to spend someone's tokens but they cannot access them until the requested party 'approve' their request. Am i getting this right?
Think of it as like a real life permit. User A writes the following into a paper "User B is granting access to User A for taking X amount from User B's wallet" This has no validity until User B signs the paper right? That's exactly how erc20permit works too.
Thanks, thats good clarification! So this cannot be abused as 'mint' fom 0x0 address and withdrawing ones tokens without interaction from the requested side, yes?
Yep just like normal approve-transferFrom pattern, you can't take it without the requested party's consent (sign)
Обсуждают сегодня