Skip to content

0xweb-org/examples-storage

Repository files navigation

Storage Demo

This git repository serves the purpose of providing example and facilitating continuous integration (CI) for:

  • forking, reading, writing EVM storage with 0xweb and hardhat.
  • dump and restore contracts storage

Further reading https://dev.kit.eco/ethereum-autogenerated-typescript-classes-to-read-and-write-contracts-private-state-variables


CircleCI


1. How was this project bootstrapped.

$ npm i 0xweb -g
$ 0xweb init --hardhat
$ 0xweb i 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 --name USDC --chain eth

2. Forking the mainnet in hardhat.config.js

Public Ankr RPC node is used.


forking, reading, writing

3. What actions were added in usdc.act.ts

  • create-accounts: Generate foo and bar accounts (address+private key)
  • set-balance: Modify the EVM storage in USDC contract to set the balance for the address foo to have 50_000$
  • transfer-balance: Execute normal transaction to transfer the balance from foo to bar

4. How we test the actions in usdc.spec.ts

  • create-accounts: Execute action and check the output
  • set-balance: Execute action and use 0xweb cli to check the foo balance
  • transfer-balance: Execute action and use 0xweb cli to ensure foo balance is empty, but the bar address has funds

dump, restore

5. What actions were added in dump.act.ts

  • deploy original and configure: Deploy first contract and manually set new values
  • dump original contract: Dump first contract's storage
  • should redeploy contract: Deploy second contract, which storage remains initial
  • should restore from dump: Restores the contracts storage from dump

6. How we test the actions in dump.spec.ts

  • Check values of the original contracts
  • Dumps original contract and checks the JSON data
  • Restore the dump to a new contract and verify the data on-chain

🏁 0xweb.org

About

Fork, Read, Write the EVM storage using the USDC contract

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published