Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: blockscout example project #3386

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions tools/blockscout-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Running the Relay with Blockscout
quiet-node marked this conversation as resolved.
Show resolved Hide resolved

## Step 1: Set Up the Relay with Localnode

1. In the `.env` file of the local node set the following variable to true:
quiet-node marked this conversation as resolved.
Show resolved Hide resolved

```env
BATCH_REQUESTS_ENABLED=true
nadezhdapopovaa marked this conversation as resolved.
Show resolved Hide resolved
```
2. In the `docker-compose.yml` file:
- add `BATCH_REQUESTS_ENABLED` to the envorment of the relay:
```
BATCH_REQUESTS_ENABLED: "${BATCH_REQUESTS_ENABLED}"
```

- adjust the port of **hedera-explorer**:
nadezhdapopovaa marked this conversation as resolved.
Show resolved Hide resolved
```
ports:
- "9080:8080"
```

3. Run the project:
```bash
npm run start
```
## Step 2: Set Up Blockscout
1. Clone Blockscout repo
```git
nadezhdapopovaa marked this conversation as resolved.
Show resolved Hide resolved
git clone git@github.com:blockscout/blockscout.git
```
2. Set these variables in `common-blockscout.env`:
```env
ETHEREUM_JSONRPC_HTTP_URL=http://host.docker.internal:7546/
ETHEREUM_JSONRPC_TRACE_URL=http://host.docker.internal:7546/
NETWORK=Hedera
COIN_NAME=HBAR
COIN=HBAR
NFT_MEDIA_HANDLER_ENABLED=false
```
3. Make these changes in `docker-compose.yml` --> in `services` find `backend` and for the `environment` set the following:
```
environment:
ETHEREUM_JSONRPC_HTTP_URL: http://host.docker.internal:7546/
ETHEREUM_JSONRPC_TRACE_URL: http://host.docker.internal:7546/
ETHEREUM_JSONRPC_WS_URL: ws://host.docker.internal:8546/
CHAIN_ID: '298'
```
4. Build the project:
```bash
cd ./docker-compose
docker-compose up --build
```
5. Open [http://localhost](http://localhost)
quiet-node marked this conversation as resolved.
Show resolved Hide resolved

## API request example
[Blockscout JSON RPC & ETH Compatible RPC Endpoints](https://docs.blockscout.com/devs/apis/rpc)

**curl example** for getting the balance of an address:
- blockscout doc: https://docs.blockscout.com/devs/apis/rpc/account#get-the-native-token-balance-for-an-address
- make sure to replace `instance_base_url` with `localhost`
- when testing different moduls make sure to give the correct value for `module`
nadezhdapopovaa marked this conversation as resolved.
Show resolved Hide resolved
- curl request:
```bash
curl --location 'http://localhost/api?module=account&action=balance&address=0x05FbA803Be258049A27B820088bab1cAD2058871'
```
Loading