web3j Documentation

Lightweight Java and Android library for integration with Ethereum clients

RAW Doc

Docker & Self-Hosted Deployment Verified OCI

Deploy web3j on any server, homelab, or cloud container platform.

1-Click Terminal Command
bash (docker run)
docker run -d --name web3j -p 21001:21001 --restart always prom/prometheus
Configured Services & Ports
โš™๏ธ validator1
image: hyperledger/besu:${BESU_VERSION:-latest}
๐Ÿ”Œ Ports: 21001:8545/tcp, 30303, 9545
โš™๏ธ validator2
image: hyperledger/besu:${BESU_VERSION:-latest}
๐Ÿ”Œ Ports: 21002:8545/tcp, 30303, 9545
โš™๏ธ validator3
image: hyperledger/besu:${BESU_VERSION:-latest}
๐Ÿ”Œ Ports: 21003:8545/tcp, 30303, 9545
โš™๏ธ validator4
image: hyperledger/besu:${BESU_VERSION:-latest}
๐Ÿ”Œ Ports: 21004:8545/tcp, 30303, 9545
โš™๏ธ rpcnode
image: hyperledger/besu:${BESU_VERSION:-latest}
๐Ÿ”Œ Ports: 8545:8545/tcp, 8546:8546/tcp
โš™๏ธ ethsignerProxy
image: consensys/ethsigner:${ETHSIGNER_VERSION:-latest}
๐Ÿ”Œ Ports: 18545:8545/tcp
โš™๏ธ member1tessera
image: build locally
๐Ÿ”Œ Ports: 9081:9080
โš™๏ธ member1besu
image: hyperledger/besu:${BESU_VERSION:-latest}
๐Ÿ”Œ Ports: 20000:8545/tcp, 20001:8546/tcp
โš™๏ธ member2tessera
image: build locally
๐Ÿ”Œ Ports: 9082:9080
โš™๏ธ member2besu
image: hyperledger/besu:${BESU_VERSION:-latest}
๐Ÿ”Œ Ports: 20002:8545/tcp, 20003:8546/tcp
โš™๏ธ member3tessera
image: build locally
๐Ÿ”Œ Ports: 9083:9080
โš™๏ธ member3besu
image: hyperledger/besu:${BESU_VERSION:-latest}
๐Ÿ”Œ Ports: 20004:8545/tcp, 20005:8546/tcp
โš™๏ธ explorer
image: consensys/quorum-explorer:${QUORUM_EXPLORER_VERSION:-latest}
๐Ÿ”Œ Ports: 25000:25000/tcp
โš™๏ธ prometheus
image: prom/prometheus
๐Ÿ”Œ Ports: 9090:9090/tcp
โš™๏ธ grafana
image: grafana/grafana
๐Ÿ”Œ Ports: 3000:3000/tcp
โš™๏ธ loki
image: grafana/loki
๐Ÿ”Œ Ports: 3100:3100/tcp
โš™๏ธ promtail
image: grafana/promtail
docker-compose.yml
yaml (docker-compose.yml)
---
version: '3.6'

x-besu-def:
  &besu-def
  restart: "on-failure"
  image: hyperledger/besu:${BESU_VERSION:-latest}
  env_file:
    - ./config/besu/.env
  entrypoint:
    - /bin/bash
    - -c
    - |

      cp "/config/${BESU_CONS_ALGO:-QBFT}genesis.json" /config/genesis.json

      /opt/besu/bin/besu \
      --config-file=/config/config.toml \
      --p2p-host=$$(hostname -i) \
      --rpc-http-api=EEA,WEB3,ETH,NET,TRACE,DEBUG,ADMIN,TXPOOL,PRIV,PERM,${BESU_CONS_ALGO:-QBFT} \
      --rpc-ws-api=EEA,WEB3,ETH,NET,TRACE,DEBUG,ADMIN,TXPOOL,PRIV,PERM,${BESU_CONS_ALGO:-QBFT} ;


x-tessera-def:
  &tessera-def
  build:
    context: config/tessera
    args:
      TESSERA_VERSION: ${TESSERA_VERSION:-latest}
  environment:
    TESSERA_MODE: orion
  expose:
    - 9000
    - 9080
    - 9101
  restart: "on-failure"




x-ethsignerProxy-def:
  ðsignerProxy-def
  image: consensys/ethsigner:${ETHSIGNER_VERSION:-latest}
  command: [
    "--chain-id=1337",
    "--http-listen-host=0.0.0.0",
    "--downstream-http-port=8545",
    "--downstream-http-host=rpcnode",
    "file-based-signer",
    "-k",
    "/opt/ethsigner/keyfile",
    "-p",
    "/opt/ethsigner/passwordfile"
  ]
  ports:
    - 8545

