Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 Watch ERC-20 token transfers
Add watchers that will watch a specific ERC-20 contract and log the balances of all transfers.
- Loading branch information
Showing
26 changed files
with
922 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/.ethlogger-state.json | ||
/checkpoints.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Watching ERC-20 token balances | ||
|
||
This is an example showing how to use ethlogger to track the activity of an ERC-20 token. | ||
|
||
Ethlogger configuration is provided in the form of [environment variables](../../docs/cli.md#environment-variables) in [docker-compose.yaml](./docker-compose.yaml#L25) and a configuration file, [ethlogger.yaml](./ethlogger.yaml). | ||
|
||
## Run | ||
|
||
1. Start docker-compose | ||
|
||
```sh-session | ||
$ cd examples/erc20-tracking | ||
$ docker-compose up -d | ||
``` | ||
|
||
2. Wait for all containers to start. | ||
You can rely on the output of `docker ps` to see the state of services. | ||
|
||
3. Then go to [http://localhost:8000](http://localhost:8000) to explore the data produced by ethlogger. | ||
Login using user `admin` and password `changeme` | ||
|
||
## Note | ||
|
||
> This example is not meant to be used in a production setup. | ||
> Using the logging driver to log to a container in the same docker-compose stack shouldn't be used in production. | ||
> Splunk and ethlogger persist data using local volumes and a checkpoints file. If blocks are no longer being ingested, or if you want to change the blockchain you are using, you should clear this state. To start clean, run the following. | ||
```sh-session | ||
$ docker-compose down | ||
$ rm checkpoints.json | ||
$ docker volume prune | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
version: '3.6' | ||
|
||
services: | ||
splunk: | ||
image: splunk/splunk:latest | ||
container_name: splunk | ||
environment: | ||
- SPLUNK_START_ARGS=--accept-license | ||
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113 | ||
- SPLUNK_PASSWORD=changeme | ||
- SPLUNK_APPS_URL=https://github.com/splunk/ethereum-basics/releases/download/latest/ethereum-basics.tgz | ||
ports: | ||
- 8000:8000 | ||
- 8088:8088 | ||
healthcheck: | ||
test: ['CMD', 'curl', '-f', 'http://localhost:8000'] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 20 | ||
volumes: | ||
- ./splunk.yml:/tmp/defaults/default.yml | ||
- /opt/splunk/var | ||
- /opt/splunk/etc | ||
ethlogger: | ||
image: ghcr.io/splunkdlt/ethlogger:latest | ||
container_name: ethlogger | ||
command: -c /app/ethlogger.yaml | ||
environment: | ||
- ETH_RPC_URL=https://dai.poa.network | ||
# Use these environment variables to connect to infura | ||
# - ETH_RPC_URL=https://mainnet.infura.io/v3/<your infura project id> | ||
- START_AT_BLOCK=latest | ||
- SPLUNK_HEC_URL=https://splunk:8088 | ||
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113 | ||
- SPLUNK_EVENTS_INDEX=main | ||
- SPLUNK_METRICS_INDEX=metrics | ||
- SPLUNK_INTERNAL_INDEX=metrics | ||
- SPLUNK_HEC_REJECT_INVALID_CERTS=false | ||
volumes: | ||
- ./:/app | ||
depends_on: | ||
- splunk | ||
restart: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
balanceWatchers: | ||
wxdai: | ||
# https://blockscout.com/xdai/mainnet/address/0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d/transactions | ||
contractAddress: '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d' | ||
startAt: 19023469 | ||
blockWatcher: | ||
enabled: false | ||
nodeMetrics: | ||
enabled: false | ||
nodeStats: | ||
enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
splunk: | ||
conf: | ||
indexes: | ||
directory: /opt/splunk/etc/apps/search/local | ||
content: | ||
metrics: | ||
coldPath: $SPLUNK_DB/metrics/colddb | ||
datatype: metric | ||
homePath: $SPLUNK_DB/metrics/db | ||
maxTotalDataSizeMB: 512000 | ||
thawedPath: $SPLUNK_DB/metrics/thaweddb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.