My OMG Tokens are locked into a smart contract due to modifier - onlyPayloadSize

Line #93 - https://etherscan.io/address/0xd26114cd6EE289AccF82350c8d8487fedB8A0C07#code

I had stored dozens of ERC20 tokens on a smart contract and easily get them all back but Tx fails whenever try to get back OMG tokens so dug out their token contract and found onlyPayloadSize which is not usual in any other ERC20 token contracts.

Following is the piece of code to collect ERC20 tokens on my smart contract:

function CollectERC20(address tokenAddress) onlyAdmin public {
    token tokenFunctions = token(tokenAddress);
    uint256 tokenBal = tokenFunctions.balanceOf(address(this));
    tokenFunctions.transfer(msg.sender, tokenBal);

1 Answer 1


Your issue is likely unrelated to payload size, and related to the fact that your token interface expects transfer() to return a bool. OMG is one of a handful of major token contracts that deviates from the standard, and does not return bool. This causes code compiled with recent versions of solidity to fail when interacting with such a buggy contract.

The byzantium hardfork introduces a new opcode, RETURNDATASIZE, which (as the name implies) stores the return data size for a call. It's mostly targetted towards variable array size returns. However, in your case, it expects a return of a bool, but gets nothing, which then leads to a revert.

Solidity 0.4.22+ default to byzantium compatible code.

I'm afraid there is no way to recover that OMG.

  • This means OMG is not compatible with transfer happening on smart contract? Oct 28, 2018 at 15:02
  • 1
    They are accessible through other smart contracts, but you need a token interface that does not expect transfer to return bool. Essentially, you need two interfaces, one for regular tokens, and one for tokens with this bug Oct 28, 2018 at 20:21
  • This is helpful for anyone coming here to solve an issue related to calling the transfer method on a broken ERC20 contract in your own contracts: web.archive.org/web/20191015055624/https://medium.com/coinmonks/…
    – Joe Edgar
    Oct 15, 2019 at 5:57

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.