Add `evm_setCode` and `evm_setStorageAt` RPC methods
See original GitHub issueExpected Behavior
I would like to be able to insert bytecode at arbitrary addresses, and manipulate storage.
Possible Solution
I propose to add two new non-standard RPC methods:
evm_setCode
: takes two parameters. The first is the address where the bytecode is to be added, and the 2nd is the bytecode.evm_setStorageAt
: takes three parameters. The first is an address, the second is an offset, the third is a 32 byte hexstring to place at that address/offset.
Context
With these methods it will be possible to recreate specific mainnet conditions so I can test against “sort-of production” without sacrificing performance (forking can be slow) or losing determinism.
It will also allow me to do things such as:
- manipulating token balances / total supply
- override safety parameters within a contract to simulate a potential exploit
- simulate consequences of an off-by-one runtime compiler error
- etc etc etc
I think there are a lot of potential use cases here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:8 (8 by maintainers)
Top Results From Across the Web
RPC API - MetaMask Docs
The API is based on an interface exposed by all Ethereum clients, along with a growing number of methods that may or may...
Read more >JSON-RPC API - ethereum.org
A handful of core JSON-RPC methods require data from the Ethereum network, and fall neatly into three main categories: Gossip, State, and History....
Read more >How to Create an RPC Add-On for Marketplace - QuickNode
1. An RPC add-on is one that is primarily used inside of QuickNode’s platform and extends our capabiliti... 2. In this guide, we’ll...
Read more >Supported JSON-RPC methods - Amazon Managed Blockchain
Ethereum in Amazon Managed Blockchain supports the following Ethereum JSON-RPC API methods. Each supported API call has a brief description of its utility....
Read more >Confluence JSON-RPC APIs - Atlassian Developer
It also supports a 'light' mode where you can supply the method name in ... We have therefore added a JSON-RPC API capability...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
These will likely land in the next major release or shortly thereafter.
I played around with an experimental version here: https://github.com/trufflesuite/ganache-core/blob/4a081acfad686e2f94c49f6087df6bb9722d2d1d/src/chains/ethereum/src/api.ts#L224 but literally haven’t even run the code to see it fail… I accidentally included it in a commit refactoring other parts of code. 😅
That branch I linked to is a rewrite of ganache-core into TypeScript and it will be some time before it is released (and will be a significant breaking change). For the time being I’m trying to maintain the current JavaScript code base as well, so if you want, you can port the work I started over to JS, and I’ll likely merge and release it.
Ah this idea is great! I’ll try working on it