services:

  validator1:
    << : *besu-def
    ports:
      - 21001:8545/tcp
      - 30303
      - 9545
    environment:
      - OTEL_RESOURCE_ATTRIBUTES=service.name=validator1,service.version=${BESU_VERSION:-latest}
    labels:
      - "consensus=besu"
    volumes:
      - ./config/besu/:/config
      - ./config/nodes/validator1:/opt/besu/keys
      - ./logs/besu:/tmp/besu
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.11

  validator2:
    << : *besu-def
    ports:
      - 21002:8545/tcp
      - 30303
      - 9545
    environment:
      - OTEL_RESOURCE_ATTRIBUTES=service.name=validator2,service.version=${BESU_VERSION:-latest}
    labels:
      - "consensus=besu"
    volumes:
      - ./config/besu/:/config
      - ./config/nodes/validator2:/opt/besu/keys
      - ./logs/besu:/tmp/besu
    depends_on:
      - validator1
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.12

  validator3:
    << : *besu-def
    ports:
      - 21003:8545/tcp
      - 30303
      - 9545
    environment:
      - OTEL_RESOURCE_ATTRIBUTES=service.name=validator3,service.version=${BESU_VERSION:-latest}
    labels:
      - "consensus=besu"
    volumes:
      - ./config/besu/:/config
      - ./config/nodes/validator3:/opt/besu/keys
      - ./logs/besu:/tmp/besu
    depends_on:
      - validator1
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.13

  validator4:
    << : *besu-def
    ports:
      - 21004:8545/tcp
      - 30303
      - 9545
    environment:
      - OTEL_RESOURCE_ATTRIBUTES=service.name=validator4,service.version=${BESU_VERSION:-latest}
    labels:
      - "consensus=besu"
    volumes:
      - ./config/besu/:/config
      - ./config/nodes/validator4:/opt/besu/keys
      - ./logs/besu:/tmp/besu
    depends_on:
      - validator1
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.14

  rpcnode:
    << : *besu-def
    container_name: rpcnode
    environment:
      - OTEL_RESOURCE_ATTRIBUTES=service.name=rpcnode,service.version=${BESU_VERSION:-latest}
    volumes:
      - ./config/besu/:/config
      - ./config/nodes/rpcnode:/opt/besu/keys
      - ./logs/besu:/tmp/besu
    depends_on:
      - validator1
    ports:
      - 8545:8545/tcp
      - 8546:8546/tcp
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.15

  ethsignerProxy:
    << : *ethsignerProxy-def
    volumes:
      - ./config/ethsigner/password:/opt/ethsigner/passwordfile
      - ./config/ethsigner/key:/opt/ethsigner/keyfile
    depends_on:
      - validator1
      - rpcnode
    ports:
      - 18545:8545/tcp
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.40


  member1tessera:
    << : *tessera-def
    ports:
      - 9081:9080
    volumes:
      - ./config/nodes/member1:/config/keys
      - ./logs/tessera:/var/log/tessera/
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.26

  member1besu:
    << : *besu-def
    environment:
      - OTEL_RESOURCE_ATTRIBUTES=service.name=member1besu,service.version=${BESU_VERSION:-latest}
      - NODE_ID=6
    entrypoint:
      - /bin/bash
      - -c
      - |
        /opt/besu/bin/besu \
        --config-file=/config/config.toml \
        --p2p-host=$$(hostname -i) \
        --privacy-enabled \
        --privacy-url=http://member1tessera:9101 \
        --privacy-public-key-file=/opt/besu/keys/tm.pub \
        --privacy-onchain-groups-enabled=${PRIVACY_ONCHAIN_GROUPS_ENABLED:-false} \
        --rpc-http-api=EEA,WEB3,ETH,NET,TRACE,DEBUG,ADMIN,TXPOOL,PRIV,PERM,${BESU_CONS_ALGO:-QBFT} \
        --rpc-ws-api=EEA,WEB3,ETH,NET,TRACE,DEBUG,ADMIN,TXPOOL,PRIV,PERM,${BESU_CONS_ALGO:-QBFT} ;
    volumes:
      - ./config/besu/:/config
      - ./config/nodes/member1:/opt/besu/keys
      - ./logs/besu:/tmp/besu
    depends_on:
      - validator1
      - member1tessera
    ports:
      - 20000:8545/tcp
      - 20001:8546/tcp
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.16

  member2tessera:
    << : *tessera-def
    ports:
      - 9082:9080
    volumes:
      - ./config/nodes/member2:/config/keys
      - ./logs/tessera:/var/log/tessera/
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.27

  member2besu:
    << : *besu-def
    environment:
      - OTEL_RESOURCE_ATTRIBUTES=service.name=member2besu,service.version=${BESU_VERSION:-latest}
      - NODE_ID=7
    entrypoint:
      - /bin/bash
      - -c
      - |
        /opt/besu/bin/besu \
        --config-file=/config/config.toml \
        --p2p-host=$$(hostname -i) \
        --privacy-enabled \
        --privacy-url=http://member2tessera:9101 \
        --privacy-public-key-file=/opt/besu/keys/tm.pub \
        --privacy-onchain-groups-enabled=${PRIVACY_ONCHAIN_GROUPS_ENABLED:-false} \
        --rpc-http-api=EEA,WEB3,ETH,NET,TRACE,DEBUG,ADMIN,TXPOOL,PRIV,PERM,${BESU_CONS_ALGO:-QBFT} \
        --rpc-ws-api=EEA,WEB3,ETH,NET,TRACE,DEBUG,ADMIN,TXPOOL,PRIV,PERM,${BESU_CONS_ALGO:-QBFT} ;
    volumes:
      - ./config/besu/:/config
      - ./config/nodes/member2:/opt/besu/keys
      - ./logs/besu:/tmp/besu
    depends_on:
      - validator1
      - member2tessera
    ports:
      - 20002:8545/tcp
      - 20003:8546/tcp
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.17

  member3tessera:
    << : *tessera-def
    ports:
      - 9083:9080
    volumes:
      - ./config/nodes/member3:/config/keys
      - ./logs/tessera:/var/log/tessera/
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.28

  member3besu:
    << : *besu-def
    environment:
      - OTEL_RESOURCE_ATTRIBUTES=service.name=member3besu,service.version=${BESU_VERSION:-latest}
      - NODE_ID=8
    entrypoint:
      - /bin/bash
      - -c
      - |
        /opt/besu/bin/besu \
        --config-file=/config/config.toml \
        --p2p-host=$$(hostname -i) \
        --privacy-enabled \
        --privacy-url=http://member3tessera:9101 \
        --privacy-public-key-file=/opt/besu/keys/tm.pub \
        --privacy-onchain-groups-enabled=${PRIVACY_ONCHAIN_GROUPS_ENABLED:-false} \
        --rpc-http-api=EEA,WEB3,ETH,NET,TRACE,DEBUG,ADMIN,TXPOOL,PRIV,PERM,${BESU_CONS_ALGO:-QBFT} \
        --rpc-ws-api=EEA,WEB3,ETH,NET,TRACE,DEBUG,ADMIN,TXPOOL,PRIV,PERM,${BESU_CONS_ALGO:-QBFT} ;
    volumes:
      - ./config/besu/:/config
      - ./config/nodes/member3:/opt/besu/keys
      - ./logs/besu:/tmp/besu
    depends_on:
      - validator1
      - member3tessera
    ports:
      - 20004:8545/tcp
      - 20005:8546/tcp
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.18



  explorer:
    image: consensys/quorum-explorer:${QUORUM_EXPLORER_VERSION:-latest}
    volumes:
      - ./quorum-explorer/config.json:/app/config.json
      - ./quorum-explorer/env:/app/.env.production
    depends_on:
      - rpcnode
    ports:
      - 25000:25000/tcp
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.31







  prometheus:
    image: "prom/prometheus"
    volumes:
      - ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus:/prometheus
    command:
      - --config.file=/etc/prometheus/prometheus.yml
    ports:
      - 9090:9090/tcp
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.32

  grafana:
    image: "grafana/grafana"
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_USERS_VIEWERS_CAN_EDIT=true
    volumes:
      - ./config/grafana/provisioning/:/etc/grafana/provisioning/
      - grafana:/var/lib/grafana
    ports:
      - 3000:3000/tcp
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.33

  loki:
    image: "grafana/loki"
    volumes:
      - ./loki/loki.yml:/etc/loki/local-config.yaml
    command: -config.file=/etc/loki/local-config.yaml
    ports:
      - 3100:3100/tcp
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.34

  promtail:
    image: "grafana/promtail"
    volumes:
      - ./logs:/var/log
      - ./promtail/promtail.yml:/etc/promtail/config.yml
    command: -config.file=/etc/promtail/config.yml
    networks:
      quorum-dev-quickstart:
        ipv4_address: 172.16.239.35






