mkdir test
cd test
π―
This file contains hidden or 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
# pragma version ^0.3.10 | |
""" | |
@title P256 Signature Verification Function | |
@custom:contract-name P256Verifier | |
@license GNU Affero General Public License v3.0 only | |
@author pcaversaccio | |
@notice The `verify` function can be used to natively (currently | |
only supported on Polygon Mumbai test network) verify a | |
P256 (a.k.a. secp256r1 elliptic curve) signature. For more | |
technical details, please refer to EIP-7212: |
This file contains hidden or 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
-----BEGIN PGP PUBLIC KEY BLOCK----- | |
Comment: Type: 3,072-bit RSA | |
Comment: Fingerprint: 063E966C93AB4356492FE0327C3B4B4B7725111F | |
mQGNBGBUv08BDADTYA0GjLhbKbCezlVAubakXh0jcIbkqZPF1wueSbSgDjlS6+d8 | |
67V6ft4hNXJhpNxqr07LrcbUEDdB7WK8EUA9qsLtVRznR/B8y2HwrFs7jbYAUzl6 | |
lZ6UgzXl2QCeKI3B3foa7aGDeBkm1um3zXlR4+b8d4krO8pZTJepC5T+UF3C81Kb | |
lV+6s+bSsHPtLHwBh+tJtSFF7hQoU1lhVW0hKVGUUwGfoFuYjWh47fLtiEvvtM2e | |
EUZ/0v9nMTKg+tuk4nrR7J+ARdDxaqDWLNTwzGvuTAgkjw6I+zrzFmgsAbdFLFKE |
This file contains hidden or 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
# pragma version ~=0.4.0rc5 | |
""" | |
@title `erc4626_fees` Module Reference Implementation | |
@custom:contract-name erc4626_fees_mock | |
@license GNU Affero General Public License v3.0 only | |
@author pcaversaccio | |
@custom:security I have coded this in ~30mins. It's completely | |
untested code, so please be careful! | |
""" |
This file contains hidden or 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
import hashlib | |
def base58_encode(data: bytes) -> str: | |
alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" | |
value = int.from_bytes(data, "big") | |
result = [] | |
while value: | |
value, remainder = divmod(value, 58) |
This file contains hidden or 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
import base58 | |
import hashlib | |
def eth_to_tron(eth_address): | |
eth_address_bytes = bytes.fromhex( | |
eth_address[2:] if eth_address.startswith("0x") else eth_address | |
) | |
tron_address_bytes = b"\x41" + eth_address_bytes | |
checksum = hashlib.sha256(hashlib.sha256(tron_address_bytes).digest()).digest()[:4] |
This file contains hidden or 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
# pragma version ~=0.4.2 | |
""" | |
@title `CREATE`, `CREATE2`, and `CREATE3` Utility Functions | |
@license GNU Affero General Public License v3.0 only | |
@author pcaversaccio | |
""" | |
PROXY_CHILD_BYTECODE: constant(Bytes[16]) = x"67363d3d37363d34f03d5260086018f3" | |
This file contains hidden or 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
#!/usr/bin/env bash | |
while [[ "$#" -gt 0 ]]; do | |
case $1 in | |
--network) | |
network="$2" | |
shift | |
;; | |
--address) | |
address="$2" |
This file contains hidden or 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
# pragma version ~=0.4.1 | |
""" | |
@title Historical Block Hashes Oracle | |
@custom:contract-name block_hash_oracle | |
@license GNU Affero General Public License v3.0 only | |
@author pcaversaccio | |
@notice The contract function `block_hash` can be used to access the | |
historical block hashes beyond the default 256-block limit. | |
We use the EIP-2935 (https://eips.ethereum.org/EIPS/eip-2935) | |
history contract, which maintains a ring buffer of the last |