org.web3j.abi.datatypes.Address.getValue()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.web3j.abi.datatypes.Address.getValue()方法的一些代码示例,展示了Address.getValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getValue()方法的具体详情如下:
包路径:org.web3j.abi.datatypes.Address
类名称:Address
方法名:getValue

Address.getValue介绍

暂无

代码示例

代码示例来源:origin: AppStoreFoundation/asf-sdk

@Override public Observable<Long> getNonce(Address address) {
 return Observable.fromCallable(
   () -> web3j.ethGetTransactionCount(address.getValue(), DefaultBlockParameterName.PENDING)
     .send())
   .map(ethGetTransactionCount -> ethGetTransactionCount.getTransactionCount()
     .longValue());
}

代码示例来源:origin: AppStoreFoundation/asf-sdk

@Override
public String getContractAddressById(String fromAddress, int chainId, String contractId) {
 List<Type> arguments = new ArrayList<>();
 List<TypeReference<?>> returnValues = new ArrayList<>();
 returnValues.add(new TypeReference<Address>() {
 });
 arguments.add(stringToBytes32(contractId));
 Function getContractAddressById =
   new Function("getContractAddressById", arguments, returnValues);
 String encodedFunction = FunctionEncoder.encode(getContractAddressById);
 Transaction ethCallTransaction = createEthCallTransaction(fromAddress,
   proxyContractAddressProvider.getProxyContractAddress(chainId), encodedFunction);
 try {
  EthCall rawResponse = web3jProvider.get(chainId)
    .ethCall(ethCallTransaction, DefaultBlockParameterName.LATEST)
    .send();
  if (!rawResponse.hasError()) {
   List<Type> response = FunctionReturnDecoder.decode(rawResponse.getValue(),
     getContractAddressById.getOutputParameters());
   return ((Address) response.get(0)).getValue();
  } else {
   throw new RuntimeException(mapErrorToMessage(rawResponse.getError()));
  }
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

相关文章