I am trying to understand Proof of Stake based on this implementation: https://github.com/PoSToken/PoSToken/blob/master/contracts/PoSToken.sol

However, I am confused about a few sections and was hoping someone could clarify them:

Line 184: require(_to != address(0));

Why does this require exist? What problem is it preventing?

Lines 183 and 167 use `onlyPayloadSize` 2 ** 32 and 3 ** 32

I understand that onlyPayloadSize fixes an ERC20 short address attack however I don't understand why the two are different. Hopefully someone can explain why?

1 Answer 1


address(0) is equivalent to 'null' - this is in line 184 to prevent you transferring tokens to nowhere. Without this line it would be possible to effectively remove tokens from circulation by accident.

the onlyPayloadSize modifier input is different for the two functions as they take different arguments - see line 167:

function transfer(address _to, uint256 _value)

for function calls, see here:

to interface with contracts that do not adhere to the ABI, the function call is provided which takes an arbitrary number of arguments of any type. These arguments are padded to 32 bytes and concatenated.

line 167 takes one address and one uint256 as inputs, both of which are padded to 32 bytes for a call hence size = 2 ** 32

whereas on line 183 there are three inputs, hence size = 3 ** 32:

function transferFrom(address _from, address _to, uint256 _value)

in both cases the onlyPayloadSize modifier is ensuring the payload is of adequate length to take these 2 or 3 inputs respectively; although please note this method of protection against short address attacks isn't bulletproof.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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