java web3j infura_区块链编程一翻译篇<二>:web3j准备工作

准备工作

将最新版本的web3j加入到项目配置中

Maven

Java 8:

org.web3j

core

2.2.1

Android:

org.web3j

core-android

2.1.0

Gradle

Java 8:

compile ('org.web3j:core:2.2.1')

Android:

compile ('org.web3j:core-android:2.1.0')

启动客户端

如果已经启动客户端,则不需要再次启动。

使用geth脚步进行启动

$ geth --fast --cache=512 --rpcapi personal,db,eth,net,web3 --rpc --testnet

使用Parity启动

$ parity --chain testnet

使用Infura提供的免费客户端启动

Web3j web3 = Web3j.build(new InfuraHttpService("https://morden.infura.io/your-token"));

如果需要详细了解Infura的启动方式,可以阅读Using Infura with web3j。

请求发送

使用Future发送异步请求

Web3j web3 = Web3j.build(new HttpService()); // defaults to http://localhost:8545/

Web3ClientVersion web3ClientVersion = web3.web3Client

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值