Environment
@openzeppelin/cli: 2.8.0
@openzeppelin/contracts-ethereum-package: 2.5.0
@openzeppelin/upgrades: 2.8.0
Details
I’m using the OpenZeppelin Proxy Upgradeability pattern faciliated through the OpenZeppelin CLI.
Everything is working well - my one question is wondering if it’s possible to revert()
a transaction when the underlying “logic” contract (the one the developer writes when using this pattern) doesn’t have a function matching the transaction encoded data.
Example: My contract has a payable
function signature of buyStamp()
. However, Bob calls buyStamp(5)
on my contract - and sends 5 ETH. The signature buyStamp(uint256)
doesn’t exist so the proxy forwards it to my contract, and nothing happens - Bob doesn’t buy a stamp. However:
- To Bob it originally appears the transaction was successful (it didn’t fail).
- Bob just gave away 5 ETH for nothing in return.
I’m wondering if it’s possible the transaction fails instead of the current behavior.
I think generally the best practice is something like below, where you’d check the msg.data.length
is empty (ie. they weren’t trying to call a function). I believe this would be added to the “logic” contract (not OpenZeppelin’s Proxy contract).
function() payable { require(msg.data.length == 0); }
However, I’m not sure if that will mess with the OpenZeppelin proxy pattern functionality.
Thanks for any help!