NomicFoundation / NomicFoundation/hardhat

Create a helper to set an ERC-20 balance

Open
#1,663 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Stale status:blocked type:feature
Dominant language
TypeScript
Stars
8.5k
Forks
1.7k
Avg merge
6d 20h
Merged PRs (30d)
35

Description

Now that we have an RPC method to overwrite a storage slot, we can create a helper to set an arbitrary balance to an address in any ERC20 token.

One way to implement it is:

  1. Get the access list of calling balanceOf(address)
  2. Take a snapshot
  3. Modify the first slot in the token's access list by setting it to a well known magic number
  4. Check if calling balanceOf(address) returns the magic number now
  5. If it doesn't, revert to the snapshot and repeat the process with the next slot
  6. If it does, revert the snapshot and overwrite it with the desired balance

We haven't implemented eth_createAccessList yet, so I'm flagging this as blocked.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by checking the existing RPC method for overwriting storage slots and whether eth_createAccessList is now available. The helper should locate the balanceOf storage slot through access-list trials, verify the magic value, then restore snapshots and set the desired balance; the issue currently identifies this work as blocked.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
blockchain, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.