Created
February 22, 2023 17:18
-
-
Save riordant/96fe4202264352cb3c6aaeb84e8f40e4 to your computer and use it in GitHub Desktop.
Set Balance of the 3 major stables (DAI, USDT, USDC) on Arbitrum forked node, via Anvil/HH setStorageAt.
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 setBalance(account: string, token: string, slot: number){ | |
const paddedSlot = ethers.utils.hexZeroPad(ethers.utils.hexlify(slot), 32); | |
const paddedKey = ethers.utils.hexZeroPad(account, 32); | |
const itemSlot = ethers.utils.keccak256(paddedKey + paddedSlot.slice(2)); | |
const storageSlot = ethers.utils.hexStripZeros(itemSlot); | |
await ethers.provider.send("anvil_setStorageAt", [ | |
token, | |
storageSlot, | |
ethers.utils.hexZeroPad(ethers.utils.parseUnits('100000000').toHexString(), 32) | |
]); | |
} | |
async function setBalances() { | |
let account = "YOUR_ACCOUNT"; | |
let dai = "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"; | |
let usdc= "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"; | |
let usdt= "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"; | |
setBalance(account, dai, 2); | |
setBalance(account, usdc, 51); | |
setBalance(account, usdt, 51); | |
} | |
setBalances(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment