Generate contract ACI object with predefined js methods for contract usage - can be used for creating a reference to already deployed contracts

Options object

JS Contract API

const contractIns = await Contract.initialize({ ...aeSdk.getContext(), sourceCode })
await contractIns.$deploy([321]) or await contractIns.init(321)
const callResult = await contractIns.$call('setState', [123])
const staticCallResult = await contractIns.$call('setState', [123], { callStatic: true })

Also you can call contract like: await contractIns.setState(123, options) Then sdk decide to make on-chain or static call (dry-run API) transaction based on function is stateful or not

Type Parameters

Constructors

Properties

_aci: Aci
_calldata: Encoder
_name: string
$options: Omit<{
    aci: Aci;
    address?: `ct_${string}`;
    bytecode?: `cb_${string}`;
    fileSystem?: Record<string, string>;
    name?: `${string}.chain`;
    onCompiler?: CompilerBase;
    onNode: Node;
    sourceCode?: string;
    sourceCodePath?: string;
} & Partial<BuildTxOptions<ContractCallTx, "contractId" | "callData" | "callerId">> & {
    omitUnknown?: boolean;
} & GetContractNameByEventOptions & Pick<Partial<SendTransactionOptions>, "onNode" | "onAccount"> & Omit<SendTransactionOptions, "onNode" | "onAccount"> & Omit<{
    combine?: boolean;
    onNode: Node;
    top?: number | `kh_${string}` | `mh_${string}`;
    txEvents?: boolean;
}, "onNode"> & {
    callStatic?: boolean;
} & Partial<BuildTxOptions<ContractCreateTx, "code" | "ownerId" | "callData">>, "aci">

Methods

  • Compile contract

    Returns Promise<`cb_${string}`>

    bytecode

  • Deploy contract

    Parameters

    • params: M extends {
              init: any;
          }
          ? Parameters<M<M>["init"]>
          : []

      Contract init function arguments array

    • Optionaloptions: Partial<BuildTxOptions<ContractCallTx, "contractId" | "callData" | "callerId">> & {
          omitUnknown?: boolean;
      } & GetContractNameByEventOptions & Pick<Partial<SendTransactionOptions>, "onNode" | "onAccount"> & Omit<SendTransactionOptions, "onNode" | "onAccount"> & Omit<{
          combine?: boolean;
          onNode: Node;
          top?: number | `kh_${string}` | `mh_${string}`;
          txEvents?: boolean;
      }, "onNode"> & {
          callStatic?: boolean;
      } & Partial<BuildTxOptions<ContractCreateTx, "code" | "ownerId" | "callData">>

      Options

    Returns Promise<Omit<SendAndProcessReturnType, "hash"> & {
        address?: `ct_${string}`;
        decodedEvents?: DecodedEvent[];
        owner?: `ak_${string}`;
        transaction?: `th_${string}`;
    }>

    deploy info

  • Type Parameters

    Parameters

    • __namedParameters: Omit<{
          aci: Aci;
          address?: `ct_${string}`;
          bytecode?: `cb_${string}`;
          fileSystem?: Record<string, string>;
          name?: `${string}.chain`;
          onCompiler?: CompilerBase;
          onNode: Node;
          sourceCode?: string;
          sourceCodePath?: string;
      } & Partial<BuildTxOptions<ContractCallTx, "contractId" | "callData" | "callerId">> & {
          omitUnknown?: boolean;
      } & GetContractNameByEventOptions & Pick<Partial<SendTransactionOptions>, "onNode" | "onAccount"> & Omit<SendTransactionOptions, "onNode" | "onAccount"> & Omit<{
          combine?: boolean;
          onNode: Node;
          top?: number | `kh_${string}` | `mh_${string}`;
          txEvents?: boolean;
      }, "onNode"> & {
          callStatic?: boolean;
      } & Partial<BuildTxOptions<ContractCreateTx, "code" | "ownerId" | "callData">>, "address" | "aci"> & {
          aci?: Aci;
          address?: `${string}.chain` | `ct_${string}`;
          validateBytecode?: boolean;
      }

    Returns Promise<Contract<M>>