Avalanche SDK Client
    Preparing search index...

    Function createCChainClient

    • Creates a C-Chain (Contract Chain) Client with a given transport configured for a Chain.

      The C-Chain Client is an interface to interact with the Avalanche Contract Chain through Avalanche-specific JSON-RPC API methods. The Contract Chain is an instance of the Ethereum Virtual Machine (EVM) that supports:

      • Cross-chain operations (import/export)
      • Atomic transactions
      • UTXO management
      • Dynamic fee calculations

      Type Parameters

      • transport extends Transport
      • chain extends undefined | Chain = undefined
      • accountOrAddress extends undefined | `0x${string}` | Account = undefined
      • rpcSchema extends undefined | RpcSchema = undefined
      • raw extends boolean = false

      Parameters

      Returns {
          extend: <const client extends { [key: string]: unknown }>(
              fn: (client: { extend: ...; getAtomicTx: ...; getAtomicTxStatus: ...; getUTXOs: ...; issueTx: ... }) => client,
          ) => { [K in (...) | (...) | (...)]: (...)[(...)] };
          getAtomicTx: (args: GetAtomicTxParameters) => Promise<GetAtomicTxReturnType>;
          getAtomicTxStatus: (args: GetAtomicTxStatusParameters) => Promise<GetAtomicTxStatusReturnType>;
          getUTXOs: (args: GetUTXOsParameters) => Promise<GetUTXOsReturnType>;
          issueTx: (args: IssueTxParameters) => Promise<IssueTxReturnType>;
      }

      A C-Chain Client. CChainClient

      • extend: <const client extends { [key: string]: unknown }>(
            fn: (client: { extend: ...; getAtomicTx: ...; getAtomicTxStatus: ...; getUTXOs: ...; issueTx: ... }) => client,
        ) => { [K in (...) | (...) | (...)]: (...)[(...)] }
      • getAtomicTx: (args: GetAtomicTxParameters) => Promise<GetAtomicTxReturnType>
        import { createAvalancheClient} from '@avalanche-sdk/client'
        import { avalanche } from '@avalanche-sdk/client/chains'

        const client = createAvalancheClient({
        chain: avalanche,
        transport: {
        type: "http",
        },
        })

        const tx = await client.cChain.getAtomicTx({
        txID: "2QouvMUbQ6oy7yQ9tLvL3L8tGQG2QK1wJ1q1wJ1q1wJ1q1wJ1q1wJ1q1wJ1"
        })
      • getAtomicTxStatus: (args: GetAtomicTxStatusParameters) => Promise<GetAtomicTxStatusReturnType>
        import { createAvalancheClient} from '@avalanche-sdk/client'
        import { avalanche } from '@avalanche-sdk/client/chains'

        const client = createAvalancheClient({
        chain: avalanche,
        transport: {
        type: "http",
        },
        })

        const status = await client.cChain.getAtomicTxStatus({
        txID: "2QouvMUbQ6oy7yQ9tLvL3L8tGQG2QK1wJ1q1wJ1q1wJ1q1wJ1q1wJ1q1wJ1"
        })
      • getUTXOs: (args: GetUTXOsParameters) => Promise<GetUTXOsReturnType>
        import { createAvalancheClient} from '@avalanche-sdk/client'
        import { avalanche } from '@avalanche-sdk/client/chains'

        const client = createAvalancheClient({
        chain: avalanche,
        transport: {
        type: "http",
        },
        })

        const utxos = await client.cChain.getUTXOs({
        addresses: ["X-avax1...", "X-avax2..."],
        limit: 100
        })
      • issueTx: (args: IssueTxParameters) => Promise<IssueTxReturnType>

        Send a signed transaction to the network.

        import { createAvalancheClient} from '@avalanche-sdk/client'
        import { avalanche } from '@avalanche-sdk/client/chains'

        const client = createAvalancheClient({
        chain: avalanche,
        transport: {
        type: "http",
        },
        })

        const txID = await client.cChain.issueTx({
        tx: "0x00000009de31b4d8b22991d51aa6aa1fc733f23a851a8c9400000000000186a0000000005f041280000000005f9ca900000030390000000000000001fceda8f90fcb5d30614b99d79fc4baa29307762668f16eb0259a57c2d3b78c875c86ec2045792d4df2d926c40f829196e0bb97ee697af71f5b0a966dabff749634c8b729855e937715b0e44303fd1014daedc752006011b730",
        encoding: "hex"
        })
      import { createCChainClient} from '@avalanche-sdk/client'
      import { avalanche } from '@avalanche-sdk/client/chains'

      const client = createCChainClient({
      chain: avalanche,
      transport: {
      type: "http",
      },
      })

      // Get atomic transaction
      const atomicTx = await client.getAtomicTx({ txID: '0x...' })