Sending Ether Cheat Sheet
TLDR
Address.sendValue(addr, amount)
(bool success, ) = addr.call{value: amount}("")
// Reverse bytes received in calldata (abcd -> dcba) | |
// https://twitter.com/huff_language/status/1583894073487654913 | |
// code length 206 | |
/// @author Philippe Dumonet <philippe@dumo.net> -- https://twitter.com/real_philogy/status/1584304102418223104 | |
/// @author karma (@0xkarmacoma) -- https://twitter.com/0xkarmacoma/status/1584239664310779904 | |
/// @author kaden.eth (@0xKaden) -- https://twitter.com/0xKaden/status/1584280521089376256/ | |
#define macro reverse_word() = takes(1) returns(1) { | |
// [x0] | |
0x00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff |
// compiles to the following bin-runtime: 7f2a447b3991925d0aa0728f5e78315948d6cb14530bc6ae127f114971abe35db87f452f5b4ef4b2336fc516af2a17113e27f69f612162a8c9321c7e2401c78629dd18600052596000f3 | |
// (run with e.g. `evm --code <bin-runtime> run | cast --to-ascii`) | |
#define macro MAIN() = takes(0) returns(0) { | |
0x2a447b3991925d0aa0728f5e78315948d6cb14530bc6ae127f114971abe35db8 // ciphertext | |
0x452f5b4ef4b2336fc516af2a17113e27f69f612162a8c9321c7e2401c78629dd // key (which happens to be the keccak hash of the message) | |
xor | |
0x00 mstore | |
// returns 0x6F6B207765206E65656420746F20676F20547572696E6720636F6D706C657465 |
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.17; | |
import {Test} from "forge-std/Test.sol"; | |
import {stdJson} from "forge-std/StdJson.sol"; | |
import {console2} from "forge-std/console2.sol"; | |
contract TestJson is Test { | |
/// @dev fields need to be sorted alphabetically (see docs of vm.parseJson()) | |
struct ContractURISchema { |
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.15; | |
import {console2} from "forge-std/console2.sol"; | |
contract FizzBuzz { | |
modifier fizz(uint256 n) { | |
_; | |
if (n % 3 == 0 && n % 5 != 0) { | |
console2.log("Fizz"); |
# quine.etk | |
# ⬜ => ⬜ | |
# A quine is a computer program which takes no input and produces a copy of its own source code as its only output. | |
# 0x80...f3 is the compiled code excluding the push16 instruction (from dup1 to return) | |
push16 0x8060801b17606f5953600152602136f3 | |
# --- stack --- | |
dup1 # code code | |
push1 128 # 128 code code |
import os | |
import random | |
import time | |
from multiprocessing import Pool, Event | |
def init_pool_processes(the_shutdown_event): | |
''' | |
Initialize each process with the global shutdown event |
// SPDX-License-Identifier: MIT | |
pragma solidity >=0.8.0; | |
contract AdversarialRoyalties { | |
bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; | |
function supportsInterface(bytes4 interfaceID) external pure returns (bool) { | |
return interfaceID == _INTERFACE_ID_ERC2981; | |
} |
// SPDX-License-Identifier: Unlicense | |
pragma solidity >=0.8.0; | |
contract CheckBeforeStore { | |
event Log(address); | |
bytes32 stored; | |
function setUp() public { | |
stored = keccak256(abi.encode(address(this))); |
Address.sendValue(addr, amount)
(bool success, ) = addr.call{value: amount}("")
[ | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "account", | |
"type": "address" | |
}, |