Skip to content

Instantly share code, notes, and snippets.

@IllIllI000
Last active June 24, 2023 13:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IllIllI000/2b00a32e8f0559e8f386ea4f1800abc5 to your computer and use it in GitHub Desktop.
Save IllIllI000/2b00a32e8f0559e8f386ea4f1800abc5 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
//pragma solidity 0.4.21; // both cases work on this version
/**
* @title MissingReturnBug
* @author IllIllI
*/
interface IERC20 {
function transfer(address to, uint value) external returns (bool);
}
contract BadERC20 {
function transfer(address, uint) external pure {
return;
}
}
// test case of the missing return bug described here:
// https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
contract Test {
function testIt() external {
BadERC20 bad = new BadERC20();
//BadERC20(address(bad)).transfer(address(this), 0); // works
IERC20(address(bad)).transfer(address(this), 0); // doesn't work - reverts
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment