public class ContractClient
extends java.lang.Object
implements java.io.Closeable
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 and Description |
---|
ContractClient(java.lang.String contractId,
java.lang.String rpcUrl,
Network network)
Creates a new
ContractClient with the given contract ID, RPC URL, and network. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
<T> AssembledTransaction<T> |
invoke(java.lang.String functionName,
java.util.Collection<SCVal> parameters,
java.lang.String source,
KeyPair signer,
java.util.function.Function<SCVal,T> parseResultXdrFn,
int baseFee,
int transactionTimeout,
int submitTimeout,
boolean simulate,
boolean restore)
Build an
AssembledTransaction to invoke a function on the contract. |
<T> AssembledTransaction<T> |
invoke(java.lang.String functionName,
java.util.List<SCVal> parameters,
java.lang.String source,
KeyPair signer,
java.util.function.Function<SCVal,T> parseResultXdrFn,
int baseFee)
Build an
AssembledTransaction to invoke a function on the contract. |
public ContractClient(java.lang.String contractId, java.lang.String rpcUrl, Network network)
ContractClient
with the given contract ID, RPC URL, and network.contractId
- The contract ID to interact with.rpcUrl
- The RPC URL of the Soroban server.network
- The network to interact with.public <T> AssembledTransaction<T> invoke(java.lang.String functionName, java.util.List<SCVal> parameters, java.lang.String source, KeyPair signer, java.util.function.Function<SCVal,T> parseResultXdrFn, int baseFee)
AssembledTransaction
to invoke a function on the contract.
An alias for invoke(String, Collection, String, KeyPair, Function, int, int, int,
boolean, boolean)
.
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.public <T> AssembledTransaction<T> invoke(java.lang.String functionName, java.util.Collection<SCVal> parameters, java.lang.String source, @Nullable KeyPair signer, @Nullable java.util.function.Function<SCVal,T> parseResultXdrFn, int baseFee, int transactionTimeout, int submitTimeout, boolean simulate, boolean restore)
AssembledTransaction
to invoke a function on the contract.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 when simulate
is
true
, and the signer is provided.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException