Skip to content

Double Zero combines privacy and interoperability, delivering a scalable blockchain solution seamlessly integrated with Ethereum/Elastic-Chain assets and development tools.

License

Notifications You must be signed in to change notification settings

Moonsong-Labs/double-zero

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Double Zero Block Explorer

A privacy-focused, access-controlled blockchain browser for the Double Zero implementation.

πŸ“Œ Overview

Note

Double Zero Block Explorer is a customized version of the ZKsync Era Block Explorer that introduces a layer of privacy and access control. By implementing user authentication and permission-based data restrictions, it ensures that users can access blockchain data according to their assigned permissions.

This repository is a monorepo consisting of 5 packages:

  • Worker - an indexer service for ZKsync Era blockchain data. The purpose of the service is to read blockchain data in real time, transform it and fill in it's database with the data in a way that makes it easy to be queried by the API service.
  • Data Fetcher - a service that exposes and implements an HTTP endpoint to retrieve aggregated data for a certain block / range of blocks from the blockchain. This endpoint is called by the Worker service.
  • API - a service providing Web API for retrieving structured ZKsync Era blockchain data collected by Worker. It connects to the Worker's database to be able to query the collected data.
  • Proxy - a proxy between the WebApp and the API used to filter data to users, and ensure that each user sees only the data that they are allowed to see.
  • App - a front-end app providing an easy-to-use interface for users to view and inspect transactions, blocks, contracts and more. It makes requests to the API to get the data and presents it in a way that's easy to read and understand.

πŸ› Architecture

The following diagram illustrates how are the block explorer components connected:

flowchart
  subgraph blockchain[Blockchain]
    Blockchain[ZKsync Era JSON-RPC API]
  end

  subgraph dapps[Dapps]
      PrivateRpc[User scoped rpc]
  end


subgraph explorer[Block explorer]
    Database[("Block explorer DB<br/>(PostgreSQL)")]
    Worker(Worker service)
    Data-Fetcher(Data Fetcher service)
    API(API service)
    App(App)
    Proxy(Proxy)
    
    Worker-."Request aggregated data (HTTP)".->Data-Fetcher
    Data-Fetcher-."Request data (HTTP)".->Blockchain
    Worker-.Save processed data.->Database

    App-."Request data (HTTP)".->Proxy
    Proxy-."Request data (HTTP) and filter results".->API
    API-.Query data.->Database
end
  
PrivateRpc -."Reads data. Returns data filtered per user.".->Blockchain
Worker-."Request data (HTTP)".->Blockchain
Loading

Worker service retrieves aggregated data from the Data Fetcher via HTTP and also directly from the blockchain using ZKsync Era JSON-RPC API, processes it and saves into the database. API service is connected to the same database where it gets the data from to handle API requests. It performs only read requests to the database. The front-end App makes HTTP calls to the Block Explorer API to get blockchain data . The Proxy filters API responses based on user permissions, ensuring secure and controlled data access.

πŸš€ Features

Privacy and access control

  • βœ… Authentication and authorization using Sign In With Ethereum (SIWE).
  • βœ… Data scoped per user based on user permissions.

Block Explorer

  • βœ… View transactions, blocks, transfers and logs.
  • βœ… Inspect accounts, contracts, tokens and balances.
  • βœ… Verify smart contracts.
  • βœ… Interact with smart contracts.
  • βœ… Standalone HTTP API.
  • βœ… Local node support.

πŸ“‹ Prerequisites

  • Ensure you have node >= 18.0.0 and yarn >= 1.20 installed.

πŸ›  Installation

yarn install

βš™οΈ Setting up env variables

Manually set up env variables

Make sure you have set up all the necessary env variables. Follow setting up env variables instructions for Worker, Data Fetcher and API. For the App package you might want to edit environment config, see Environment configs.

Build env variables based on your zksync-era local repo setup

Make sure you have zksync-era repo set up locally. You must have your environment variables files present in the zksync-era repo at /etc/env/*.env for the build envs script to work.

The following script sets .env files for Worker, Data Fetcher, API and Proxy packages as well as environment configuration file for App package based on your local zksync-era repo setup.

yarn run hyperchain:configure

You can review and edit generated files if you need to change any settings.

πŸ‘¨β€πŸ’» Running locally

Before running the solution, make sure you have a database server up and running, you have created a database and set up all the required environment variables. To create a database run the following command:

yarn run db:create

To run all the packages (Worker, Data Fetcher, API, Proxy and front-end App) in development mode run the following command from the root directory.

yarn dev

For production mode run:

yarn build
yarn start

Each component can also be started individually. Follow individual packages README for details.

🐳 Running in Docker

There is a docker compose configuration that allows you to run Block Explorer and all its dependencies in docker. Just run the following command to spin up the whole environment:

docker compose up

It will run local Ethereum node, ZkSync Era, Postgres DB and all Block Explorer services.

Another option is to run only the double zero services hitting external endpoints These can be done by upgrading the content proxy.env with the desired rpc and explorer urls. Then running:

docker compose -f docker-compose-00.yaml --env-file=proxy.env up

This is going to spin only the services needed to make a functional double zero setup against the specified environment.

⛓️ Connection to your Hyperchain

To get block-explorer connected to your ZK Stack Hyperchain you need to set up all the the necessary environment and configuration files with your Hyperchain settings. You can use a script to build them. See Setting up env variables.

πŸ” Verify Block Explorer is up and running

To verify front-end App is running open http://localhost:3010 in your browser. API should be available at http://localhost:3020, Worker at http://localhost:3001 and Data Fetcher at http://localhost:3040.

πŸ•΅οΈβ€β™‚οΈ Testing

Run unit tests for all packages:

yarn test

Run e2e tests for all packages:

yarn test:e2e

Run tests for a specific package:

yarn test -w {package}

For more details on testing please check individual packages README.

πŸ’» Conventional Commits

We follow the Conventional Commits specification.

πŸ“˜ License

ZKsync Era Block Explorer is distributed under the terms of either

at your option.

πŸ”— Production links

About

Double Zero combines privacy and interoperability, delivering a scalable blockchain solution seamlessly integrated with Ethereum/Elastic-Chain assets and development tools.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 84.0%
  • Vue 13.4%
  • Gherkin 1.9%
  • JavaScript 0.3%
  • Dockerfile 0.2%
  • MDX 0.2%