Java Code Examples for org.web3j.abi.FunctionEncoder

The following examples show how to use org.web3j.abi.FunctionEncoder. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: besu   Author: hyperledger   File: OnChainPrivacyGroupManagementProxy.java    License: Apache License 2.0 6 votes vote down vote up
public static RemoteCall<OnChainPrivacyGroupManagementProxy> deploy(
    Web3j web3j,
    Credentials credentials,
    ContractGasProvider contractGasProvider,
    String _implementation) {
  String encodedConstructor =
      FunctionEncoder.encodeConstructor(
          Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, _implementation)));
  return deployRemoteCall(
      OnChainPrivacyGroupManagementProxy.class,
      web3j,
      credentials,
      contractGasProvider,
      BINARY,
      encodedConstructor);
}
 
Example #2
Source Project: besu   Author: hyperledger   File: OnChainPrivacyGroupManagementProxy.java    License: Apache License 2.0 6 votes vote down vote up
public static RemoteCall<OnChainPrivacyGroupManagementProxy> deploy(
    Web3j web3j,
    TransactionManager transactionManager,
    ContractGasProvider contractGasProvider,
    String _implementation) {
  String encodedConstructor =
      FunctionEncoder.encodeConstructor(
          Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, _implementation)));
  return deployRemoteCall(
      OnChainPrivacyGroupManagementProxy.class,
      web3j,
      transactionManager,
      contractGasProvider,
      BINARY,
      encodedConstructor);
}
 
Example #3
Source Project: besu   Author: hyperledger   File: OnChainPrivacyGroupManagementProxy.java    License: Apache License 2.0 6 votes vote down vote up
@Deprecated
public static RemoteCall<OnChainPrivacyGroupManagementProxy> deploy(
    Web3j web3j,
    TransactionManager transactionManager,
    BigInteger gasPrice,
    BigInteger gasLimit,
    String _implementation) {
  String encodedConstructor =
      FunctionEncoder.encodeConstructor(
          Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(160, _implementation)));
  return deployRemoteCall(
      OnChainPrivacyGroupManagementProxy.class,
      web3j,
      transactionManager,
      gasPrice,
      gasLimit,
      BINARY,
      encodedConstructor);
}
 
Example #4
Source Project: etherscan-explorer   Author: bing-chou   File: HumanStandardTokenIT.java    License: GNU General Public License v3.0 6 votes vote down vote up
private String execute(
        Credentials credentials, Function function, String contractAddress) throws Exception {
    BigInteger nonce = getNonce(credentials.getAddress());

    String encodedFunction = FunctionEncoder.encode(function);

    RawTransaction rawTransaction = RawTransaction.createTransaction(
            nonce,
            GAS_PRICE,
            GAS_LIMIT,
            contractAddress,
            encodedFunction);

    byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
    String hexValue = Numeric.toHexString(signedMessage);

    EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue)
            .sendAsync().get();

    return transactionResponse.getTransactionHash();
}
 
Example #5
Source Project: etherscan-explorer   Author: bing-chou   File: GreeterContractIT.java    License: GNU General Public License v3.0 6 votes vote down vote up
private String sendCreateContractTransaction() throws Exception {
    BigInteger nonce = getNonce(ALICE.getAddress());

    String encodedConstructor =
            FunctionEncoder.encodeConstructor(Collections.singletonList(new Utf8String(VALUE)));

    Transaction transaction = Transaction.createContractTransaction(
            ALICE.getAddress(),
            nonce,
            GAS_PRICE,
            GAS_LIMIT,
            BigInteger.ZERO,
            getGreeterSolidityBinary() + encodedConstructor);

    org.web3j.protocol.core.methods.response.EthSendTransaction
            transactionResponse = web3j.ethSendTransaction(transaction)
            .sendAsync().get();

    return transactionResponse.getTransactionHash();
}
 
Example #6
Source Project: etherscan-explorer   Author: bing-chou   File: SolidityFunctionWrapper.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static MethodSpec buildDeployWithParams(
        MethodSpec.Builder methodBuilder, String className, String inputParams,
        String authName, boolean isPayable) {

    methodBuilder.addStatement("$T encodedConstructor = $T.encodeConstructor("
                    + "$T.<$T>asList($L)"
                    + ")",
            String.class, FunctionEncoder.class, Arrays.class, Type.class, inputParams);
    if (isPayable) {
        methodBuilder.addStatement(
                "return deployRemoteCall("
                        + "$L.class, $L, $L, $L, $L, $L, encodedConstructor, $L)",
                className, WEB3J, authName, GAS_PRICE, GAS_LIMIT, BINARY, INITIAL_VALUE);
    } else {
        methodBuilder.addStatement(
                "return deployRemoteCall($L.class, $L, $L, $L, $L, $L, encodedConstructor)",
                className, WEB3J, authName, GAS_PRICE, GAS_LIMIT, BINARY);
    }

    return methodBuilder.build();
}
 
Example #7
Source Project: guarda-android-wallets   Author: guardaco   File: SendingTokensActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
private String getContractTransfer() {
    int tokenDecimals = tokensManager.getTokenByCode(tokenCode).getDecimal();
    BigInteger tokenValue = Converter.toDecimals(new BigDecimal(amountToSend), tokenDecimals).toBigInteger();
    List<Type> inputParams = new ArrayList<>();

    Type address = new Address(walletNumber);
    inputParams.add(address);

    Type value = new Uint(tokenValue);
    inputParams.add(value);

    Function function = new Function(
            "transfer",
            inputParams,
            Collections.<TypeReference<?>>emptyList());

    return FunctionEncoder.encode(function);
}
 
Example #8
Source Project: alpha-wallet-android   Author: AlphaWallet   File: TokenRepository.java    License: MIT License 6 votes vote down vote up
private String callSmartContractFunction(
        Function function, String contractAddress, NetworkInfo network, Wallet wallet) throws Exception
{
    try
    {
        String encodedFunction = FunctionEncoder.encode(function);

        org.web3j.protocol.core.methods.request.Transaction transaction
                = createEthCallTransaction(wallet.address, contractAddress, encodedFunction);
        EthCall response = getService(network.chainId).ethCall(transaction, DefaultBlockParameterName.LATEST).send();

        return response.getValue();
    }
    catch (InterruptedIOException|UnknownHostException e)
    {
        //expected to happen when user switches wallets
        return "0x";
    }
}
 
Example #9
Source Project: alpha-wallet-android   Author: AlphaWallet   File: TokenRepository.java    License: MIT License 6 votes vote down vote up
/**
 * Call smart contract function on custom network contract. This would be used for things like ENS lookup
 * Currently because it's tied to a mainnet contract address there's no circumstance it would work
 * outside of mainnet. Users may be confused if their namespace doesn't work, even if they're currently
 * using testnet.
 *
 * @param function
 * @param contractAddress
 * @param wallet
 * @return
 */
private String callCustomNetSmartContractFunction(
        Function function, String contractAddress, Wallet wallet, int chainId)  {
    String encodedFunction = FunctionEncoder.encode(function);

    try
    {
        org.web3j.protocol.core.methods.request.Transaction transaction
                = createEthCallTransaction(wallet.address, contractAddress, encodedFunction);
        EthCall response = getService(chainId).ethCall(transaction, DefaultBlockParameterName.LATEST).send();

        return response.getValue();
    }
    catch (Exception e)
    {
        e.printStackTrace();
        return null;
    }
}
 
Example #10
Source Project: alpha-wallet-android   Author: AlphaWallet   File: TokenRepository.java    License: MIT License 6 votes vote down vote up
public static byte[] createDropCurrency(MagicLinkData order, int v, byte[] r, byte[] s, String recipient)
{
    Function function = new Function(
            "dropCurrency",
            Arrays.asList(new org.web3j.abi.datatypes.generated.Uint32(order.nonce),
                          new org.web3j.abi.datatypes.generated.Uint32(order.amount),
                          new org.web3j.abi.datatypes.generated.Uint32(order.expiry),
                          new org.web3j.abi.datatypes.generated.Uint8(v),
                          new org.web3j.abi.datatypes.generated.Bytes32(r),
                          new org.web3j.abi.datatypes.generated.Bytes32(s),
                          new org.web3j.abi.datatypes.Address(recipient)),
            Collections.emptyList());

    String encodedFunction = FunctionEncoder.encode(function);
    return Numeric.hexStringToByteArray(Numeric.cleanHexPrefix(encodedFunction));
}
 
Example #11
Source Project: alpha-wallet-android   Author: AlphaWallet   File: EnsResolver.java    License: MIT License 6 votes vote down vote up
private String callSmartContractFunction(
        Function function, String contractAddress, int chainId) throws Exception
{
    try
    {
        String encodedFunction = FunctionEncoder.encode(function);

        org.web3j.protocol.core.methods.request.Transaction transaction
                = createEthCallTransaction(TokenscriptFunction.ZERO_ADDRESS, contractAddress, encodedFunction);
        EthCall response = TokenRepository.getWeb3jService(chainId).ethCall(transaction, DefaultBlockParameterName.LATEST).send();

        return response.getValue();
    }
    catch (InterruptedIOException | UnknownHostException e)
    {
        //expected to happen when user switches wallets
        return "0x";
    }
}
 
Example #12
Source Project: web3j   Author: web3j   File: HumanStandardTokenIT.java    License: Apache License 2.0 6 votes vote down vote up
private String execute(Credentials credentials, Function function, String contractAddress)
        throws Exception {
    BigInteger nonce = getNonce(credentials.getAddress());

    String encodedFunction = FunctionEncoder.encode(function);

    RawTransaction rawTransaction =
            RawTransaction.createTransaction(
                    nonce, GAS_PRICE, GAS_LIMIT, contractAddress, encodedFunction);

    byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
    String hexValue = Numeric.toHexString(signedMessage);

    EthSendTransaction transactionResponse =
            web3j.ethSendRawTransaction(hexValue).sendAsync().get();

    return transactionResponse.getTransactionHash();
}
 
Example #13
Source Project: besu   Author: hyperledger   File: CallSmartContractFunction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public EthSendTransaction execute(final NodeRequests node) {
  final Function function =
      new Function(functionName, Collections.emptyList(), Collections.emptyList());
  final RawTransactionManager transactionManager =
      new RawTransactionManager(node.eth(), BENEFACTOR_ONE);
  try {
    return transactionManager.sendTransaction(
        GAS_PRICE, GAS_LIMIT, contractAddress, FunctionEncoder.encode(function), BigInteger.ZERO);
  } catch (IOException e) {
    throw new IllegalStateException(e);
  }
}
 
Example #14
Source Project: Upchain-wallet   Author: xilibi2003   File: TokenRepository.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private String callSmartContractFunction(
        org.web3j.abi.datatypes.Function function, String contractAddress, String walletAddress) throws Exception {
    String encodedFunction = FunctionEncoder.encode(function);

    org.web3j.protocol.core.methods.response.EthCall response = web3j.ethCall(
            Transaction.createEthCallTransaction(walletAddress, contractAddress, encodedFunction),
            DefaultBlockParameterName.LATEST)
            .sendAsync().get();

    return response.getValue();
}
 
Example #15
Source Project: Upchain-wallet   Author: xilibi2003   File: TokenRepository.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static String createTokenTransferData(String to, BigInteger tokenAmount) {
        List<Type> params = Arrays.<Type>asList(new Address(to), new Uint256(tokenAmount));

        List<TypeReference<?>> returnTypes = Arrays.<TypeReference<?>>asList(new TypeReference<Bool>() {
        });

        Function function = new Function("transfer", params, returnTypes);
        return FunctionEncoder.encode(function);
//        return Numeric.hexStringToByteArray(Numeric.cleanHexPrefix(encodedFunction));
    }
 
Example #16
Source Project: client-sdk-java   Author: PlatONnetwork   File: SolidityFunctionWrapper.java    License: Apache License 2.0 5 votes vote down vote up
private static MethodSpec buildDeployWithParams(
        MethodSpec.Builder methodBuilder, String className, String inputParams,
        String authName, boolean isPayable, boolean withGasProvider) {

    methodBuilder.addStatement("$T encodedConstructor = $T.encodeConstructor("
                    + "$T.<$T>asList($L)"
                    + ")",
            String.class, FunctionEncoder.class, Arrays.class, Type.class, inputParams);
    if (isPayable && !withGasProvider) {
        methodBuilder.addStatement(
                "return deployRemoteCall("
                        + "$L.class, $L, $L, $L, $L, $L, encodedConstructor, $L)",
                className, WEB3J, authName, GAS_PRICE, GAS_LIMIT, BINARY, INITIAL_VALUE);
        methodBuilder.addAnnotation(Deprecated.class);
    } else if (isPayable && withGasProvider) {
        methodBuilder.addStatement(
                "return deployRemoteCall("
                        + "$L.class, $L, $L, $L, $L, encodedConstructor, $L)",
                className, WEB3J, authName, CONTRACT_GAS_PROVIDER, BINARY, INITIAL_VALUE);
    } else if (!isPayable && !withGasProvider) {
        methodBuilder.addStatement(
                "return deployRemoteCall($L.class, $L, $L, $L, $L, $L, encodedConstructor)",
                className, WEB3J, authName, GAS_PRICE, GAS_LIMIT, BINARY);
        methodBuilder.addAnnotation(Deprecated.class);
    } else {
        methodBuilder.addStatement(
                "return deployRemoteCall($L.class, $L, $L, $L, $L, encodedConstructor)",
                className, WEB3J, authName, CONTRACT_GAS_PROVIDER, BINARY);
    }

    return methodBuilder.build();
}
 
Example #17
Source Project: client-sdk-java   Author: PlatONnetwork   File: Contract.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Execute constant function call - i.e. a call that does not change state of the contract
 *
 * @param function to call
 * @return {@link List} of values returned by function call
 */
private List<Type> executeCall(
        Function function) throws IOException {
    String encodedFunction = FunctionEncoder.encode(function);
    PlatonCall ethCall = web3j.platonCall(
            Transaction.createEthCallTransaction(
                    transactionManager.getFromAddress(), contractAddress, encodedFunction),
            defaultBlockParameter)
            .send();

    String value = ethCall.getValue();
    return FunctionReturnDecoder.decode(value, function.getOutputParameters());
}
 
Example #18
Source Project: client-sdk-java   Author: PlatONnetwork   File: ContractTest.java    License: Apache License 2.0 5 votes vote down vote up
private Contract deployContract(TransactionReceipt transactionReceipt)
        throws Exception {

    prepareTransaction(transactionReceipt);

    String encodedConstructor = FunctionEncoder.encodeConstructor(
            Arrays.<Type>asList(new Uint256(BigInteger.TEN)));

    return TestContract.deployRemoteCall(
            TestContract.class, web3j, getVerifiedTransactionManager(SampleKeys.CREDENTIALS),
            ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT,
            "0xcafed00d", encodedConstructor, BigInteger.ZERO).send();
}
 
Example #19
Source Project: web3j   Author: web3j   File: HumanStandardToken.java    License: Apache License 2.0 5 votes vote down vote up
@Deprecated
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger _initialAmount, String _tokenName, BigInteger _decimalUnits, String _tokenSymbol) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_initialAmount),
            new org.web3j.abi.datatypes.Utf8String(_tokenName),
            new org.web3j.abi.datatypes.generated.Uint8(_decimalUnits),
            new org.web3j.abi.datatypes.Utf8String(_tokenSymbol)));
    return deployRemoteCall(HumanStandardToken.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example #20
Source Project: client-sdk-java   Author: PlatONnetwork   File: HumanStandardToken.java    License: Apache License 2.0 5 votes vote down vote up
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, TransactionManager transactionManager, GasProvider contractGasProvider,
		BigInteger _initialAmount, String _tokenName, BigInteger _decimalUnits, String _tokenSymbol) {
	String encodedConstructor = FunctionEncoder.encodeConstructor(
			Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_initialAmount), new org.web3j.abi.datatypes.Utf8String(_tokenName),
					new org.web3j.abi.datatypes.generated.Uint8(_decimalUnits), new org.web3j.abi.datatypes.Utf8String(_tokenSymbol)));
	return deployRemoteCall(HumanStandardToken.class, web3j, transactionManager, contractGasProvider, BINARY, encodedConstructor);
}
 
Example #21
Source Project: web3j   Author: web3j   File: HumanStandardToken.java    License: Apache License 2.0 5 votes vote down vote up
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider, BigInteger _initialAmount, String _tokenName, BigInteger _decimalUnits, String _tokenSymbol) {
    String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_initialAmount),
            new org.web3j.abi.datatypes.Utf8String(_tokenName),
            new org.web3j.abi.datatypes.generated.Uint8(_decimalUnits),
            new org.web3j.abi.datatypes.Utf8String(_tokenSymbol)));
    return deployRemoteCall(HumanStandardToken.class, web3j, credentials, contractGasProvider, BINARY, encodedConstructor);
}
 
Example #22
Source Project: client-sdk-java   Author: PlatONnetwork   File: HumanStandardToken.java    License: Apache License 2.0 5 votes vote down vote up
@Deprecated
public static RemoteCall<HumanStandardToken> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit,
		BigInteger _initialAmount, String _tokenName, BigInteger _decimalUnits, String _tokenSymbol) {
	String encodedConstructor = FunctionEncoder.encodeConstructor(
			Arrays.<Type>asList(new org.web3j.abi.datatypes.generated.Uint256(_initialAmount), new org.web3j.abi.datatypes.Utf8String(_tokenName),
					new org.web3j.abi.datatypes.generated.Uint8(_decimalUnits), new org.web3j.abi.datatypes.Utf8String(_tokenSymbol)));
	return deployRemoteCall(HumanStandardToken.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor);
}
 
Example #23
Source Project: client-sdk-java   Author: PlatONnetwork   File: PayWages.java    License: Apache License 2.0 5 votes vote down vote up
@Deprecated
public static RemoteCall<PayWages> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit,
		BigInteger initialWeiValue, String _personnel, String _financer) {
	String encodedConstructor = FunctionEncoder.encodeConstructor(
			Arrays.<Type>asList(new org.web3j.abi.datatypes.Address(_personnel), new org.web3j.abi.datatypes.Address(_financer)));
	return deployRemoteCall(PayWages.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialWeiValue);
}
 
Example #24
Source Project: ETHWallet   Author: snailflying   File: TokenRepository.java    License: GNU General Public License v3.0 5 votes vote down vote up
private String callSmartContractFunction(
        org.web3j.abi.datatypes.Function function, String contractAddress, Wallet wallet) throws Exception {
    String encodedFunction = FunctionEncoder.encode(function);

    Log.d("aaron", "address:" + wallet.getAddress());
    org.web3j.protocol.core.methods.response.EthCall response = web3j.ethCall(
            Transaction.createEthCallTransaction(wallet.getAddress(), contractAddress, encodedFunction),
            DefaultBlockParameterName.LATEST)
            .sendAsync().get();

    return response.getValue();
}
 
Example #25
Source Project: etherscan-explorer   Author: bing-chou   File: HumanStandardTokenIT.java    License: GNU General Public License v3.0 5 votes vote down vote up
private String sendCreateContractTransaction(
        Credentials credentials, BigInteger initialSupply) throws Exception {
    BigInteger nonce = getNonce(credentials.getAddress());

    String encodedConstructor =
            FunctionEncoder.encodeConstructor(
                    Arrays.asList(
                            new Uint256(initialSupply),
                            new Utf8String("web3j tokens"),
                            new Uint8(BigInteger.TEN),
                            new Utf8String("w3j$")));

    RawTransaction rawTransaction = RawTransaction.createContractTransaction(
            nonce,
            GAS_PRICE,
            GAS_LIMIT,
            BigInteger.ZERO,
            getHumanStandardTokenBinary() + encodedConstructor);

    byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
    String hexValue = Numeric.toHexString(signedMessage);

    EthSendTransaction transactionResponse = web3j.ethSendRawTransaction(hexValue)
            .sendAsync().get();

    return transactionResponse.getTransactionHash();
}
 
Example #26
Source Project: etherscan-explorer   Author: bing-chou   File: HumanStandardTokenIT.java    License: GNU General Public License v3.0 5 votes vote down vote up
private String callSmartContractFunction(
        Function function, String contractAddress) throws Exception {
    String encodedFunction = FunctionEncoder.encode(function);

    org.web3j.protocol.core.methods.response.EthCall response = web3j.ethCall(
            Transaction.createEthCallTransaction(
                    ALICE.getAddress(), contractAddress, encodedFunction),
            DefaultBlockParameterName.LATEST)
            .sendAsync().get();

    return response.getValue();
}
 
Example #27
Source Project: etherscan-explorer   Author: bing-chou   File: DeployContractIT.java    License: GNU General Public License v3.0 5 votes vote down vote up
private String callSmartContractFunction(
        Function function, String contractAddress) throws Exception {

    String encodedFunction = FunctionEncoder.encode(function);

    org.web3j.protocol.core.methods.response.EthCall response = web3j.ethCall(
            Transaction.createEthCallTransaction(
                    ALICE.getAddress(), contractAddress, encodedFunction),
            DefaultBlockParameterName.LATEST)
            .sendAsync().get();

    return response.getValue();
}
 
Example #28
Source Project: etherscan-explorer   Author: bing-chou   File: GreeterContractIT.java    License: GNU General Public License v3.0 5 votes vote down vote up
private String callSmartContractFunction(
        Function function, String contractAddress) throws Exception {

    String encodedFunction = FunctionEncoder.encode(function);

    org.web3j.protocol.core.methods.response.EthCall response = web3j.ethCall(
            Transaction.createEthCallTransaction(
                    ALICE.getAddress(), contractAddress, encodedFunction),
            DefaultBlockParameterName.LATEST)
            .sendAsync().get();

    return response.getValue();
}
 
Example #29
Source Project: web3j   Author: web3j   File: DeployContractIT.java    License: Apache License 2.0 5 votes vote down vote up
private String callSmartContractFunction(Function function, String contractAddress)
        throws Exception {

    String encodedFunction = FunctionEncoder.encode(function);

    org.web3j.protocol.core.methods.response.EthCall response =
            web3j.ethCall(
                            Transaction.createEthCallTransaction(
                                    ALICE.getAddress(), contractAddress, encodedFunction),
                            DefaultBlockParameterName.LATEST)
                    .sendAsync()
                    .get();

    return response.getValue();
}
 
Example #30
Source Project: etherscan-explorer   Author: bing-chou   File: Contract.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Execute constant function call - i.e. a call that does not change state of the contract
 *
 * @param function to call
 * @return {@link List} of values returned by function call
 */
private List<Type> executeCall(
        Function function) throws IOException {
    String encodedFunction = FunctionEncoder.encode(function);
    org.web3j.protocol.core.methods.response.EthCall ethCall = web3j.ethCall(
            Transaction.createEthCallTransaction(
                    transactionManager.getFromAddress(), contractAddress, encodedFunction),
            defaultBlockParameter)
            .send();

    String value = ethCall.getValue();
    return FunctionReturnDecoder.decode(value, function.getOutputParameters());
}