This directory contains the bridge-history-api
service that provides REST APIs to query txs interact with Scroll official bridge contracts
The bridge-history-api contains three distinct components
Provide init, show version, rollback, and check status services of DB
cd ./bridge-history-api
make bridgehistoryapi-db-cli
./build/bin/bridgehistoryapi-db-cli [command]
Fetch the transactions from both L1 and L2
cd ./bridge-history-api
make bridgehistoryapi-fetcher
./build/bin/bridgehistoryapi-fetcher
provides REST APIs. Please refer to the API details below.
cd ./bridge-history-api
make bridgehistoryapi-api
./build/bin/bridgehistoryapi-api
/api/txs
// @Summary get all txs under the given address
// @Accept plain
// @Produce plain
// @Param address query string true "wallet address"
// @Param page_size query int true "page size"
// @Param page query int true "page"
// @Success 200
// @Router /api/txs [get]
/api/l2/withdrawals
// @Summary get all L2 withdrawals under given address
// @Accept plain
// @Produce plain
// @Param address query string true "wallet address"
// @Param page_size query int true "page size"
// @Param page query int true "page"
// @Success 200
// @Router /api/l2/withdrawals [get]
/api/l2/unclaimed/withdrawals
// @Summary get all L2 unclaimed withdrawals under the given address
// @Accept plain
// @Produce plain
// @Param address query string true "wallet address"
// @Param page_size query int true "page size"
// @Param page query int true "page"
// @Success 200
// @Router /api/l2/unclaimed/withdrawals [get]
/api/txsbyhashes
// @Summary get txs by given tx hashes
// @Accept plain
// @Produce plain
// @Param hashes query string array true "array of hashes"
// @Success 200
// @Router /api/txsbyhashes [post]
-
Pull the latest Redis image:
docker pull redis:latest
-
Run the Redis container:
docker run --name bridgehistoryapi-redis -d -p 6379:6379 redis:latest
-
Pull the latest PostgreSQL image:
docker pull postgres:latest
-
Run the PostgreSQL container:
docker run --name bridgehistoryapi-history-db -p 5444:5432 -e POSTGRES_PASSWORD=123456 -e POSTGRES_DB=test -d postgres
-
Run database migrations to initialize the tables:
make bridgehistoryapi-db-cli ./build/bin/bridgehistoryapi-db-cli migrate
-
Run bridgehistoryapi-fetcher:
make bridgehistoryapi-fetcher ./build/bin/bridgehistoryapi-fetcher
-
Run bridgehistoryapi-api:
make bridgehistoryapi-api ./build/bin/bridgehistoryapi-api
The endpoints provided in ./conf/config.json are all public endpoints and have rate limits.
For production usage:
- For L1 endpoints, utilizing a service provider's free tier should suffice.
- For L2 endpoints, consider running a Scroll L2geth node and using the exposed HTTP port.