volumes:
  public-keys:
  prometheus:
  grafana:
  splunk:
  ethlogger:
  blockscoutpostgres:

networks:
  quorum-dev-quickstart:
    name: quorum-dev-quickstart
    driver: bridge
    ipam:
      config:
        - subnet: 172.16.239.0/24

Technical Documentation: LFDT-web3j/web3j

โ„น๏ธ Provenance: Multi-Tier Ingestion ยท CodeWiki Reference

Overview (`README.md`)

Web3j: Web3 Java Ethereum Dapp API





Web3j is a lightweight, highly modular, reactive, type safe Java and
Android library for working with Smart Contracts and integrating with
clients (nodes) on the Ethereum network:

This allows you to work with the Ethereum
blockchain, without the additional overhead of having to write your own
integration code for the platform.

The Java and the Blockchain talk provides
an overview of blockchain, Ethereum and Web3j.

NEW! Get involved!

Since Web3J moved under Hyperledger we started to do Web3J Contributors calls every 2 weeks!
Subscribe to our community page and to see check our call schedule.
Your contribution matters!

Features

It has five runtime dependencies:

It also uses JavaPoet for
generating smart contract wrappers.

QuickStart

The simplest way to start your journey with Web3j is to create a project.
We provide this functionality using the Web3j CLI. This latter can be installed as follows:

