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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity 0.8.17; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
contract MyToken is ERC20 { | |
constructor() ERC20("MyToken", "MTK") {} | |
function mint(address to, uint256 amount) public { | |
_mint(to, amount); |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity 0.8.17; | |
/** | |
* Generate UUID strings from `block.difficulty`, i.e., `block.prevrandao` | |
* | |
* UUID follows RFC4122 Version-4 Variant-1 (DCE 1.1, ISO/IEC 11578:1996) | |
* | |
* See more at https://datatracker.ietf.org/doc/html/rfc4122.html | |
*/ |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.17; | |
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; | |
contract C { | |
struct MerkleRoot { | |
bytes32 data; | |
bytes32 signatures; | |
} |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.1; | |
import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
/** | |
* @dev | |
* Purpose: Retrieve an `uint256` random number secured by Chainlink VRF v1 | |
* Usage example: |
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
import hashlib | |
import string | |
##### Helper function ##### | |
ssz_byteorder = "little" # https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md | |
# https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#aliases | |
def isBytesN(input_): | |
# BytesN := Vector[uint8, N] | |
assert isinstance(input_, list) |
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
// Import | |
const Web3 = require("web3"); | |
// Constants | |
const USDC_mainnet = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; | |
const Provider_URL = "wss://eth-mainnet.alchemyapi.io/v2/"; | |
async function eventSubscribe() { | |
const web3 = new Web3(Provider_URL); | |
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
from web3 import Web3 # Use version 5.29.2 | |
from web3.middleware import geth_poa_middleware | |
import json | |
class CONST: | |
def ABI(): | |
with open("./WrappedEther.json") as f: | |
return json.load(f) | |
NodeProvider = lambda : "https://" | |
WrappedEther = lambda : "" |
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
async function method1(payload) { | |
return Buffer.from(payload, 'base64').toString('utf-8'); | |
} | |
async function method2(payload) { | |
const uint8_array = await ethers.utils.base64.decode(payload); | |
const char_array = Array.from(uint8_array).map((element) => { | |
return String.fromCharCode(element) | |
}); |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.13; | |
contract Victim { | |
mapping(address => uint256) public balances; | |
function deposit() public payable { | |
balances[msg.sender] += msg.value; | |
} | |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.13; | |
contract A { | |
uint256 public x; | |
function foo() public payable { | |
x++; | |
} |
NewerOlder