# Technical Documentation: LFDT-web3j/web3j

> ℹ️ **Provenance:** Multi-Tier Ingestion · [CodeWiki Reference](https://codewiki.google/github.com/LFDT-web3j/web3j)

### Overview (`README.md`)

Web3j: Web3 Java Ethereum Dapp API
==================================

[](https://docs.web3j.io)
[](https://github.com/web3j/web3j/actions/workflows/build.yml)
[](https://codecov.io/gh/web3j/web3j)
[](https://discord.gg/A9UXfPF2tS)
[](https://gurubase.io/g/web3j)


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](https://www.ethereum.org/)
blockchain, without the additional overhead of having to write your own
integration code for the platform.

The [Java and the Blockchain](https://www.youtube.com/watch?v=ea3miXs_P6Y) 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!
- [Community Link](https://lists.hyperledger.org/g/web3j) - Check our last updates! 
- [Calendar Invite](https://lists.hyperledger.org/g/web3j/ics/invite.ics?repeatid=57401) - Add the contributor call to your calendar!

Features
--------

-   Complete implementation of Ethereum's
    [JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/) client
    API over HTTP and IPC
-   Ethereum wallet support
-   Auto-generation of Java smart contract wrappers to create, deploy,
    transact with and call smart contracts from native Java code
    ([Solidity](http://solidity.readthedocs.io/en/latest/using-the-compiler.html#using-the-commandline-compiler)
    and
    [Truffle](https://github.com/trufflesuite/truffle-contract-schema)
    definition formats supported)
-   Reactive-functional API for working with filters
-   [Ethereum Name Service (ENS)](https://ens.domains/) support
-   Support for Parity's
    [Personal](https://github.com/paritytech/parity/wiki/JSONRPC-personal-module),
    and Geth's
    [Personal](https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal)
    client APIs
-   Support for [Alchemy](https://docs.alchemyapi.io/alchemy/guides/getting-started#web-3-j) and [Infura](https://infura.io/), so you don't have to run
    an Ethereum client yourself
-   Comprehensive integration tests demonstrating a number of the above
    scenarios
-   Command line tools
-   Android compatible
-   Support for JP Morgan's Quorum via
    [web3j-quorum](https://github.com/web3j/quorum)
-   Support for [EEA Privacy features as described in EEA
    documentation](https://entethalliance.org/technical-documents/) and
    implemented in [Hyperledger
    Besu](https://besu.hyperledger.org/private-networks/reference/api#eea-methods).

It has five runtime dependencies:

-   [RxJava](https://github.com/ReactiveX/RxJava) for its
    reactive-functional API
-   [OKHttp](https://square.github.io/okhttp/)
    for HTTP connections
-   [Jackson Core](https://github.com/FasterXML/jackson-core) for fast
    JSON serialisation/deserialization
-   [Bouncy Castle](https://www.bouncycastle.org/) for
    crypto
-   [Jnr-unixsocket](https://github.com/jnr/jnr-unixsocket) for \*nix
    IPC (not available on Android)
-   [Java-WebSocket](https://github.com/TooTallNate/Java-WebSocket)

It also uses [JavaPoet](https://github.com/square/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](http://docs.web3j.io/latest/command_line_tools/). 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](https://github.com/web3j/web3j-maven-plugin) or 
[Gradle](https://github.com/web3j/web3j-gradle-plugin) 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](https://github.com/docker-java/docker-java/blob/master/docs/getting_started.md#instantiating-a-dockerclientconfig)
for more information on configuration options.


Projects using Web3j
------------------

<a href="https://alphawallet.com/">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/alphawallet-dark.svg">
    <img alt="Alphawallet logo" src="static-imgs/alphawallet-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://linea.build">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/linea-dark.svg">
    <img alt="Linea logo" src="static-imgs/linea-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://consensys.io/">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/consensys-dark.svg">
    <img alt="ConsenSys logo" src="static-imgs/consensys-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://ens.domains">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/ens-dark.svg">
    <img alt="ENS logo" src="static-imgs/ens-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://github.com/hyperledger/besu">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/hyperledger-besu-dark.svg">
    <img alt="Hyperledger Besu logo" src="static-imgs/hyperledger-besu-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://web3auth.io">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/web3auth_dark.svg">
    <img alt="Web3Auth logo" src="static-imgs/web3auth_light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://hedera.com">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/hedera-dark.svg">
    <img alt="Hedera logo" src="static-imgs/hedera-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://celo.org">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/celo-dark.svg">
    <img alt="Celo logo" src="static-imgs/celo-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://explorer.walletconnect.com/">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/walletconnect-dark.svg">
    <img alt="WalletConnect logo" src="static-imgs/walletconnect-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://argent.xyz">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/argent-dark.svg">
    <img alt="Argent logo" src="static-imgs/argent-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://unstoppabledomains.com">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/unstoppable_domains-dark.svg">
    <img alt="Unstoppable Domains logo" src="static-imgs/unstoppable_domains-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://www.fnality.org/home">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/fnality-dark.svg">
    <img alt="Fnality logo" src="static-imgs/fnality-light.svg" width="auto" height="50">
  </picture>
</a>

<a href="https://zksync.io/">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="static-imgs/zksync-dark.svg">
    <img alt="zksync logo" src="static-imgs/zksync-light.svg" width="auto" height="50">
  </picture>
</a>

Commercial support and training
-------------------------------

Commercial support and training is available from
[web3labs.com](https://www.web3labs.com/web3j-sdk).

License
------
Apache 2.0

---

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

# CI containment for the eMudhra certificate incident

Following [Oracle guidance](https://ops.java/emudhra), 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](https://github.com/galadran/we-have-a-problem.com/tree/954b49d8a5735beb08889687c1d9d549e7c37ebe/chains). 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 ---
- Files Extracted: 5
- Estimated Token Budget: ~3997 tokens
- Canonical Reference: https://codewiki.google/github.com/LFDT-web3j/web3j
