Interface ContractApi

Contract API

This module provides methods about the smart contracts

interface ContractApi {
    callContractMethod: ((args: CallContractMethodArgs) => Promise<TransactionId | UnsignedTransaction>);
    getAllContractIds: ((args: GetAllContractIdsArgs) => Promise<ContractIdList>);
    getAllContractsByCodeHash: ((args: GetAllContractsByCodeHashArgs) => Promise<ContractList>);
    getContract: ((id: string) => Promise<Contract>);
    getContractMapValuesByFirstKey: ((args: GetContractMapValuesByFirstKeyArgs) => Promise<ContractMapValueList>);
    getContractsByAccount: ((args: GetContractsByAccountArgs) => Promise<ContractList>);
    getSingleContractMapValue: ((args: GetSingleContractMapValueArgs) => Promise<{
        value: string;
    }>);
    publishContract: ((args: PublishContractArgs) => Promise<TransactionId | UnsignedTransaction>);
    publishContractByReference: ((args: PublishContractByReferenceArgs) => Promise<TransactionId | UnsignedTransaction>);
}

Properties

callContractMethod: ((args: CallContractMethodArgs) => Promise<TransactionId | UnsignedTransaction>)

Calls a public method of smart contract

Type declaration

getAllContractIds: ((args: GetAllContractIdsArgs) => Promise<ContractIdList>)

Get all contract Ids of the blockchain, or filtered by the argument

Type declaration

    • (args): Promise<ContractIdList>
    • Parameters

      Returns Promise<ContractIdList>

      The list of contract ids

getAllContractsByCodeHash: ((args: GetAllContractsByCodeHashArgs) => Promise<ContractList>)

Gets all contracts for a given machin code hash

Type declaration

getContract: ((id: string) => Promise<Contract>)

Get a contract by its Id

Type declaration

    • (id): Promise<Contract>
    • Parameters

      • id: string

        The ID of the contract

      Returns Promise<Contract>

      The contract

getContractMapValuesByFirstKey: ((args: GetContractMapValuesByFirstKeyArgs) => Promise<ContractMapValueList>)

Gets a key-value list for the given first key of a contracts data store

Type declaration

getContractsByAccount: ((args: GetContractsByAccountArgs) => Promise<ContractList>)

Get all contracts of given account, or filtered by the arguments

Type declaration

    • (args): Promise<ContractList>
    • Parameters

      Returns Promise<ContractList>

      A list of contracts

getSingleContractMapValue: ((args: GetSingleContractMapValueArgs) => Promise<{
    value: string;
}>)

Gets a map value from a contracts data store

Type declaration

    • (args): Promise<{
          value: string;
      }>
    • Parameters

      Returns Promise<{
          value: string;
      }>

      The value. Non-existing key-value tuples return always 0 (Zero)

publishContract: ((args: PublishContractArgs) => Promise<TransactionId | UnsignedTransaction>)

Publishes a smart contract to the blockchain

Type declaration

publishContractByReference: ((args: PublishContractByReferenceArgs) => Promise<TransactionId | UnsignedTransaction>)

Publishes a smart contract to the blockchain using the code base of an already existant contract. This reduces payload in the chain, allowing to deploy many contracts per block and very cheap

Type declaration