EthereumJ是以太坊协议的纯Java实现。有关以太坊及其目标的高级信息,请访问ethereum.org,其白皮书提供了一个完整的概念的概述,和黄皮书一起提供了协议的正式定义。
我们尽可能保持EthereumJ简单。对于JSON-RPC支持和其他客户端功能,请看Ethereum Harmony。
运行EthereumJ
作为依赖项添加到Maven项目:
<dependency>
<groupId>org.ethereum</groupId>
<artifactId>ethereumj-core</artifactId>
<version>1.8.1-RELEASE</version>
</dependency>
或者你的Gradle项目:
repositories {
mavenCentral()
jcenter()
maven { url "https://dl.bintray.com/ethereum/maven/" }
}
compile "org.ethereum:ethereumj-core:1.8.+"
作为你项目的起点,任何一个项目都可以以下列方式启动:
git clone https://github.com/ether-camp/ethereumj.starter
./gradlew run
检查你的本地区块链如何同步使用:
curl -w "\n" -X GET http://localhost:8080/bestBlock
构建可执行的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
从命令行运行:
> git clone https://github.com/ethereum/ethereumj
> cd ethereumj
> ./gradlew run [-PmainClass=<sample class>]
可以运行任意一个测试示例:
./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
快照构建
请注意,快照不稳定,目前正在开发中!如果你还想尝试一下:
- 将https://oss.jfrog.org/libs-snapshot/添加为构建脚本的存储库。
- 添加依赖项
org.ethereum:ethereumj-core:${VERSION}
,${VERSION}
位置的值是1.9.0-SNAPSHOT
。
示例如下:
<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.9.0-SNAPSHOT</version>
</dependency>
将项目导入IntelliJ IDEA:
> git clone https://github.com/ethereum/ethereumj
> cd ethereumj
> gradlew build
IDEA:
- File -> New -> Project from existing sources......
- 选择 ethereumj/build.gradle
- 对话框“Import Project from gradle”:点击“ok”
- 在构建之后运行
org.ethereum.Start
,org.ethereum.samples.*
之一或创建自己的主程序。
配置EthereumJ
有关所有现有选项,其描述和默认值的参考,你可以参考默认配置ethereumj.conf
(你可以在jar库或源代码ethereum-core/src/main/resources
目录中找到它),要重新设置所需的选项,你可以使用以下方法之一:
- 把你的选项放到
<working dir>/config/ethereumj.conf
文件中 - 把
user.conf
放到classpath的启动目录中(作为一个资源) - 将你的选项放在任何文件中并通过它提供
-Dethereumj.conf.file=<your config>
- 编程通过
SystemProperties.CONFIG.override*()
使用 - 编程重写Spring
SystemPropertiesbean
来使用
请注意,不需要将所有选项都放在自定义配置中,只需要放置你需要修改的那些选项。
如果你希望尽快的使用java开始以太坊的开发,可以选择web3j类库,它封装实现了绝大部分web3的功能,十分好用:
java以太坊教程,主要是针对java和android程序员进行区块链以太坊开发的web3j详解。
相关推荐
java 以太坊包ethereumj-core 支持解析结构体传参,返回参数。
关于以太坊J是以太坊协议的纯Java实现。 有关以太坊及其目标的高级信息,请访问 。 提供了完整的概念概述,而提供了该协议的正式定义。 我们将以太坊J保持尽可能的薄。 要获得支持和其他客户端功能,请查看 。运行...
ethereumj是以太坊协议的纯Java实现。 有关以太坊及其目标的高级信息,请访问 。 提供了完整的概念概述,而提供了该协议的正式定义。 查看我们的博客 接触 通过与我们聊天 执照 ethereumj是根据发布的。
总结起来,以太坊拥挤者是一个利用Java和ethereumj库来探索以太坊P2P网络的工具。它可以帮助我们了解网络的规模、节点分布和行为模式,为以太坊的开发、优化和研究提供数据支持。通过源代码分析和实际运行,我们可以...
AppCoins-ethereumj-以太坊黄皮书的Java实现 AppCoins-Attention-of-Attention-用于评估注意力证明API可用性的Android项目。 AppCoins概念验证的应用程序宝石-概念验证:使用Aptoide应用程序购买AppCoins中的应用...