Skip to content

Instantly share code, notes, and snippets.

View nhancv's full-sized avatar
🏠
Working from home

Nhan Cao nhancv

🏠
Working from home
View GitHub Profile

setup adb

Add platform-tools to your path

echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile

Refresh your bash profile (or restart your terminal app)

source ~/.bash_profile
@nhancv
nhancv / Multicall.sol
Created August 11, 2023 00:39
Multicall v2, v3
pragma solidity =0.5.0;
pragma experimental ABIEncoderV2;
/// @title Multicall - Aggregate results from multiple read-only function calls
/// @author Michael Elliot <[email protected]>
/// @author Joshua Levine <[email protected]>
/// @author Nick Johnson <[email protected]>
contract Multicall {
struct Call {
@nhancv
nhancv / USDToken.sol
Last active August 3, 2023 05:11
ERC20 implementation, USDT, BUSD
pragma solidity 0.5.16;
/**
* @dev Interface of the ERC20 standard.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
@nhancv
nhancv / WETH.sol
Last active August 2, 2023 08:13
WETH
// SPDX-License-Identifier: GNU GENERAL PUBLIC LICENSE V3
pragma solidity 0.5.16;
contract WETH {
string public name = "Wrapped Ether";
string public symbol = "WETH";
uint8 public decimals = 18;
event Approval(address indexed src, address indexed guy, uint256 wad);
event Transfer(address indexed src, address indexed dst, uint256 wad);
@nhancv
nhancv / export_nftids.js
Created July 26, 2023 03:36
Export NFT ids of owner to text file
const fs = require('fs');
const fetchNFTIDs = async () => {
const NFT_ADDRESS='';
const OWNER_ADDRESS='';
const ETHERSCAN_APIKEY='';
const res = await fetch(`https://api.etherscan.io/api?module=account&action=addresstokennftinventory&address=${OWNER_ADDRESS}&contractaddress=${NFT_ADDRESS}&page=1&offset=1000&apikey=${ETHERSCAN_APIKEY}`);
if (res.ok) {
const data = await res.json();
const file = `nfts-${OWNER_ADDRESS}-${Date.now()}.txt`;
@nhancv
nhancv / install_docker_script.sh
Created June 25, 2023 03:11
Install docker ubuntu
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker $(whoami)
@nhancv
nhancv / ERC20.ABI.json
Created June 14, 2023 02:16
Ethereum Solidity Standard ABI
[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"
@nhancv
nhancv / snapshot_graphql.js
Created November 24, 2022 10:01
Example query data of snapshot.org
/**
DIR=snapshotdev
mkdir $DIR
cd $DIR
touch index.js
npm init -y
npm i isomorphic-unfetch
npm i @urql/core
# Docs: https://docs.snapshot.org/snapshot.js
@nhancv
nhancv / IERC20Full.sol
Created November 19, 2022 04:17
Interface of the ERC20 standard as defined in the EIP.
// SPDX-License-Identifier: MIT
pragma solidity 0.4.25;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Full {
/**
* @dev Returns the name of the token.
*/
@nhancv
nhancv / web3-metamask.html
Created November 14, 2022 01:19
Example web3 - Metamask
<!-- Localhost start: http-server -->
<html>
<link
rel="icon"
type="image/x-icon"
href="https://www.mozilla.org/media/img/favicons/firefox/browser/favicon.f093404c0135.ico"
/>
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script>