CCC Docs
    Preparing search index...

    Represents a User Defined Token (UDT) script compliant with the SSRI protocol.

    This class provides a comprehensive implementation for interacting with User Defined Tokens, supporting various token operations such as querying metadata, checking balances, and performing transfers. It supports both SSRI-compliant UDTs and legacy sUDT/xUDT standard tokens.

    Hierarchy (View Summary)

    Index

    Constructors

    • Constructs a new UDT (User Defined Token) script instance. By default it is a SSRI-compliant UDT. By providing xudtType, it is compatible with the legacy xUDT.

      Parameters

      • code: OutPointLike

        The script code cell of the UDT.

      • script: ScriptLike

        The type script of the UDT.

      • Optionalconfig: null | { executor?: null | Executor }

      Returns Udt

      const udt = new Udt(executor, code, script);
      

    Properties

    script: Script

    Methods

    • Transfers UDT to specified addresses.

      Parameters

      • signer: Signer
      • transfers: { to: ScriptLike; amount: NumLike }[]

        The array of transfers.

      • Optionaltx: null | TransactionLike

        Transfer on the basis of an existing transaction to achieve combined actions. If not provided, a new transaction will be created.

      Returns Promise<ExecutorResponse<Transaction>>

      The transaction result.

      Mutation - This method represents a mutation of the onchain state and will return a transaction object.

      const { script: change } = await signer.getRecommendedAddressObj();
      const { script: to } = await ccc.Address.fromString(receiver, signer.client);

      const udt = new Udt(
      {
      txHash: "0x4e2e832e0b1e7b5994681b621b00c1e65f577ee4b440ef95fa07db9bb3d50269",
      index: 0,
      },
      {
      codeHash: "0xcc9dc33ef234e14bc788c43a4848556a5fb16401a04662fc55db9bb201987037",
      hashType: "type",
      args: "0x71fd1985b2971a9903e4d8ed0d59e6710166985217ca0681437883837b86162f"
      },
      );

      const { res: tx } = await udtTrait.transfer(
      signer,
      [{ to, amount: 100 }],
      );

      const completedTx = udt.completeUdtBy(tx, signer);
      await completedTx.completeInputsByCapacity(signer);
      await completedTx.completeFeeBy(signer);
      const transferTxHash = await signer.sendTransaction(completedTx);