Skip to content

Instantly share code, notes, and snippets.

View a2468834's full-sized avatar
🤗
Search for opportunities

Chuan-Chun Wang a2468834

🤗
Search for opportunities
View GitHub Profile
@a2468834
a2468834 / interact.js
Created March 14, 2022 17:26
Interact with WETH9 contract using Hardhat network + mainnet forking
// Interact with WETH9 contract using Hardhat network + mainnet forking
// #0 = No. 0 of Hardhat Network default accounts
// #1 = A randomly picked address
// Constants
const EXIT_SUCCESS = 0;
const EXIT_FAILURE = 1;
const weth9_address = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
const somebody = "0x2feb1512183545f48f6b9c5b4ebfcaf49cfca6f3";
const contract_ABI = require("./contract-abi.json"); // WETH9's ABI
@a2468834
a2468834 / query.js
Last active March 21, 2022 08:24
Query WETH9 contract using Hardhat mainnet forking between a range of blocks
// Please read mainnet forking tutorial at the LunDAO
// Constants
const EXIT_SUCCESS = 0;
const EXIT_FAILURE = 1;
const weth9_address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
const contract_ABI = require("./contract-abi.json");
const start_block = 14379900; // The starting block number you want
const end_block = 14379910; // The ending block number you want
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;
contract PreSaleMint {
address public immutable _owner;
mapping(address => uint256) public addressMintedBalance; // # of NFTs minted by every address
address[] public whitelistedAddresses; // Dynamic array version of the whitelist
mapping(address => bool) public whitelistedAddressesMap; // Mapping version of the whitelist
modifier onlyOwner() {
@a2468834
a2468834 / SqrtByMagicNumber.cxx
Created March 6, 2022 14:41
Calaulate sqrt(x) using magic number method
#include <iostream>
#include <cmath>
#define SQRT_MAGIC32 0x5F375A86
#define SQRT_MAGIC64 0x5FE6EB50C7B537A9
using namespace std;
float Sqrt32(float x) {
uint32_t i; // The integer interpretation of x
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0; // 限定 compiler version 在某一個區間較好
contract donation {
// Data
struct donorinfo {
address[] donors;
mapping(address=> uint) ledger;
}