首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用web3j发送以太的问题

用web3j发送以太的问题
EN

Ethereum用户
提问于 2018-12-13 02:29:10
回答 1查看 571关注 0票数 2

大家好,我到处搜索,但没有合理的解释,为什么我会得到这些例外,我已经要求,并与我的地址相关的三个以太。下面是我发送以太的代码:

代码语言:javascript
复制
private static void transferEther(String password)
            throws IOException, CipherException, InterruptedException, TransactionException {
        Web3j web3 = Web3j.build(new HttpService("https://rinkeby.infura.io/v1/<API-KEY>"));

    Web3ClientVersion web3ClientVersion = web3.web3ClientVersion().send();
    String clientVersion = web3ClientVersion.getWeb3ClientVersion();
    System.out.println("Connected to Ethereum client version: " + clientVersion);

    Credentials credentials = WalletUtils.loadCredentials(password,
            new File("/PATH_TO_FILE/"
                    + "UTC--2018-12-12T07-39-27.54000000Z--ff1062eb9f9f4369780f8029fe60a5825eb943c9.json")
                            .toString());

    RemoteCall<TransactionReceipt> transactionReceipt = Transfer.sendFunds(web3, credentials,
            "ADDRESS", BigDecimal.valueOf(0.2), Convert.Unit.ETHER);

    System.out.println("Funds transfer completed, transaction hash: " + transactionReceipt.toString());
}

但我有以下例外:

线程"main“中的异常:rx/调度程序/调度程序在org.web3j.protocol.rx.JsonRpc2_0Rx.(JsonRpc2_0Rx.java:39) at org.web3j.protocol.core.JsonRpc2_0Web3j.(JsonRpc2_0Web3j.java:87) at org.web3j.protocol.core.JsonRpc2_0Web3j.(JsonRpc2_0Web3j.java:80) at org.web3j.protocol.Web3j.build(Web3j.java:21)在CreateWallet.transferEther(CreateWallet.java:51) at CreateWallet.main(( java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) .

EN

回答 1

Ethereum用户

发布于 2018-12-14 07:42:38

万一有人有这个问题,我找到了解决办法。这只是一个代理问题和缺少的库问题。

  1. 添加rxJava、okio和Okhttp库。
  2. 如果你像我一样有代理问题,这个步骤是可选的。字符串主机名= "IP地址“;int端口=端口;代理代理=新代理(Proxy.Type.HTTP,新InetSocketAddress(主机名,端口));OkHttpClient client =新OkHttpClient.Builder().proxy(代理).build();String url = "https://rinkeby.infura.io/v3/";web3 =Web3j.build(url,client,true);
票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/64008

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档