Skip to content
A library for running a local Ethereum EVM and ledger in-process
Java Kotlin Shell
Branch: master
Clone or download
cfelde Merge pull request #28 from cfelde/BuildScripts
Build setup: Change kotlin jvm target to 1.8
Latest commit 227481e Dec 5, 2019

web3j-evm Build Status

⚠️ This is a work in progress! ⚠

Web3j-evm is an embedded freestanding Ethereum EVM and ledger running within a Java process, which can be used for unit and integration testing your Web3j projects.

As everything is local and in-process, there is no need to start up external Ethereum nodes, which helps with easy of use and performance.

Everything runs within the JVM process, including EVM bytecode, which allows for easy debugging of for example Solidity smart contracts.

Getting started

Often you'd use this together with the web3j-unit project, allowing you to run unit and integration tests without the need to start an Ethereum node. You do this by using the web3j-unit @EVMTest annotation with NodeType EMBEDDED: @EVMTest(NodeType.EMBEDDED)

If you want to use this within our own project directly, you would need the EVM dependency + a few external libraries. N.B. Only snapshots are available at this time.

repositories {
    maven { url '' }
    maven { url "" }
    maven { url "" }

dependencies {
    implementation "org.web3j:web3j-evm:4.5.8"

Below is a simple demonstration of ETH transactions, contract deployment and simple contract interactions. Using the ConsoleDebugTracer, we're able to step through the EVM bytecode and inspect the stack.

The demo also show to how get started with the EmbeddedWeb3jService which is what you'd use when building your web3j instance.

Credentials credentials = WalletUtils.loadCredentials("Password123", "resources/demo-wallet.json");

// Define our own address and how much ether to prefund this address with
Configuration configuration = new Configuration(new Address(credentials.getAddress()), 10);

// If you don't want console debugging, use PassthroughTracer instead..
OperationTracer operationTracer = new ConsoleDebugTracer();
// OperationTracer operationTracer = new PassthroughTracer();

// We use EmbeddedWeb3jService rather than the usual service implementation..
Web3j web3j = EmbeddedWeb3jService(configuration, operationTracer));

You can’t perform that action at this time.