Skip to content

Instantly share code, notes, and snippets.

@petejkim
Created December 21, 2020 20:39
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/78e187a6565f1e034046dfeee1c569ee to your computer and use it in GitHub Desktop.
Save petejkim/78e187a6565f1e034046dfeee1c569ee to your computer and use it in GitHub Desktop.
USDC v2: Upgrading a $1.4B Token - Testing Storage Slot 4
// Storage slot 4 contains "name" (string)
const data = await web3.eth.getStorageAt(contract.address, 4);
const len2 = parseInt(data.slice(-2), 16); // Last 1 byte = length * 2
// Read the text (skip "0x")
const text = Buffer.from(data.slice(2, 2 + len2), "hex").toString("utf8");
expect(text).to.equal(name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment