Convert Figma logo to code with AI

ethereum logoethereumj

DEPRECATED! Java implementation of the Ethereum yellowpaper. For JSON-RPC and other client features check Ethereum Harmony

2,178
1,097
2,178
92

Top Related Projects

Go implementation of the Ethereum protocol

The fast, light, and robust client for Ethereum-like networks.

1,474

An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu

2,249

A Python implementation of the Ethereum Virtual Machine

Quick Overview

EthereumJ is a pure Java implementation of the Ethereum protocol. It provides a complete Ethereum client and library, allowing developers to interact with the Ethereum network, create and deploy smart contracts, and build decentralized applications using Java.

Pros

  • Written in Java, providing easy integration with existing Java projects and ecosystems
  • Supports both full and light client modes for different use cases
  • Includes a comprehensive test suite for ensuring reliability and compatibility
  • Actively maintained and regularly updated to keep up with Ethereum protocol changes

Cons

  • May have slower performance compared to native implementations like Go-Ethereum
  • Limited documentation and community support compared to more popular Ethereum clients
  • Potential for version incompatibilities with the main Ethereum network during rapid protocol changes
  • Steeper learning curve for developers not familiar with Java or Ethereum concepts

Code Examples

  1. Connecting to the Ethereum network:
EthereumFacade ethereum = EthereumFactory.createEthereum();
ethereum.addListener(new EthereumListenerAdapter() {
    @Override
    public void onSyncDone(SyncState state) {
        System.out.println("Sync done: " + state);
    }
});
  1. Sending a transaction:
BigInteger nonce = ethereum.getNonce(senderAddress);
Transaction tx = new TransactionBuilder()
    .sender(senderAddress)
    .nonce(nonce)
    .recipient(recipientAddress)
    .value(BigInteger.valueOf(1_000_000_000_000_000_000L)) // 1 ETH
    .buildTransaction();

ethereum.submitTransaction(tx);
  1. Deploying a smart contract:
String contractSource = "pragma solidity ^0.8.0; contract SimpleStorage { uint256 public value; function setValue(uint256 _value) public { value = _value; } }";
SolidityCompiler.Result result = SolidityCompiler.compile(contractSource.getBytes(), true, SolidityCompiler.Options.ABI, SolidityCompiler.Options.BIN);
CompilationResult compilationResult = CompilationResult.parse(result.output);
CompilationResult.ContractMetadata metadata = compilationResult.getContract("SimpleStorage");

Transaction tx = ethereum.createContractTransaction(senderAddress, BigInteger.ZERO, metadata.bin);
ethereum.submitTransaction(tx);

Getting Started

To start using EthereumJ in your Java project:

  1. Add the EthereumJ dependency to your pom.xml file:
<dependency>
    <groupId>org.ethereum</groupId>
    <artifactId>ethereumj-core</artifactId>
    <version>1.12.0-RELEASE</version>
</dependency>
  1. Create an instance of the Ethereum facade:
EthereumFacade ethereum = EthereumFactory.createEthereum();
  1. Start syncing with the Ethereum network:
ethereum.addListener(new EthereumListenerAdapter() {
    @Override
    public void onSyncDone(SyncState state) {
        System.out.println("Sync complete. Current block: " + ethereum.getBlockchain().getBestBlock().getNumber());
    }
});

Now you're ready to interact with the Ethereum network using EthereumJ!

Competitor Comparisons

Go implementation of the Ethereum protocol

Pros of go-ethereum

  • Written in Go, offering better performance and concurrency handling
  • More actively maintained with frequent updates and larger community support
  • Official implementation by the Ethereum Foundation, ensuring compatibility

Cons of go-ethereum

  • Steeper learning curve for developers not familiar with Go
  • Larger codebase, potentially more complex for newcomers to navigate

Code Comparison

ethereumj (Java):

public class Block {
    private BlockHeader header;
    private List<Transaction> transactionsList = new ArrayList<>();
    private List<BlockHeader> uncleList = new ArrayList<>();
    // ...
}

go-ethereum (Go):

type Block struct {
    header       *Header
    uncles       []*Header
    transactions Transactions
    // ...
}

Key Differences

  • ethereumj is written in Java, while go-ethereum is implemented in Go
  • go-ethereum has more active development and a larger community
  • ethereumj may be easier for Java developers to understand and contribute to
  • go-ethereum is the official Ethereum implementation, ensuring better compatibility with the network
  • Both implementations provide similar core functionality, but go-ethereum often receives updates and new features earlier

Conclusion

While both repositories serve as Ethereum clients, go-ethereum is generally considered the primary implementation due to its official status, active development, and performance benefits. However, ethereumj may still be valuable for Java-based projects or developers more comfortable with the Java ecosystem.

The fast, light, and robust client for Ethereum-like networks.

Pros of parity-ethereum

  • Written in Rust, offering better performance and memory safety
  • More actively maintained with frequent updates
  • Supports light client functionality for resource-constrained devices

Cons of parity-ethereum

  • Steeper learning curve due to Rust language
  • Smaller community compared to Java-based implementations

Code Comparison

ethereumj (Java):

public class Block {
    private BlockHeader header;
    private List<Transaction> transactions;
    private List<BlockHeader> uncles;
    // ...
}

parity-ethereum (Rust):

pub struct Block {
    pub header: Header,
    pub transactions: Vec<SignedTransaction>,
    pub uncles: Vec<Header>,
    // ...
}

Key Differences

  • Language: ethereumj uses Java, while parity-ethereum uses Rust
  • Performance: parity-ethereum generally offers better performance due to Rust's efficiency
  • Community: ethereumj has a larger Java developer community, while parity-ethereum attracts Rust enthusiasts
  • Maintenance: parity-ethereum is more actively maintained and updated
  • Features: parity-ethereum supports light clients, which ethereumj lacks

Both implementations serve as Ethereum clients, but parity-ethereum is generally considered more modern and efficient. However, ethereumj may be easier for Java developers to understand and contribute to. The choice between them often depends on specific project requirements and developer expertise.

1,474

An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu

Pros of Besu

  • More active development and larger community support
  • Better performance and scalability for enterprise use cases
  • Supports both public and private Ethereum networks

Cons of Besu

  • Steeper learning curve due to more complex architecture
  • Requires more system resources compared to EthereumJ

Code Comparison

EthereumJ:

public class BlockchainImpl implements Blockchain {
    @Autowired
    private Repository repository;
    
    @Autowired
    private BlockStore blockStore;
    
    // ... other code
}

Besu:

public class DefaultBlockchain implements MutableBlockchain {
    private final BlockchainStorage blockchainStorage;
    private final BlockValidator blockValidator;
    private final ConsensusContext consensusContext;
    
    // ... other code
}

Both implementations use dependency injection and follow similar architectural patterns. However, Besu's codebase is generally more modular and extensible, reflecting its focus on enterprise-grade solutions.

Besu offers more comprehensive documentation and a wider range of features, making it suitable for larger-scale projects. EthereumJ, while simpler, may be more appropriate for smaller projects or educational purposes.

Overall, Besu is the more robust and actively maintained option, but EthereumJ still has its place in certain use cases where simplicity is preferred.

2,249

A Python implementation of the Ethereum Virtual Machine

Pros of py-evm

  • Written in Python, making it more accessible for developers familiar with the language
  • Actively maintained with regular updates and improvements
  • Designed with modularity in mind, allowing for easier customization and extension

Cons of py-evm

  • Generally slower performance compared to Java-based implementations
  • Less mature and battle-tested in production environments
  • Smaller community and ecosystem compared to Java alternatives

Code Comparison

py-evm (Python):

class BaseVM:
    def apply_transaction(self, transaction):
        # Transaction application logic
        pass

    def execute_bytecode(self, code, context):
        # Bytecode execution logic
        pass

ethereumj (Java):

public class VM {
    public void applyTransaction(Transaction tx) {
        // Transaction application logic
    }

    public void executeCode(byte[] code, ExecutionContext ctx) {
        // Bytecode execution logic
    }
}

Both implementations provide similar core functionality for applying transactions and executing bytecode, but with language-specific syntax and conventions. The py-evm code uses Python classes and methods, while ethereumj uses Java classes and methods. The overall structure and purpose of the code remain similar between the two projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Welcome to ethereumj

Gitter Build Status Coverage Status

:no_entry: Deprecated :no_entry:

This project is not supported anymore. If you have any question or would like to contribute find us on Gitter.

About

EthereumJ is a pure-Java implementation of the Ethereum protocol. For high-level information about Ethereum and its goals, visit ethereum.org. The ethereum white paper provides a complete conceptual overview, and the yellow paper provides a formal definition of the protocol.

We keep EthereumJ as thin as possible. For JSON-RPC support and other client features check Ethereum Harmony.

Running EthereumJ

Adding as a dependency to your Maven project:
   <dependency>
     <groupId>org.ethereum</groupId>
     <artifactId>ethereumj-core</artifactId>
     <version>1.12.0-RELEASE</version>
   </dependency>
or your Gradle project:
   repositories {
       mavenCentral()
       jcenter()
       maven { url "https://dl.bintray.com/ethereum/maven/" }
   }
   implementation "org.ethereum:ethereumj-core:1.9.+"

As a starting point for your own project take a look at https://github.com/ether-camp/ethereumj.starter

Building an executable JAR
git clone https://github.com/ethereum/ethereumj
cd ethereumj
cp ethereumj-core/src/main/resources/ethereumj.conf ethereumj-core/src/main/resources/user.conf
vim ethereumj-core/src/main/resources/user.conf # adjust user.conf to your needs
./gradlew clean fatJar
java -jar ethereumj-core/build/libs/ethereumj-core-*-all.jar
Running from command line:
> git clone https://github.com/ethereum/ethereumj
> cd ethereumj
> ./gradlew run [-PmainClass=<sample class>]
Optional samples to try:
./gradlew run -PmainClass=org.ethereum.samples.BasicSample
./gradlew run -PmainClass=org.ethereum.samples.FollowAccount
./gradlew run -PmainClass=org.ethereum.samples.PendingStateSample
./gradlew run -PmainClass=org.ethereum.samples.PriceFeedSample
./gradlew run -PmainClass=org.ethereum.samples.PrivateMinerSample
./gradlew run -PmainClass=org.ethereum.samples.TestNetSample
./gradlew run -PmainClass=org.ethereum.samples.TransactionBomb
For snapshot builds:

Please, note, snapshots are not stable and are currently in development! If you still want to try it:

  • Add https://oss.jfrog.org/libs-snapshot/ as a repository to your build script
  • Add a dependency on org.ethereum:ethereumj-core:${VERSION}, where ${VERSION} is of the form 1.13.0-SNAPSHOT.

Example:

<repository>
    <id>jfrog-snapshots</id>
    <name>oss.jfrog.org</name>
    <url>https://oss.jfrog.org/libs-snapshot/</url>
    <snapshots><enabled>true</enabled></snapshots>
</repository>
<!-- ... -->
<dependency>
   <groupId>org.ethereum</groupId>
   <artifactId>ethereumj-core</artifactId>
   <version>1.13.0-SNAPSHOT</version>
</dependency>
Importing project to IntelliJ IDEA:
> git clone https://github.com/ethereum/ethereumj
> cd ethereumj
> gradlew build

IDEA:

  • File -> New -> Project from existing sources…
  • Select ethereumj/build.gradle
  • Dialog “Import Project from gradle”: press “OK”
  • After building run either org.ethereum.Start, one of org.ethereum.samples.* or create your own main.

Configuring EthereumJ

For reference on all existing options, their description and defaults you may refer to the default config ethereumj.conf (you may find it in either the library jar or in the source tree ethereum-core/src/main/resources) To override needed options you may use one of the following ways:

  • put your options to the <working dir>/config/ethereumj.conf file
  • put user.conf to the root of your classpath (as a resource)
  • put your options to any file and supply it via -Dethereumj.conf.file=<your config>, accepts several configs, separated by comma applied in provided order: -Dethereumj.conf.file=<config1>,<config2>
  • programmatically by using SystemProperties.CONFIG.override*()
  • programmatically using by overriding Spring SystemProperties bean

Note that don’t need to put all the options to your custom config, just those you want to override.

Special thanks

YourKit for providing us with their nice profiler absolutely for free.

YourKit supports open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of YourKit Java Profiler and YourKit .NET Profiler, innovative and intelligent tools for profiling Java and .NET applications.

YourKit Logo

Contact

Chat with us via Gitter

License

ethereumj is released under the LGPL-V3 license.