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
71561683 |
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 { ethers } from 'ethers'; | |
async function getTokenInfo(tokenAddress: string, walletAddress: string) { | |
const provider = ethers.getDefaultProvider('homestead'); | |
// Create a contract instance for the USDC token using the ERC-20 ABI | |
const usdcToken = new ethers.Contract( | |
tokenAddress, | |
[ | |
'function name() view returns (string)', |
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 { ethers } from 'ethers'; | |
(async () => { | |
const address = '0x67147840C8eca35C819C7523861E6A1D75D93200'; | |
try { | |
// get transaction count | |
const mainnetTransactionCount = await ethers.getDefaultProvider('mainnet').getTransactionCount(address); | |
const goerliTransactionCount = await ethers.getDefaultProvider('goerli').getTransactionCount(address); | |
const sepoliaTransactionCount = await ethers.getDefaultProvider('sepolia').getTransactionCount(address); |
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
1. Write a script to interact with an Ethereum account on mainnet , return its balance and transaction count. | |
import { ethers } from 'ethers'; | |
async function getBalanceAndTransactionCount(address: string) { | |
try { | |
// Create a default provider for mainnet | |
const provider = ethers.getDefaultProvider('mainnet'); | |
// Get the balance of the Ethereum address |
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
#! /bin/bash | |
# ECHO COMMAND | |
# echo Hello World! | |
# VARIABLES | |
# Uppercase by convention | |
# Letters, numbers, underscores | |
NAME="Bob" | |
# echo "My name is $NAME" |
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
//flat an array | |
function flat(arr, depth) { | |
if (depth > 0) { | |
return arr.reduce( | |
(acc, val) => acc.concat(Array.isArray(val) ? flat(val, depth - 1) : val), | |
[] | |
) | |
} else { | |
return arr.slice() | |
} |