Class

Client

contract.Client(spec, options)

Generate a class from the contract spec that where each contract method gets included with an identical name.

Each method returns an AssembledTransaction that can be used to modify, simulate, decode results, and possibly sign, & submit the transaction.

Constructor

# new Client(spec, options)

Parameters:
Name Type Description
spec module:contract.Spec

Spec to construct a Client for

options ClientOptions

see ClientOptions

View Source lib/contract/client.js, line 54

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+)\)/"

View Source lib/contract/utils.js, line 72

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.

View Source lib/contract/client.js, line 160

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.

View Source lib/contract/client.js, line 148

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".

View Source lib/contract/client.js, line 124

If the provided options object does not contain an rpcUrl.

TypeError

A Promise that resolves to a Client instance.

Promise.<module:contract.Client>