0.1.10 • Published 4 months ago

@ckb-ccc/udt v0.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Quick Start

  • At the moment, UDT and UDTPausable from @ckb-ccc/udt are fully supported through SSRI. In the future, there will be built in TypeScript generation directly based on the Rust source code on compilation.
  • To instantiate a UDT script compliant with SSRI, you can provide the SSRI server url and also specify the OutPoint of the script code.
  • You can also instantiate a UDTPausable script or other scripts that extends from UDT.
import { Server } from "@ckb-ccc/ssri";
import { Udt, UdtPausable } from "@ckb-ccc/udt";

const { signer } = useApp();
const server = new Server("https://localhost:9090");

const udt = new Udt(
  server,
  {
    txHash: "0x...",
    index: 0,
  },
  {
    codeHash: "0x...",
    hashType: "type",
    args: "0x...",
  },
);

const udtPausable = new UdtPausable(
  server,
  {
    txHash: "0x...",
    index: 0,
  },
  {
    codeHash: "0x...",
    hashType: "type",
    args: "0x...",
  },
);

You can directly call the methods in the script:

const { res: udtSymbol } = await udt.symbol();
const { res: pauseList } = await udtPausable.enumeratePaused();

Some of the methods can return a ccc.Transaction. For example, you can call transfer with the following params:

const { script: to } = await signer.getRecommendedAddressObj();

const { res: transferTx } = await udt.transfer(signer, [{ to, amount: 100 }]);
const completedTx = await udt.completeUdtBy(transferTx, signer);

await completedTx.completeInputsByCapacity(signer);
await completedTx.completeFeeBy(signer);
const transferTxHash = await signer.sendTransaction(completedTx);
0.1.10

4 months ago

0.1.9

5 months ago

0.1.8

7 months ago

0.1.7

7 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago