Skip to content

Commit

Permalink
chore: blockscout example project (#3386)
Browse files Browse the repository at this point in the history
* chore: blockscout example project

Signed-off-by: Nadezhda Popova <[email protected]>

* fixup! chore: blockscout example project

Signed-off-by: Nadezhda Popova <[email protected]>

* fixup! fixup! chore: blockscout example project

Signed-off-by: Nadezhda Popova <[email protected]>

* fixup! fixup! fixup! fixup! chore: blockscout example project

Signed-off-by: Nadezhda Popova <[email protected]>

---------

Signed-off-by: Nadezhda Popova <[email protected]>
  • Loading branch information
nadezhdapopovaa authored Jan 17, 2025
1 parent 0fc6680 commit 76687f8
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions tools/blockscout-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Blockscout

BlockScout is an open-source blockchain explorer designed to provide users with a comprehensive interface for interacting with Ethereum-compatible networks, enhancing transparency and accessibility in blockchain ecosystems. It allows users to view and analyze blockchain data, including transactions, blocks, smart contracts, and token information, while providing real-time monitoring of transactions and block confirmations through a user-friendly interface and an API that enable both technical and non-technical users to easily interact with smart contracts and track various tokens and their transactions.

- Documentation: https://docs.blockscout.com/
- Repository: https://github.com/blockscout/blockscout/tree/master

## Requirements
Local node repository needed
```bash
git clone [email protected]:hiero-ledger/hiero-local-node.git
```

## Step 1: Set Up the Relay with Localnode

1. In the `.env` file of the local node set the following variable to true:

```env
BATCH_REQUESTS_ENABLED=true
```
2. In the `docker-compose.yml` file in the local node:
- add `BATCH_REQUESTS_ENABLED` to the envorment of the relay:
```
BATCH_REQUESTS_ENABLED: "${BATCH_REQUESTS_ENABLED}"
```
- adjust the port of **hedera-explorer** in order to free up the default port on which blockscout is running:
```
ports:
- "9080:8080"
```
3. Run the project:
```bash
npm run start
```
## Step 2: Set Up Blockscout
1. Clone Blockscout repo
```git
git clone [email protected]: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)
## 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 modules make sure to give the correct value for `module`
- choose an `accountAddress` from one of the accounts that the local node generates upon starting
- curl request:
```bash
curl --location 'http://localhost/api?module=account&action=balance&address={accountAddress}'
```

0 comments on commit 76687f8

Please sign in to comment.