This project indexes the C-Chain of Avalanche and provides endpoints for accessing information related to blockchain transactions and addresses.
- Install dependencies
docker compose build
- Setup the database
docker compose run --rm indexer npx prisma db push
docker compose up
If you need to start fresh by erasing all indexed data, execute the following command.
docker compose run --rm indexer npx prisma db push --force-reset
Below are instructions on how to call the endpoints of the API along with examples of requests and responses.
GET /addresses/:address/transactions
GET http://localhost:3000/addresses/0x123abc/transactions
[
{
"hash": "0x5aea6d0e7f8d910260ec0bddeeb75504aacf274a00322b01d15828b60df16839",
"to": "0x123abc",
"from": "0x9f8c163cba728e99993abe7495f06c0a3c8ac8b9",
"blockNumber": "0x2400f8d",
"transactionIndex": "0x2",
"value": "0x1b1ac86aedc91c0000"
},
// ... additional transactions for the address
]
GET /addresses/:address/transaction-count
GET http://localhost:3000/addresses/0x123abc/transaction-count
{
"count": 42
}
GET /blocks
GET http://localhost:3000/blocks
[
{
"hash": "0x85230025f1b0ffc35b0289d15b58d957772a89e04e1d9de57393822eb48fcbb7",
"miner": "0x0100000000000000000000000000000000000000",
"number": "0x261aae0",
"size": "0x8fc",
"timestamp": "0x65979a13"
},
// ... additional blocks sorted by number
]
GET /transactions
GET http://localhost:3000/transactions
[
{
"hash": "0x5aea6d0e7f8d910260ec0bddeeb75504aacf274a00322b01d15828b60df16839",
"to": "0xffb02c56bb2843b794016ddc08ab11a8be7d73ca",
"from": "0x9f8c163cba728e99993abe7495f06c0a3c8ac8b9",
"blockNumber": "0x2400f8d",
"transactionIndex": "0x2",
"value": "0x1b1ac86aedc91c0000"
},
// ... additional transactions sorted by value
]
GET /addresses/top-by-balance
GET http://localhost:3000/addresses/top-by-balance
[
{
"address": "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
"balance": "0x50d2701ab4082e190466f"
},
// ... additional top addresses
]