diff --git a/README.md b/README.md index b7dc7481..6fbec91c 100644 --- a/README.md +++ b/README.md @@ -33,36 +33,91 @@
Interoperate with wallets from different chain ecosystems.
- Fully enabling CKB's Turing completeness and cryptographic freedom. + Fully enabling CKB's Turing completeness and cryptographic freedom power.

## Use Cases -We design CCC to optimize various use cases, including: +

+ + + +

-- **Learn CKB**: Numerous [basic code examples and web demos based on CCC](https://github.com/ckb-devrel/ccc?tab=readme-ov-file#examples) help you quickly understand how CKB works. -- **Analyze Data**: Leverage CCC to interact with CKB nodes and process blockchain data programmatically. -- [**Compose Transaction**](https://github.com/ckb-devrel/ccc?tab=readme-ov-file#transaction-composing): Highly intuitive and customizable transaction composition, with helpers to simplify the process. -- **Sign Easily**: Unified Signing interface with pre-built signing methods to interoperate with multiple chains seamlessly. -- **Connect Wallets**: Integrate the connector component in a minute or smoothly build a customized wallet connection UI, enabling your app to reach a wider audience. +For non-developers, you can [try CCC's app now here](https://app.ckbccc.com/) ([Project source code](https://github.com/ckb-devrel/ccc/tree/master/packages/demo)). It showcases how to use CCC for some basic scenarios in CKB: + +- [Sign and verify any message.]() ([Playground](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/sign.ts)) +- [Transfer native CKB token.]() ([Playground](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transfer.ts)) +- [Transfer UDT token.]() ([Playground](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transferUdt.ts)) +- See [Misc: Single-Use-Seals](https://talk.nervos.org/t/en-cn-misc-single-use-seals/8279) to learn how token issuing works in the cell model. + - [Issue xUDT token with the Single-Use Lock.]() + - [Issue xUDT token controlled by a Type ID cell.]() +- [Spore Protocol](https://docs.spore.pro/) SDK. + - [Create spore cluster.]() + - [Mint spore.]() + - [Transfer/Melt spore.]() + - [Transfer spore cluster.]() +- [Manage Nervos DAO.]() +- [Transfer native CKB token with time lock.]() +- [Calculate the CKB hash of any messages.]() +- [Generate mnemonic and keypairs. Encrypt to a keystore.]() +- [Decrypt a keystore.]() +- [Transfer the native CKB token with the old Lumos SDK.]() -Read our [documents](https://docs.ckbccc.com) or [API reference](https://api.ckbccc.com) to learn more about CCC. If you are new to the CKB, we also recommend [Nervos CKB Docs](https://docs.nervos.org/) for basic knowledge. +## Examples -## Try in the Playground +

+ + + +

+ +Check our [full documents for all detailed APIs](https://docs.ckbccc.com) to understand these examples better. If you are new to the CKB, we recommend checking [Nervos CKB Docs](https://docs.nervos.org/) for basic knowledge. We build examples based on [the CCC playground](https://live.ckbccc.com/).

- +

-The CCC Playground is an integrated testing environment in web browsers that supports data visualization and code-sharing. [Click the link](https://live.ckbccc.com/) to run your code without the annoying preparation and watch how the code works, exploring CCC's capabilities. +Cells are represented with graphs in the playground. The three layers of cells represent occupancy, type and lock from inside to outside. The filled center circle means that all CKB of this cell is used to store data. + +When cells share the same color, the same script governs them. They are owned by the same address (the outside ring) or the same type of assets (the inside ring). Check the script details in the "Scripts" tab. + +### Transaction Composing + +Here's an example for transferring CKB: -For an explanation of the visual elements and interface components in the playground, please refer to [the CCC Playground guide](https://docs.ckbccc.com/docs/playground). +```typescript +const tx = ccc.Transaction.from({ + outputs: [{ lock: toLock, capacity: ccc.fixedPointFrom(amount) }], +}); +``` -## Quick Start with `create-ccc-app` +Tell CCC what you need, and then... -Besides short testing, CCC is also suitable for building scalable applications. To get started quickly, you can use our CLI tool `create-ccc-app` to bootstrap a new CCC-based application: +```typescript +await tx.completeInputsByCapacity(signer); +await tx.completeFeeBy(signer); // Transaction fee rate is calculated automatically +const txHash = await signer.sendTransaction(tx); +``` + +We have done everything! + +- [Use specified wallet in custom UI.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/customUi.ts) +- [Use all supported wallets in custom UI.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/customUiWithController.ts) +- [Sign and verify any message.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/sign.ts) +- [Transfer native CKB token.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transfer.ts) +- [Transfer all native CKB token.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transferAll.ts) +- [Transfer UDT token.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transferUdt.ts) +- [Interact with UDT through @ckb-ccc/udt](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/udt/quickstart.ts): +- [Get UDT symbol through @ckb-ccc/udt.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/udt/symbol.ts) +- [Check if a lock hash has been paused through @ckb-ccc/udt.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/pausableUdt/isPaused.ts) +- [Transfer UDT token through @ckb-ccc/udt.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/udt/transfer.ts) + +## Quick Start with `create-ccc-app` (Recommended) + +To quickly bootstrap a new CCC-based application, you can use our CLI tool `create-ccc-app`: ```bash # Using npx @@ -79,63 +134,29 @@ yarn create ccc-app my-ccc-app pnpm create ccc-app my-ccc-app ``` -Follow the prompts to select your preferred framework template and begin building your CCC application. +Follow the prompts to select your preferred framework template and start building your CCC application. ## Manual Installation -Whether you are a front-end or back-end developer, CCC provides helpful tools and capabilities: +We design CCC for both front-end and back-end developers. You need only one package to fulfil all your needs: - [NodeJS](https://www.npmjs.com/package/@ckb-ccc/shell): `npm install @ckb-ccc/shell` - [Custom UI](https://www.npmjs.com/package/@ckb-ccc/ccc): `npm install @ckb-ccc/ccc` - [Web Component](https://www.npmjs.com/package/@ckb-ccc/connector): `npm install @ckb-ccc/connector` -- [React](https://www.npmjs.com/package/@ckb-ccc/connector-react) ([Docs](https://api.ckbccc.com/modules/_ckb_ccc_connector_react.html)): `npm install @ckb-ccc/connector-react` +- [React](https://www.npmjs.com/package/@ckb-ccc/connector-react) ([Docs](https://docs.ckbccc.com/modules/_ckb_ccc_connector_react.html)): `npm install @ckb-ccc/connector-react` -All exports from CCC are available on the `ccc` object to help with code completion: +CCC exports everything on the `ccc` object: ```typescript import { ccc } from "@ckb-ccc/"; ``` -If you are an advanced developer and wish to customize your code heavily, the `/advanced` entry point exports `cccA`, which contains almost everything else. Be aware that these interfaces are not stable: +For advanced developers, we provided the `cccA` object to fulfil all your needs. You should notice that these interfaces are not stable: ```typescript import { cccA } from "@ckb-ccc//advanced"; ``` -## Examples - -

- - - -

- -The CCC App is a mini-toolset for CKB, showcasing some basic scenarios. You can still [try the CCC App here](https://app.ckbccc.com) even if you are not a developer. To learn more about the app's features, visit [the documentation](https://docs.ckbccc.com/docs/ccc-app). - -### Transaction Composing - -Let's start with a minimal example for transferring CKB: - -```typescript -const tx = ccc.Transaction.from({ - outputs: [{ lock: toLock, capacity: ccc.fixedPointFrom(amount) }], -}); -``` - -Define the essential outputs of the transaction, and then... - -```typescript -await tx.completeInputsByCapacity(signer); -await tx.completeFeeBy(signer); // Transaction fee rate is calculated automatically -const txHash = await signer.sendTransaction(tx); -``` - -That's it! The transaction is sent. - -[Click here to read the full example of transferring native CKB token.](https://live.ckbccc.com/?src=https://raw.githubusercontent.com/ckb-devrel/ccc/refs/heads/master/packages/examples/src/transfer.ts) - -Additional examples can be found in [the documentation](https://docs.ckbccc.com/docs/code-examples). - ## Build and Run Run the demo of CCC in two steps: @@ -164,8 +185,8 @@ pnpm run dev | [](https://www.nervape.com/) | [](https://utxoswap.xyz/) | [](https://d.id/) | [](https://bool.network/) | | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -| [](https://world3.ai/) | [](https://catnip.rgbcat.io/) | -| ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | +| [](https://world3.ai/) | [](https://catnip.rgbcat.io/) | +| ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ## FAQs @@ -204,6 +225,12 @@ import { generateDefaultScriptInfos } from "@ckb-ccc/lumos-patches"; registerCustomLockScriptInfos(generateDefaultScriptInfos()); ``` +## Additional Guides + +### SSRI (Script Sourced Rich Information) + +- [Quick Starts: Interact with SSRI-Compliant UDT Script with @ckb-ccc/udt](https://github.com/ckb-devrel/ccc/tree/master/guides/quickstart_udt.md) + ## Links - [CCC Playground](https://live.ckbccc.com/) and its [source code](https://github.com/ckb-devrel/ccc/tree/master/packages/playground) help you experiment with CCC instantly in browsers. diff --git a/packages/docs/docs/udt.md b/packages/docs/docs/udt.md new file mode 100644 index 00000000..1c2598ba --- /dev/null +++ b/packages/docs/docs/udt.md @@ -0,0 +1,225 @@ +--- +sidebar-position: 5 +title: UDT +description: UDT(User Defined Tokens) is the customized token created with properties defined by user. +--- + +## Fungible Tokens + +Unlike [ERC20(Ethereum)](https://eips.ethereum.org/EIPS/eip-20) and [BRC20(Bitcoin)](https://www.brc-20.io/), CKB uses a unique way to build custom tokens based on its UTXO-like Cell Model. + +In CKB, custom tokens are called User-Defined Tokens (UDTs). s(Simple)UDT is the standard that defines the most basic implementation of a UDT fungible token on CKB, and CKB's core team has also proposed a minimal but also extensible standard for UDT called xUDT(extensible UDT). + +Steps to Issue a Custom Token with sUDT/xUDT: + +1. Create a Special Cell: When you issue tokens, you create a special Cell representing a balance of your custom token, similar to how physical cash represents a balance of currency. + +2. Configure the Cell's Data: This Cell’s data field will store the token amount, while its Type Script will be the sUDT/xUDT Script. The script’s args field will contain the Lock Script Hash of the issuer. + +3. Establish a Unique Token ID: The issuer’s Lock Script hash serves as the unique identifier for each custom token. Different Lock Script hashes represent different tokens, enabling secure and distinct transactions for each token type. + +## SSRI-Compliant `UDT` (Advanced) + +SSRI-Compliant UDT is an enhanced and the latest version of UDT that implements the SSRI (Script-Sourced Rich Information) protocol. By implementing the public traits `UDT`, SSRI allows UDT scripts to provide rich metadata and additional functionality directly from the script code, such as token name, symbol, icon, and other custom properties, making them more interoperable and user-friendly across different applications and wallets. + +On a more abstract level, any Script can be a UDT if it implements the public traits `UDT` as SSRI provides unlimited extensibility. + +## `@ckb-ccc/udt`: All-in-one SDK for interactions with `UDT` + +@ckb-ccc/udt is a comprehensive SDK that provides a unified interface for interacting seamlessly with both SSRI-compliant UDTs and legacy sUDT and xUDT tokens on CKB. It offers a rich set of features including: + +- Querying token metadata (name, symbol, icon, etc.) +- Checking token balances +- Transferring tokens + +For detailed API documentation and usage examples, please refer to the [API Reference](https://api.ckbccc.com/). + +## Tutorial: Interact UDT Script with `@ckb-ccc/udt` + +>The following guide uses UDT and Pausable UDT as example and assume you're using the playground environment which provides the signer. Your signer would be different based on your project setup. + +### Example 1: Prepare and Setup a `UDT` instance + +1. Create or setup your project with CCC (see guide [here](https://docs.ckbccc.com/index.html#md:quick-start-with-create-ccc-app-recommended)) + +2. `(Only for SSRI-Compliant Token)` Start up your local SSRI server through docker: + + ```shell + docker run -p 9090:9090 hanssen0/ckb-ssri-server + ``` + + Note: You can also choose to use the WASM implementation of SSRI Executor instead if you're developing browser based dApps, so you don't need to provide the service yourself. + +3. `(Only for SSRI-Compliant Token)` Prepare the `OutPoint` of your SSRI-compliant UDT script. It's recommended to deploy your UDT script with Type ID, and the following way would allow you to get the `OutPoint` programmatically even if the script gets upgraded: + + ```ts + import { ccc } from "@ckb-ccc/ccc"; + import { signer } from "@ckb-ccc/playground"; + // Note: Your signer would be different based on your project setup. + + const pudtScriptCell = await signer.client.findSingletonCellByType({ + codeHash:"0x00000000000000000000000000000000000000000000000000545950455f4944", + hashType: "type", + args: "0xf0bad0541211603bf14946e09ceac920dd7ed4f862f0ffd53d0d477d6e1d0f0b", + }); + if (!scriptCell) { + throw new Error("pudt script cell not found"); + } + ``` + +4. Prepare the type `Script` object of your UDT. You can provide the code hash yourself by copying from the explorer, or get it programmatically from the `OutPoint` of your UDT script. + For sUDT, you can get the type `Script` object like this: + + ```ts + const mySudtType = ccc.Script.from({ + codeHash: "0x5e7a36a77e68eecc013dfa2fe6a23f3b6c344b04005808694ae6dd45eea4cfd5", + hashType: "type", + args: "0xabcd..." // The args of your sUDT + }); + ``` + + For xUDT, you can get it more programmatically: + + ```ts + const xudtInfo = await signer.client.getKnownScript(ccc.KnownScript.XUdt); + const myXudtType = ccc.Script.from({ + codeHash: xudtInfo.codeHash, + hashType: xudtInfo.hashType, + args: "0xabcd..." // The args of your xUDT + }) + ``` + + For SSRI-Compliant UDT, you can get it this way even if the Script code gets updated: + + ```ts + const pudtCodeHash = pudtScriptCell.cellOutput.type?.hash(); + if (!pudtCodeHash) { + throw new Error("PUDT code hash not found"); + } + const pudtType = { + codeHash: pudtCodeHash, + hashType: "type", + args: "0x02c93173368ec56f72ec023f63148461b80e7698eddd62cbd9dbe31a13f2b330", // This is just for playground, you should replace it with the args with your SSRI-Compliant UDT + }; + ``` + +5. You have everything ready, now you can create an instance of your UDT and interact with it. + + For sUDT and xUDT, you will create the instance like this, but you can only call with `UDT.transfer` and `UDT.mint`. See how to call them with in the next example. + + ```ts + const sudtOutPoint = ccc.OutPoint.from({ + txHash: "0xc7813f6a415144643970c2e88e0bb6ca6a8edc5dd7c1022746f628284a9936d5", + index: 0 + }); + const mySudt = new ccc.udt.Udt(sudtOutPoint, mySudtType); + ``` + + For SSRI-Compliant UDT, you will need to provide the Executor and create your instance like this: + + ```ts + const executor = new ccc.ssri.ExecutorJsonRpc("http://localhost:9090"); + const pudt = new ccc.udt.Udt(pudtScriptCell.outPoint, pudtType, { + executor, + }); + ``` + + And then you can interact with your SSRI-Compliant UDT like this: + + ```ts + const pudtName = await pudt.name(); + const pudtIcon = await pudt.icon(); + console.log(pudtName); + // {"res":"pudt Token","cellDeps":[]} + console.log(pudtIcon); + // {"res":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMjQiIGN5PSIyNCIgcj0iMjQ ...... + ``` + + The same script might have implemented multiple SSRI traits or sub-traits at the same time, but you can instantiate the same script arbitrarily with different traits as long as the script implemented the traits you want. + + ```ts + const pudt = new ccc.udt.UdtPausable(pudtScriptCell.outPoint, pudtType, { + executor, + }); + const pudtEnumeratePaused = await pudt.enumeratePaused(); + console.log(pudtEnumeratePaused); + // {"res":["0xb5202efa0f2d250af66f0f571e4b8be8b272572663707a052907f8760112fe35","0xa320a09489791af2e5e1fe84927eda84f71afcbd2c7a65cb419464fe46e75085"],"cellDeps":[{"txHash":"0x98c37eabc1672c4a0a30c0bb284ed49308f0cb58b0d8791f44cca168c973e7da","index":"0"}]} + ``` + +### Example 2: Generate and Send a Transaction through @ckb-ccc/udt + +1. Some of the methods allows you to generate a transaction object directly while taking care of most of the details for you. You just need to follow the guidance of the docs provided via your IDE. + + For all UDT including the legacy sUDT, xUDT, and SSRI-Compliant UDT, you can `transfer` and `mint` like this: + + ```ts + const receiverA = + "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2jk6pyw9vlnfakx7vp4t5lxg0lzvvsp3c5adflu"; + + const { script: lockA } = await ccc.Address.fromString( + receiverA, + signer.client + ); + + const sudtTransferTx = ( + await mySudt.transfer(signer, [ + { + to: lockA, + amount: 10000, + }, + ]) + ).res; + + const xudtTransferTx = ( + await myXudt.transfer(signer, [ + { + to: lockA, + amount: 10000, + }, + ]) + ).res; + + const pudtTransferTx = ( + await pudt.transfer(signer, [ + { + to: lockA, + amount: 10000, + }, + ]) + ).res; + ``` + + Many of these methods also allow you to pass in a previous `ccc.TransactionLike` object as the second argument, which allows you for example to transfer multiple UDT cells in a single transaction. + + ```ts + const receiverB = + "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqflz4emgssc6nqj4yv3nfv2sca7g9dzhscgmg28x"; + const { script: lockB } = await ccc.Address.fromString( + receiverB, + signer.client + ); + let combinedTransferTx = ( + await pudt.transfer( + signer, + [ + { + to: lockB, + amount: 20000, + }, + ], + pudtTransferTx + ) + ).res; + ``` + +2. You only need to complete the inputs of the transaction just like processing any other transactions with CCC. + + ```ts + // Note: You need to connect your wallet for the following parts. You also need to have enough balance of pudt in your wallet. + combinedTransferTx = await pudt.completeBy(combinedTransferTx, signer); + await combinedTransferTx.completeFeeBy(signer); + await render(combinedTransferTx); + const combinedTransferTxHash = await signer.sendTransaction(combinedTransferTx); + + console.log(combinedTransferTxHash); + ``` diff --git a/packages/ssri/README.md b/packages/ssri/README.md index a74280be..cdd6d28f 100644 --- a/packages/ssri/README.md +++ b/packages/ssri/README.md @@ -36,18 +36,24 @@ Fully enabling CKB's Turing completeness and cryptographic freedom power.

-### Script-Sourced Rich Information +## Script-Sourced Rich Information -Read more about SSRI on [[EN/CN] Script-Sourced Rich Information - 来源于 Script 的富信息](https://talk.nervos.org/t/en-cn-script-sourced-rich-information-script/8256). +- Try interactive demo at [CCC App - SSRI](https://app.ckbccc.com/connected/SSRI) +- Read more about SSRI on [[EN/CN] Script-Sourced Rich Information - 来源于 Script 的富信息](https://talk.nervos.org/t/en-cn-script-sourced-rich-information-script/8256). -NOTE: This is the base package for interaction with SSRI-Compliant scripts. +>## NOTE: This is the base package for interaction with SSRI-Compliant scripts +> +>If you are looking for UDT support, please refer directly to [@ckb-ccc/udt](https://www.npmjs.com/package/@ckb-ccc/udt) which supports both SSRI-compliant UDT and legacy support for `xUDT` through `ckb-asset-indexer` (coming soon). -If you are looking for UDT support, please refer directly to [@ckb-ccc/udt](https://www.npmjs.com/package/@ckb-ccc/udt) which supports both SSRI-compliant UDT and falling back to xUDT. +## Additional Note -### Related Projects +- Currently `ExecutorJsonRpc` is the only supported `Executor`. There will be more in the future and legacy support for `xUDT` will be added through `ckb-asset-indexer`. +- A public SSRI Executor JSON RPC Point is being scheduled, and efforts to make to provide in-browser SSRI execution with WASM are under review at the moment. -- [`ssri-server`](https://github.com/ckb-devrel/ssri-server): Server for calling SSRI methods. -- [`ckb_ssri_sdk`](https://github.com/ckb-devrel/ckb_ssri_sdk): A toolkit to help developers build SSRI-Compliant scripts on CKB with production level example script `pausable-udt` for reference. +## Related Projects + +- [`ssri-server`](https://github.com/ckb-devrel/ssri-server): `ExecutorJSONRpc` server for calling SSRI methods. +- [`ckb-ssri-std`](https://github.com/ckb-devrel/ckb-ssri-std): A toolkit to help developers build SSRI-Compliant scripts on CKB.

Read more about CCC on our website or GitHub Repo. diff --git a/packages/udt/README.md b/packages/udt/README.md index 992f8fb7..28e4612b 100644 --- a/packages/udt/README.md +++ b/packages/udt/README.md @@ -36,65 +36,14 @@ Fully enabling CKB's Turing completeness and cryptographic freedom power.

-## Quick Start +## Note -- 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`. +- Try interactive demo at `[CCC App - UDT](!!!TODO - Add LINK!!!)` +- Currently `ExecutorJsonRpc` is the only supported `Executor`. There will be more in the future and extra legacy support for metadata of `xUDT` will be added through `ckb-asset-indexer`. -```ts -import { Server } from "@ckb-ccc/ssri"; -import { Udt, UdtPausable } from "@ckb-ccc/udt"; +> Note: A public SSRI Executor JSON RPC Point is being scheduled, and efforts are being made to make to provide in-browser SSRI execution with WASM. -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: - -```ts -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: - -```ts -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); -``` +- At the moment, `UDT` and `UDTPausable` from `@ckb-ccc/udt` are fully supported with SSRI by extending the `ssri.Trait` class in `@ckb-ccc/ssri`. While you can build your own SSRI-based SDK for your SSRI-compliant script in reference to `@ckb-ccc/udt`, in the future, there will be built in TypeScript generation directly based on the Rust source code on compilation.

Read more about CCC on our website or GitHub Repo.