# new Client(spec, options)
Parameters:
Name | Type | Description |
---|---|---|
spec |
module:contract.Spec
|
Spec to construct a Client for |
options |
ClientOptions
|
see ClientOptions |
Members
RegExp
# static constant contractErrorPattern
If contracts are implemented using the #[contracterror]
macro, then the
errors get included in the on-chain XDR that also describes your contract's
methods. Each error will have a specific number. This Regular Expression
matches these "expected error types" that a contract may throw, and helps
AssembledTransaction parse these errors.
- Default Value:
- "/Error\(Contract, #(\d+)\)/"
Methods
# async static from(options) → {Promise.<module:contract.Client>}
Generates a Client instance from the provided ClientOptions, which must include the contractId and rpcUrl.
Parameters:
Name | Type | Description |
---|---|---|
options |
ClientOptions
|
The ClientOptions object containing the necessary configuration, including the contractId and rpcUrl. |
If the provided options object does not contain both rpcUrl and contractId.
TypeError
A Promise that resolves to a Client instance.
Promise.<module:contract.Client>
# async static fromWasm(wasm, options) → {Promise.<module:contract.Client>}
Generates a Client instance from the provided ClientOptions and the contract's wasm binary.
Parameters:
Name | Type | Description |
---|---|---|
wasm |
Buffer
|
The contract's wasm binary as a Buffer. |
options |
ClientOptions
|
The ClientOptions object containing the necessary configuration. |
If the contract spec cannot be obtained from the provided wasm binary.
Error
A Promise that resolves to a Client instance.
Promise.<module:contract.Client>
# async static fromWasmHash(wasmHash, options, formatopt) → {Promise.<module:contract.Client>}
Generates a Client instance from the provided ClientOptions and the contract's wasm hash. The wasmHash can be provided in either hex or base64 format.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
wasmHash |
Buffer
|
string
|
The hash of the contract's wasm binary, in either hex or base64 format. |
||
options |
ClientOptions
|
The ClientOptions object containing the necessary configuration, including the rpcUrl. |
||
format |
'hex'
|
'base64'
|
<optional> |
'hex' | The format of the provided wasmHash, either "hex" or "base64". Defaults to "hex". |
If the provided options object does not contain an rpcUrl.
TypeError
A Promise that resolves to a Client instance.
Promise.<module:contract.Client>