Skip to main content

ContractApi

scrypt-ts / ContractApi

Class: ContractApi

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new ContractApi(_core)

Parameters

NameType
_coreCore

Defined in

dist/client/apis/contract-api.d.ts:36

Properties

_core

Private Readonly _core: any

Defined in

dist/client/apis/contract-api.d.ts:35

Methods

getLatestInstance

getLatestInstance<T>(clazz, contractId): Promise<T>

Get a contract instance containing the latest state of the contract by the contract ID. The obtained contract instance may also be obtained by other users at the same time. If other users call this contract instance. Then the contract instance will be invalid. At this time, calling the contract will cause a txn-mempool-conflict error (that is, UTXO double spending). If this error occurs, you need to re-acquire the contract instance

Type parameters

NameType
Textends SmartContract<T>

Parameters

NameType
clazz(...args: any) => T
contractIdContractId

Returns

Promise<T>

a contract instance contains latest state

Defined in

dist/client/apis/contract-api.d.ts:49


subscribe

subscribe<T>(options, cb): SubScription

Subscribe to notifications of contract status changes by contract ID,

Type parameters

NameType
Textends SmartContract<T>

Parameters

NameTypeDescription
optionsSubscribeOptions<T>SubscribeOptions
cb(e: ContractCalledEvent<T>) => void

Returns

SubScription

a SubScription, which can be used to unsubscribe

Defined in

dist/client/apis/contract-api.d.ts:56