Skip to content

Instantly share code, notes, and snippets.

@bh2smith
Last active September 18, 2023 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bh2smith/3d8a443f26b1130722e2e6fbb6ffe2e3 to your computer and use it in GitHub Desktop.
Save bh2smith/3d8a443f26b1130722e2e6fbb6ffe2e3 to your computer and use it in GitHub Desktop.
Run Arak Quickstart

Arak Quickstart

Arak is a very simple ethereum log indexing program found on github at: https://github.com/cowprotocol/arak

Create Postgres Instance

docker pull postgres

docker run --name erc721 -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres -d postgres

This instance corresponds to a postgres container with the following connection string:

postgresql://postgres:postgres@localhost:5432/postgres

Prepare your configuration TOML file. Our example is for indexing ERC721 Events:

#### Free Nodes that work
ethrpc = "https://rpc.ankr.com/eth"
# ethrpc = "https://eth.llamarpc.com"

#### Nodes requiring API keys (supply API key)
# ethrpc = "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}"
# ethrpc = "https://mainnet.infura.io/v3/${INFURA_KEY}"

[database.postgres]
connection = "postgresql://postgres:postgres@localhost:5432/postgres"

#[database.sqlite]
#connection = "file:arak.db"

[indexer]
page-size = 250
poll-interval = 0.1

## ERC721: https://eips.ethereum.org/EIPS/eip-721#specification

[[event]]
name = "erc721_transfer"
start = 0
contract = "*"
signature = "event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"

[[event]]
name = "erc721_approval"
start = 0
contract = "*"
signature = "event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)"

## ERC1155: https://eips.ethereum.org/EIPS/eip-1155#specification

[[event]]
name = "erc1155_transfer_single"
start = 0
contract = "*"
signature = "event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value)"

[[event]]
name = "erc1155_transfer_batch"
start = 0
contract = "*"
signature = "event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values)"

[[event]]
name = "erc1155_uri"
start = 0
contract = "*"
signature = "event URI(string value, uint256 indexed id)"

### Overlapping Events

[[event]]
name = "approval_for_all"
start = 0
contract = "*"
signature = "event ApprovalForAll(address indexed owner, address indexed operator, bool approved)"

Save this as arak.toml.

Run the Remote Container Image:

This won't work until the following PR is merged: cowprotocol/arak#49

docker run --network host --add-host=localhost:host-gateway -v ${PWD}/arak.toml:/opt/config.toml -e ARAKCONFIG=/opt/config.toml ghcr.io/cowprotocol/arak:main

Run with Cargo

Clone the repo and put your arak.toml file at in the project root.

git clone git@github.com:cowprotocol/arak.git
cd arak
# save arak.toml (from above) here
RUST_LOG=info,arak=debug cargo run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment