GeneralizedTCR Events Mirror
This tool allows an oracle to mirror events from a Generalized TCR contract to another contract on another chain (though it can be used on the same chain).
The motivation for the development of this tool is to allow a subgraph synced to an Ethereum blockchain (say xDai) to handle changes that happen on another chain (say Mainnet). This allows for queries using data from both blockchains.
Throughout this project, we call "watch contract" the contract from which the bot reads events, and "mirror contract" the contract to which it sends transactions/relays the events.
- Tested on NodeJS version 10
- Clone this repo and run
yarn
. - Duplicate
.env.example
and name it.env
. - Run
yarn start:localnode
. Once it finishes booting, copy the first account private key and paste it on theMIRROR_CONTRACT_WALLET_PRIVATE_KEY
variable in .env.
. It should be the same every time you boot your node. - On another terminal, run
yarn deploy:localhost
. Copy the GeneralizedTCR address to theWATCH_CONTRACT_ADDRESS
environment variable. Copy the GTCR events relay address toMIRROR_CONTRACT_ADDRESS
environment variable. - To run the bot we have to options see option
Option A
if are working on VS Code/Codium andOption B
to just run the bot.
If developing in VS Code/Codium, you can use this .vscode/launch.json
file for debugging:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"preLaunchTask": "tsc: build - tsconfig.json",
"program": "${workspaceFolder}/bot/index.ts",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
With the file in place, just hit F5
.
Alternatively you can just build and run the bot with yarn start:bot
.
Sokol Network: 0x584F1896ce5876aB38cF28CC4CD2b93A1E319bF0
To start with PM2 use
pm2 start yarn --interpreter bash --name gtcr-event-mirror -- start:bot
See CONTRIBUTING.md.