Documentation Index
Fetch the complete documentation index at: https://tech.ramses.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
Developing your dApps or smart contracts requires some tinkering to get a proper setup that is both a good simulation of how Mainnet will behave, but also customizable enough to suit the needs of a development environment. One very common approach is to create your own custom chain offline and develop on top of it. The issue with this approach is that if you are integrating with protocols like Ramses or others that are on Mainnet, it’s difficult to simulate on your local chain as the smart contracts from Mainnet are not there. Another approach is to use a testnet. While most protocols have versions of their smart contracts deployed on common testnets, there are certain behavioral differences. Not all pools that are on Mainnet are on testnets for example. Also, it’s difficult to get enough testnet ETH to account for real testing. And without lots of testnet tokens it’s even more difficult to swap to other coins on Ramses, if that’s what you need to do in your development environment. This guide focuses on yet another approach to local development: Mainnet Forks. A Mainnet Fork is a local chain that copies the state of Ethereum Mainnet at a given block number. It then gives you access to cheat codes like wallets with thousands of ETH and RPC URLs that you can use as drop-in replacements of real Mainnet RPCs. This approach combines the best of all other approaches. You have a local chain that you can manipulate to your liking and you have real deployments of all the protocols you need to test and develop your dApp or smart contracts.This guide focuses on Ethereum Mainnet. But you can easily fork any other chain by simply replacing the RPC URL with
one of the network you want to use.
The
@kingdomdotone/v3-sdk is Ramses’ fork of the Uniswap V3 SDK, tailored for Ramses V3 pools. Use it alongside @uniswap/sdk-core for core token abstractions.Forking a chain requires archival data and trace calls. Infura and normal geth instances are by default not archival.
You can get a free archival RPC that you can use to follow this guide and fork Mainnet you can visit Chainnodes.
Using Foundry and Anvil
There are several developer tools to fork Mainnet. Anvil by foundry is a newcomer that’s fast and easy to setup. This guide focuses on Anvil. As a first step, follow the installation guide in the foundry book. Once you have done that, you will be able to fork Mainnet straight away. Run the below command in your terminal: Make sure that you:- Replace your API Key (get one by heading to Chainnodes)
- Replace the block number with a recent one, check Etherscan for that
- If you fork a non-Ethereum Mainnet chain, check Chainlist for the correct chain id and replace both occurrences in the command below
anvil --help to see all available options.
Once you have done that, you should see something like the below:
127.0.0.1:8545.
This is the RPC URL that you can now use as a drop-in replacement everywhere in your development environment, and interact with it
as if it was real Ethereum Mainnet. You can use the http provider http://127.0.0.1:8545 as well as the Websocket provider ws://127.0.0.1:8545.
You can now make a sample RPC request to your http provider using Postman using the below:
POST http://127.0.0.1:8545
Body:
result value 0x1 is the hex-encoded chain ID for Ethereum Mainnet (1). This confirms your local fork is correctly emulating Mainnet.
You can find the above example and more in the Postman workspace under “Local Development”.
