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
.
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
Clone the repo and put your arak.toml
file at in the project root.
git clone [email protected]:cowprotocol/arak.git
cd arak
# save arak.toml (from above) here
RUST_LOG=info,arak=debug cargo run