🏁Quickstart

This 5 minute tutorial will walk you through steps to create a shadow fork of Ethereum Mainnet, add a shadow event to a contract, and retrieve its data.

By the end of this tutorial, you will:

  1. Add a custom shadow event by editing the WETH contract

  2. Test your changes

  3. Deploy your changes to your shadow fork

  4. Make a JSON-RPC request to retrieve your custom shadow logs

Step 0 – Login to Shadow

Login to app.shadow.xyz with a Google account.

You should see a screen like the one shown below. The string after project_id= in the URL is your unique Shadow project ID (e.g. fc6ee70a-6f14-4a99-81db-6bd96226b95f).

https://app.shadow.xyz/?project_id=fc6ee70a-6f14-4a99-81db-6bd96226b95f

Step 1 – Add a custom shadow event

Navigate to the WETH token contract page by pasting the contract address into the search bar 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

Click the “Open in editor” button on the top right to open the in-browser IDE.

At the top of the contract on L27, define a new event schema called HelloWorld:

event HelloWorld(string message);

Then, add a line to emit a HelloWorld log at L74 with a custom message every time WETH is transferred:

HelloWorld("Emitting my first shadow event");

After you’re done with your changes, hit the “Compile” button on the top right.

Step 2 – Test your changes

Test run your changes by simulating a transaction, and confirming that the transaction has logged your new shadow event.

Click the “Test Run” button on the top right, paste in the following transaction hash, and hit “Run”: 0x2ce5687567574b47c9406df5b65c1d9dd0d94bdcdde7109810b642c35599774b.

You should see your new HelloWorld shadow event in the right hand panel!

Step 3 – Deploy your shadow fork

Now that you’ve tested your shadow changes, you’re ready to deploy the shadow contract onto your shadow fork. Just hit the “Deploy” button on the top right corner.

Step 4 – Make a JSON-RPC request

Now that you've deployed your shadow changes, you're ready to request the data from your shadow fork's RPC. Here's how you would make an eth_getLogs request from your terminal.

curl https://rpc.shadow.xyz/ethereum/mainnet/v1/<fork_id>/<version> \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-SHADOW-API-KEY: <API_KEY>" \
  --data '{
    "method": "eth_getLogs",
    "params": [{
      "fromBlock": "safe",
      "toBlock": "latest",
      "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "topics": []
    }],
    "id": 1,
    "jsonrpc": "2.0"
  }'

That's it! You have successfully generated custom data on your own shadow fork 🌗

Last updated