Created
August 6, 2022 10:31
-
-
Save robercano/55516de38ba3a360e1050eea6b9f60c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object "Token" { | |
code { | |
// Store the creator in slot zero. | |
sstore(0, caller()) | |
// Deploy the contract | |
datacopy(0, dataoffset("runtime"), datasize("runtime")) | |
return(0, datasize("runtime")) | |
} | |
object "runtime" { | |
code { | |
// Protection against sending Ether | |
require(iszero(callvalue())) | |
// Dispatcher | |
switch selector() | |
case 0x70a08231 /* "balanceOf(address)" */ { | |
returnUint(balanceOf(decodeAsAddress(0))) | |
} | |
case 0x18160ddd /* "totalSupply()" */ { | |
returnUint(totalSupply()) | |
} | |
case 0xa9059cbb /* "transfer(address,uint256)" */ { | |
transfer(decodeAsAddress(0), decodeAsUint(1)) | |
returnTrue() | |
} | |
case 0x23b872dd /* "transferFrom(address,address,uint256)" */ { | |
transferFrom(decodeAsAddress(0), decodeAsAddress(1), decodeAsUint(2)) | |
returnTrue() | |
} | |
case 0x095ea7b3 /* "approve(address,uint256)" */ { | |
approve(decodeAsAddress(0), decodeAsUint(1)) | |
returnTrue() | |
} | |
case 0xdd62ed3e /* "allowance(address,address)" */ { | |
returnUint(allowance(decodeAsAddress(0), decodeAsAddress(1))) | |
} | |
case 0x40c10f19 /* "mint(address,uint256)" */ { | |
mint(decodeAsAddress(0), decodeAsUint(1)) | |
returnTrue() | |
} | |
default { | |
revert(0, 0) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment