Package org.stellar.sdk.contract
Class ContractClient
java.lang.Object
org.stellar.sdk.contract.ContractClient
- All Implemented Interfaces:
Closeable,AutoCloseable
A client to interact with Soroban smart contracts.
This client is a wrapper for SorobanServer and TransactionBuilder to make it
easier to interact with Soroban smart contracts. If you need more fine-grained control, please
consider using them directly.
-
Constructor Summary
ConstructorsConstructorDescriptionContractClient(String contractId, String rpcUrl, Network network) Creates a newContractClientwith the given contract ID, RPC URL, and network. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()<T> AssembledTransaction<T> invoke(String functionName, Collection<SCVal> parameters, String source, KeyPair signer, Function<SCVal, T> parseResultXdrFn, int baseFee, int transactionTimeout, int submitTimeout, boolean simulate, boolean restore) Build anAssembledTransactionto invoke a function on the contract.<T> AssembledTransaction<T> invoke(String functionName, List<SCVal> parameters, String source, KeyPair signer, Function<SCVal, T> parseResultXdrFn, int baseFee) Build anAssembledTransactionto invoke a function on the contract.
-
Constructor Details
-
ContractClient
Creates a newContractClientwith the given contract ID, RPC URL, and network.- Parameters:
contractId- The contract ID to interact with.rpcUrl- The RPC URL of the Soroban server.network- The network to interact with.
-
-
Method Details
-
invoke
public <T> AssembledTransaction<T> invoke(String functionName, List<SCVal> parameters, String source, KeyPair signer, Function<SCVal, T> parseResultXdrFn, int baseFee) Build anAssembledTransactionto invoke a function on the contract.An alias for
invoke(String, Collection, String, KeyPair, Function, int, int, int, boolean, boolean).- Parameters:
functionName- The name of the function to invoke.parameters- The parameters to pass to the function.source- The source account to use for the transaction.signer- The key pair to sign the transaction with.parseResultXdrFn- A function to parse the result XDR of the transaction.baseFee- The base fee for the transaction.
-
invoke
public <T> AssembledTransaction<T> invoke(String functionName, Collection<SCVal> parameters, String source, @Nullable KeyPair signer, @Nullable Function<SCVal, T> parseResultXdrFn, int baseFee, int transactionTimeout, int submitTimeout, boolean simulate, boolean restore) Build anAssembledTransactionto invoke a function on the contract.- Parameters:
functionName- The name of the function to invoke.parameters- The parameters to pass to the function.source- The source account to use for the transaction.signer- The key pair to sign the transaction with.parseResultXdrFn- A function to parse the result XDR of the transaction.baseFee- The base fee for the transaction.transactionTimeout- The timeout for the transaction.submitTimeout- The timeout for submitting the transaction.simulate- Whether to simulate the transaction.restore- Whether to restore the transaction, only valid whensimulateistrue, and the signer is provided.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-