For Unix:

shell script
installer=$(mktemp) &&
curl --disable --proto '=https' --proto-redir '=https' --fail --show-error --silent --location https://get.web3j.io -o "$installer" &&
bash "$installer" && rm -f "$installer" && source ~/.web3j/source.sh

For Windows, in Powershell:

shell script
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/hyperledger/web3j-installer/main/installer.ps1'))

Create a new project by running:

shell script
$ web3j new

Or use our Maven or
Gradle plugins to
generate java files from Solidity contracts.

Please head to the [Web3j Documentation](https://docs.web3j.io) for further instructions on using Web3j.

Maven

Java:

xml
<dependency>
  <groupId>org.web3j</groupId>
  <artifactId>core</artifactId>
  <version>6.1.0</version>
</dependency>

Note: The Web3j Java binaries are compiled using Java 21. Java 21 or a more recent version is required to use Web3j
as a dependency.

Android:

xml
<dependency>
  <groupId>org.web3j</groupId>
  <artifactId>core</artifactId>
  <version>4.12.3-android</version>
</dependency>

Gradle

Java:

groovy
implementation ('org.web3j:core:6.1.0')

Android:

groovy
implementation ('org.web3j:core:4.12.3-android')

Build instructions

Web3j includes integration tests for running against a live Ethereum
client. If you do not have a client running, you can exclude their
execution as per the below instructions.

To run a full build (excluding integration tests):

{.sourcecode .bash}
$ ./gradlew check

To run the integration tests, you will need to set up these variables in order to pull the Docker
images from the Docker Hub registry:

  • registry.username
  • registry.password

Then run the following command:

{.sourcecode .bash}
$ ./gradlew -Pintegration-tests=true :integration-tests:test

If you do not want the integration test to run:

{.sourcecode .bash}
$ ./gradlew -Pintegration-tests=false :test

Check the Docker client API
for more information on configuration options.

Projects using Web3j

Commercial support and training

Commercial support and training is available from
web3labs.com.

License

Apache 2.0


Overview (`.github/actions/emudhra-trust/README.md`)

CI containment for the eMudhra certificate incident

Following Oracle guidance, this action removes the emSign ECC Root CA - G3 and AAA Certificate Services roots from an isolated copy of the selected JDK truststore. It identifies roots by SHA-256, preserves other anchors, and never changes the installed JDK. Removing these roots may reject legitimate services that still use them.

The action validates fixture checksums, then checks that the effective JSSE trust manager rejects all twelve compromised TLS chains. Missing, malformed or expired fixtures fail the gate. Four hostname-verified TLS handshakes check legitimate dependency/publication hosts. No credentials or HTTP requests are sent. JAVA_TOOL_OPTIONS selects the isolated store for subsequent JVMs; a Gradle init script verifies that each Gradle daemon uses it and excludes both roots.

The public certificate fixtures come from this pinned incident-research commit. They cover DV/OV/EV, G3B/G3C and both issuer paths. No private keys or third-party code are included. SHA256SUMS records their exact bytes. Refresh the fixtures before their validity expires, preserving all twelve paths and provenance.

Build, integration, snapshot, release, Javadocs and CodeQL jobs use the action before Gradle. Changes to this action trigger the non-publishing release rehearsal. PR and manual rehearsal events cannot enter the push-only publishing steps.

This protects default Java TLS trust within these jobs. It does not update Node actions, Git/curl, Python, OS/container trust, consumer JDKs, custom trust managers or JVMs launched with overriding trust options. Those need independent verification. It does not change the Web3j library's API or consumer trust policy.


Overview (`.agents/skills/web3j/assets/erc20-example/README.md`)

ERC20 Example Starters

Use these starter assets when a user wants one example that shows how Web3j modules and companion tools fit together around an ERC20-like contract.

Templates

  • basic-erc20-app/
    • minimal JVM-side app and test suite
    • covers Solidity source, wrapper generation, deploy/load/call flow, typed events, and @EVMTest
    • best answer for show me a basic erc20 example, how do the web3j pieces fit together, or create a basic erc20 app

Agent workflow

When the user asks for a quick scaffold:

  1. copy basic-erc20-app/ into the target directory
  2. keep the package names and wrapper package unless the user asks to rename them
  3. patch token metadata, endpoint defaults, or transfer env vars only if the user provided concrete values
  4. mention web3j new if they asked for a CLI-generated template
  5. mention web3j_openapi only if they want an HTTP layer on top of the same contract flow

Overview (`.agents/skills/web3j/assets/event-subscriptions/README.md`)

Event Subscription Starters

Use these starter projects when a user asks for a runnable Web3j event-listening example.

Templates

  • websocket-newheads/
    • subscribes to new block headers over WebSocket
    • best default runnable example
  • contract-logs/
    • subscribes to contract logs with EthFilter
    • best when the user already has a contract address and event topic

Agent workflow

When the user asks for a quick scaffold:

  1. copy the closest starter into the target directory
  2. rename the package or project only if the user cares
  3. patch the env-var defaults if the user gave a concrete endpoint or contract
  4. explain the exact env vars required to run it

Runtime expectations

These templates are minimal Gradle Java apps.

Typical run commands:

sh
gradle run

or, if the target project has a wrapper:

sh
./gradlew run

Environment variables

`websocket-newheads`

  • WEB3J_WS_URL

`contract-logs`

  • WEB3J_HTTP_URL
  • WEB3J_CONTRACT_ADDRESS
  • WEB3J_EVENT_TOPIC0 optional

Overview (`.agents/skills/web3j/assets/erc20-example/basic-erc20-app/README.md`)

Basic ERC20 App

This starter is the shortest repo-grounded example that ties together:

  • Solidity source in src/main/solidity
  • wrapper generation via the Web3j Gradle plugin
  • wrapper-based deploy, call, and transfer flows
  • typed Transfer event subscriptions
  • Web3j Unit @EVMTest coverage

It is intentionally a JVM-side starter, not a browser UI. If the user wants an HTTP layer, keep this contract/test flow and add web3j_openapi on top.

Files

  • src/main/solidity/ExampleToken.sol
    • small ERC20-like contract with Transfer and Approval events
  • src/main/java/example/Erc20ExampleApp.java
    • deploys the wrapper, reads token state, performs a transfer, and listens for Transfer events
  • src/test/java/example/Erc20EvmTest.java
    • runs the same pattern under @EVMTest
  • build.gradle
    • applies the Web3j Gradle plugin and fixes generated wrappers to example.contracts

Commands

Run the test path:

sh
./gradlew test

Run the deploy/interact/event path:

sh
WEB3J_PRIVATE_KEY=0xyourprivatekey ./gradlew run

Environment variables

  • WEB3J_HTTP_URL
    • defaults to http://localhost:8545
  • WEB3J_PRIVATE_KEY
    • required for run
  • WEB3J_TOKEN_NAME
    • defaults to Skill Token
  • WEB3J_TOKEN_SYMBOL
    • defaults to SKILL
  • WEB3J_INITIAL_SUPPLY
    • defaults to 1000000
  • WEB3J_TRANSFER_TO
    • defaults to the deployer address so the transfer path can run without a second account
  • WEB3J_TRANSFER_AMOUNT
    • defaults to 1

How companion tools fit

CLI scaffolding:

  • the published CLI docs already expose web3j new, and erc20 is one of the documented templates

Web3j Sokt:

  • the published v5.0.3 docs position Sokt as the direct compiler-resolution and native solc helper
  • the docs-backed shape is SolidityFile -> getCompilerInstance() -> execute(...)
  • this starter keeps the shortest runnable path on the Gradle-plugin side for wrapper generation, and leaves direct Sokt wiring as a follow-on step when the user asks for compiler-management code specifically

Web3j Unit and Web3j EVM:

  • Erc20EvmTest shows the concrete @EVMTest flow documented for Web3j Unit
  • when a user asks about web3j-unit or web3j-evm, point them to the test first because it is the most directly runnable path in this starter

--- METRICS ---