Skip to content

Instantly share code, notes, and snippets.

@petejkim
Created December 21, 2020 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petejkim/d2203e0049a888e5ae9e29a5f136e637 to your computer and use it in GitHub Desktop.
Save petejkim/d2203e0049a888e5ae9e29a5f136e637 to your computer and use it in GitHub Desktop.
USDC v2: Upgrading a $1.4B Token - Testing Storage Slot 9
// Storage slot 9 contains "balances" (mapping(address => uint256))
// Derive slot position for the key k
const k = holderAddr.slice(2).toLowerCase().padStart(64, "0");
const p = "9".padStart(64, "0");
const valueSlotPos = web3.utils.keccak256("0x" + k + p);
const data = await web3.eth.getStorageAt(contract.address, valueSlotPos);
expect(new BN(data.slice(2), 16).eq(expectedBalance)).to.be.true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment