Class TonHttpApiV2

Constructors

Properties

#adapter?: AxiosAdapter
#apiKey?: string
#endpoint: string
#timeout: number

Methods

  • Private

    Method to call jsonrpc.

    Type Parameters

    • T

    Parameters

    • method: string
    • params: any
    • returnSchema: ZodType<T, ZodTypeDef, T>

    Returns Promise<T>

  • Get all possible address forms.

    Parameters

    • address: string

    Returns Promise<{
        bounceable: { b64: string; b64url: string; };
        given_type: "raw_form" | "dns" | "friendly_bounceable" | "friendly_non_bounceable";
        non_bounceable: { b64: string; b64url: string; };
        raw_form: string;
        test_only: boolean;
    }>

  • Estimate fees required for query processing. body, init-code and init-data accepted in serialized format (b64-encoded).

    Parameters

    • address: string
    • body: string
    • init_code: string
    • init_data: string
    • ignore_chksig: boolean

    Returns Promise<{
        @type: "query.fees";
        destination_fees: ({ "@type": "fees"; fwd_fee: string | number; storage_fee: string | number; in_fwd_fee: string | number; gas_fee: string | number; })[];
        source_fees: { "@type": "fees"; fwd_fee: string | number; storage_fee: string | number; in_fwd_fee: string | number; gas_fee: string | number; };
    }>

  • Get balance (in nanotons) of a given address.

    Parameters

    • address: string

    Returns Promise<string | number>

  • Get basic information about the address: balance, code, data, last_transaction_id.

    Parameters

    • address: string

    Returns Promise<{
        @type: "raw.fullAccountState";
        balance: string | number;
        block_id: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        code: string;
        data: string;
        frozen_hash: string;
        last_transaction_id: { "@type": "internal.transactionId"; lt: string; hash: string; };
        state: "active" | "uninitialized" | "frozen";
        sync_utime: number;
    }>

  • Get state of a given address. State can be either unitialized, active or frozen.

    Parameters

    • address: string

    Returns Promise<"active" | "uninitialized" | "frozen">

  • Get metadata of a given block.

    Parameters

    • workchain: number
    • shard: string
    • seqno: number
    • Optional optional: {
          file_hash?: string;
          root_hash?: string;
      }
      • Optional file_hash?: string
      • Optional root_hash?: string

    Returns Promise<{
        @type: "blocks.header";
        after_merge: boolean;
        after_split: boolean;
        before_split: boolean;
        catchain_seqno: number;
        end_lt: string;
        flags: number;
        gen_utime: number;
        global_id: number;
        id: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        is_key_block: boolean;
        min_ref_mc_seqno: number;
        prev_blocks: ({ "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; })[];
        prev_key_block_seqno: number;
        start_lt: string;
        validator_list_hash_short: number;
        version: number;
        vert_seqno: number;
        want_merge: boolean;
        want_split: boolean;
    }>

  • Get transactions of the given block.

    Parameters

    • workchain: number
    • shard: string
    • seqno: number
    • Optional optional: {
          after_hash?: string;
          after_lt?: string;
          count?: number;
          file_hash?: string;
          root_hash?: string;
      }
      • Optional after_hash?: string
      • Optional after_lt?: string
      • Optional count?: number
      • Optional file_hash?: string
      • Optional root_hash?: string

    Returns Promise<{
        @type: "blocks.transactions";
        id: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        incomplete: boolean;
        req_count: number;
        transactions: ({ "@type": "blocks.shortTxId"; lt: string; hash: string; mode: number; account: string; })[];
    }>

  • Get config by id.

    Parameters

    • config_id: number
    • Optional optional: {
          seqno?: number;
      }
      • Optional seqno?: number

    Returns Promise<{
        @type: "configInfo";
        config: { "@type": "tvm.cell"; bytes: string; };
    }>

  • Get consensus block and its update timestamp.

    Returns Promise<{
        consensus_block: number;
        timestamp: number;
    }>

  • Similar to previous one but tries to parse additional information for known contract types. This method is based on tonlib's function getAccountState. For detecting wallets we recommend to use getWalletInformation.

    Parameters

    • address: string

    Returns Promise<{
        @type: "fullAccountState";
        account_state: (({ code: string; data: string; "@type": "raw.accountState"; frozen_hash: string; }) | ({ "@type": "wallet.v3.accountState"; seqno: number; wallet_id: string | number; }) | ({ "@type": "wallet.v4.accountState"; seqno: number; wallet_id: string | number; }) | ({ "@type": "wallet.highload.v1.accountState"; seqno: number; wallet_id: string | number; }) | ({ "@type": "wallet.highload.v2.accountState"; wallet_id: string | number; }) | ({ "@type": "dns.accountState"; wallet_id: string | number; }) | ({ "@type": "rwallet.accountState"; seqno: number; wallet_id: string | number; unlocked_balance: string | number; config: { "@type": "rwallet.config"; start_at: number; limits: { value: number; "@type": "rwallet.limit"; seconds: number; }[]; }; })) & (undefined | ({ code: string; data: string; "@type": "raw.accountState"; frozen_hash: string; }) | ({ "@type": "wallet.v3.accountState"; seqno: number; wallet_id: string | number; }) | ({ "@type": "wallet.v4.accountState"; seqno: number; wallet_id: string | number; }) | ({ "@type": "wallet.highload.v1.accountState"; seqno: number; wallet_id: string | number; }) | ({ "@type": "wallet.highload.v2.accountState"; wallet_id: string | number; }) | ({ "@type": "dns.accountState"; wallet_id: string | number; }) | ({ "@type": "rwallet.accountState"; seqno: number; wallet_id: string | number; unlocked_balance: string | number; config: { "@type": "rwallet.config"; start_at: number; limits: { value: number; "@type": "rwallet.limit"; seconds: number; }[]; }; }));
        address: { "@type": "accountAddress"; account_address: string; };
        balance: string | number;
        block_id: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        last_transaction_id: { "@type": "internal.transactionId"; lt: string; hash: string; };
        revision: number;
        sync_utime: number;
    }>

  • Get metadata of a given masterchain block.

    Parameters

    • seqno: number

    Returns Promise<{
        @type: "blocks.header";
        after_merge: boolean;
        after_split: boolean;
        before_split: boolean;
        catchain_seqno: number;
        end_lt: string;
        flags: number;
        gen_utime: number;
        global_id: number;
        id: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        is_key_block: boolean;
        min_ref_mc_seqno: number;
        prev_blocks: ({ "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; })[];
        prev_key_block_seqno: number;
        start_lt: string;
        validator_list_hash_short: number;
        version: number;
        vert_seqno: number;
        want_merge: boolean;
        want_split: boolean;
    }>

  • Get up-to-date masterchain state.

    Parameters

    • seqno: number

    Returns Promise<{
        @type: "blocks.blockSignatures";
        id: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        signatures: ({ "@type": "blocks.signature"; node_id_short: string; signature: string; })[];
    }>

  • Get transactions of the given masterchain block.

    Parameters

    • seqno: number

    Returns Promise<{
        @type: "blocks.transactions";
        id: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        incomplete: boolean;
        req_count: number;
        transactions: ({ "@type": "blocks.shortTxId"; lt: string; hash: string; mode: number; account: string; })[];
    }>

  • Get up-to-date masterchain state.

    Returns Promise<{
        @type: "blocks.masterchainInfo";
        init: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        last: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        state_root_hash: string;
    }>

  • Get merkle proof of shardchain block.

    Parameters

    • workchain: number
    • shard: string
    • seqno: number
    • Optional optional: {
          from_seqno?: number;
      }
      • Optional from_seqno?: number

    Returns Promise<{
        @type: "blocks.shardBlockProof";
        from: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        links: ({ "@type": "blocks.shardBlockLink"; id: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; }; proof: string; })[];
        mc_id: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; };
        mc_proof: ({ "@type": "blocks.blockLinkBack"; proof: string; to_key_block: boolean; from: { "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; }; to: { ...; }; dest_proof: string; state_proof: string; })[];
    }>

  • Get shards information.

    Parameters

    • seqno: number

    Returns Promise<{
        @type: "blocks.shards";
        shards: ({ "@type": "ton.blockIdExt"; workchain: number; shard: string; seqno: number; root_hash: string; file_hash: string; })[];
    }>

  • Get transaction history of a given address.

    Parameters

    • address: string
    • Optional optional: {
          archival?: boolean;
          hash?: string;
          limit?: number;
          lt?: string;
          to_lt?: string;
      }
      • Optional archival?: boolean
      • Optional hash?: string
      • Optional limit?: number
      • Optional lt?: string
      • Optional to_lt?: string

    Returns Promise<{
        @type: "raw.transaction";
        address: { "@type": "accountAddress"; account_address: string; };
        data: string;
        fee: string | number;
        in_msg: { value: string; "@type": "raw.message"; source: string; destination: string; fwd_fee: string | number; ihr_fee: string | number; created_lt: string; body_hash: string; msg_data: { "@type": "msg.dataRaw"; body: string; init_state: string; } | { ...; } | { ...; } | { ...; }; message?: string | undefined; };
        other_fee: string | number;
        out_msgs: ({ value: string; "@type": "raw.message"; source: string; destination: string; fwd_fee: string | number; ihr_fee: string | number; created_lt: string; body_hash: string; msg_data: { "@type": "msg.dataRaw"; body: string; init_state: string; } | { ...; } | { ...; } | { ...; }; message?: string | undefined; })[];
        storage_fee: string | number;
        transaction_id: { "@type": "internal.transactionId"; lt: string; hash: string; };
        utime: number;
    }[]>

  • Retrieve wallet information. This method parses contract state and currently supports more wallet types than getExtendedAddressInformation: simple wallet, standart wallet, v3 wallet, v4 wallet.

    Parameters

    • address: string

    Returns Promise<{
        account_state: string;
        balance: string | number;
        last_transaction_id: { "@type": "internal.transactionId"; lt: string; hash: string; };
        seqno: number;
        wallet: boolean;
        wallet_id: string | number;
        wallet_type: string;
    }>

  • Look up block by either seqno, lt or unixtime.

    Parameters

    • workchain: number
    • shard: string
    • Optional optional: {
          lt?: string;
          seqno?: number;
          unixtime?: number;
      }
      • Optional lt?: string
      • Optional seqno?: number
      • Optional unixtime?: number

    Returns Promise<{
        @type: "ton.blockIdExt";
        file_hash: string;
        root_hash: string;
        seqno: number;
        shard: string;
        workchain: number;
    }>

  • Convert an address from raw to human-readable format.

    Parameters

    • address: string

    Returns Promise<string>

  • Run get method on smart contract.

    Parameters

    • address: string
    • method: string
    • stack: TupleItem[]

    Returns Promise<{
        exit_code: number;
        gas_used: number;
        stack: unknown[];
    }>

  • Send serialized boc file: fully packed and serialized external message to blockchain. boc accepted in serialized format (b64-encoded).

    Parameters

    • boc: string

    Returns Promise<{
        @type: "ok";
    }>

  • Send serialized boc file: fully packed and serialized external message to blockchain. The method returns message hash. boc accepted in serialized format (b64-encoded).

    Parameters

    • boc: string

    Returns Promise<{
        @type: "raw.extMessageInfo";
        hash: string;
    }>

  • Same as previous. Locate outcoming transaction of destination address by incoming message.

    Parameters

    • source: string
    • destination: string
    • created_lt: string

    Returns Promise<{
        @type: "raw.transaction";
        address: { "@type": "accountAddress"; account_address: string; };
        data: string;
        fee: string | number;
        in_msg: { value: string; "@type": "raw.message"; source: string; destination: string; fwd_fee: string | number; ihr_fee: string | number; created_lt: string; body_hash: string; msg_data: { "@type": "msg.dataRaw"; body: string; init_state: string; } | { ...; } | { ...; } | { ...; }; message?: string | undefined; };
        other_fee: string | number;
        out_msgs: ({ value: string; "@type": "raw.message"; source: string; destination: string; fwd_fee: string | number; ihr_fee: string | number; created_lt: string; body_hash: string; msg_data: { "@type": "msg.dataRaw"; body: string; init_state: string; } | { ...; } | { ...; } | { ...; }; message?: string | undefined; })[];
        storage_fee: string | number;
        transaction_id: { "@type": "internal.transactionId"; lt: string; hash: string; };
        utime: number;
    }>

  • Locate incoming transaction of source address by outcoming message.

    Parameters

    • source: string
    • destination: string
    • created_lt: string

    Returns Promise<{
        @type: "raw.transaction";
        address: { "@type": "accountAddress"; account_address: string; };
        data: string;
        fee: string | number;
        in_msg: { value: string; "@type": "raw.message"; source: string; destination: string; fwd_fee: string | number; ihr_fee: string | number; created_lt: string; body_hash: string; msg_data: { "@type": "msg.dataRaw"; body: string; init_state: string; } | { ...; } | { ...; } | { ...; }; message?: string | undefined; };
        other_fee: string | number;
        out_msgs: ({ value: string; "@type": "raw.message"; source: string; destination: string; fwd_fee: string | number; ihr_fee: string | number; created_lt: string; body_hash: string; msg_data: { "@type": "msg.dataRaw"; body: string; init_state: string; } | { ...; } | { ...; } | { ...; }; message?: string | undefined; })[];
        storage_fee: string | number;
        transaction_id: { "@type": "internal.transactionId"; lt: string; hash: string; };
        utime: number;
    }>

  • Locate outcoming transaction of destination address by incoming message.

    Parameters

    • source: string
    • destination: string
    • created_lt: string

    Returns Promise<{
        @type: "raw.transaction";
        address: { "@type": "accountAddress"; account_address: string; };
        data: string;
        fee: string | number;
        in_msg: { value: string; "@type": "raw.message"; source: string; destination: string; fwd_fee: string | number; ihr_fee: string | number; created_lt: string; body_hash: string; msg_data: { "@type": "msg.dataRaw"; body: string; init_state: string; } | { ...; } | { ...; } | { ...; }; message?: string | undefined; };
        other_fee: string | number;
        out_msgs: ({ value: string; "@type": "raw.message"; source: string; destination: string; fwd_fee: string | number; ihr_fee: string | number; created_lt: string; body_hash: string; msg_data: { "@type": "msg.dataRaw"; body: string; init_state: string; } | { ...; } | { ...; } | { ...; }; message?: string | undefined; })[];
        storage_fee: string | number;
        transaction_id: { "@type": "internal.transactionId"; lt: string; hash: string; };
        utime: number;
    }>

  • Convert an address from human-readable to raw format.

    Parameters

    • address: string

    Returns Promise<string>

Generated using TypeDoc