### Starting Local SSRI Server with Docker Source: https://github.com/alive24/ckb-ssri-std/blob/main/wikis/Quick Starts: Interact with SSRI Contract with @ckb-ccc.md This command starts a local SSRI server using Docker, mapping port 9090 from the container to the host. This server is essential for interacting with SSRI contracts in a local development environment. ```shell docker run -p 9090:9090 hanssen0/ckb-ssri-server ``` -------------------------------- ### Instantiating Pausable UDT and Enumerating Paused States (TypeScript) Source: https://github.com/alive24/ckb-ssri-std/blob/main/wikis/Quick Starts: Interact with SSRI Contract with @ckb-ccc.md This code illustrates instantiating a UDT as a UdtPausable to interact with its pausing capabilities. It then calls enumeratePaused() to retrieve a list of paused states or transactions, demonstrating interaction with a specific SSRI sub-trait. ```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"}]} ``` -------------------------------- ### Instantiating UDT and Querying Basic Info (TypeScript) Source: https://github.com/alive24/ckb-ssri-std/blob/main/wikis/Quick Starts: Interact with SSRI Contract with @ckb-ccc.md This snippet demonstrates how to create an instance of a UDT using its OutPoint and Type script, connecting to the local SSRI server. It then queries and logs the UDT's name and icon, showcasing basic interaction with the instantiated UDT object. ```ts const executor = new ccc.ssri.ExecutorJsonRpc("http://localhost:9090"); const pudt = new ccc.udt.Udt(pudtScriptCell.outPoint, pudtType, { executor }); 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,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMjQiIGN5PSIyNCIgcj0iMjQg...... ``` -------------------------------- ### Generating a Single UDT Transfer Transaction (TypeScript) Source: https://github.com/alive24/ckb-ssri-std/blob/main/wikis/Quick Starts: Interact with SSRI Contract with @ckb-ccc.md This snippet demonstrates generating a UDT transfer transaction using the transfer method. It defines a receiver address and specifies the amount to transfer, creating a ccc.TransactionLike object that handles most transaction details automatically. ```ts const receiverA = "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2jk6pyw9vlnfakx7vp4t5lxg0lzvvsp3c5adflu"; const { script: lockA } = await ccc.Address.fromString( receiverA, signer.client ); const pudtTransferTx = ( await pudt.transfer(signer, [ { to: lockA, amount: 10000 } ]) ).res; ``` -------------------------------- ### Completing and Sending a Combined UDT Transfer Transaction (TypeScript) Source: https://github.com/alive24/ckb-ssri-std/blob/main/wikis/Quick Starts: Interact with SSRI Contract with @ckb-ccc.md This snippet finalizes a ccc.TransactionLike object by completing its inputs and calculating fees using the signer. It then renders the transaction for user review (if applicable) and sends it to the CKB network, logging the resulting transaction hash. ```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); ``` -------------------------------- ### Preparing UDT Type Script Object (TypeScript) Source: https://github.com/alive24/ckb-ssri-std/blob/main/wikis/Quick Starts: Interact with SSRI Contract with @ckb-ccc.md This TypeScript code extracts the codeHash from the previously found UDT script cell and constructs a Type script object. This object is a fundamental component for defining and interacting with the UDT, ensuring correct identification and interaction with the contract on the CKB blockchain. ```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" }; ``` -------------------------------- ### Finding SSRI-Compliant UDT Script Cell (TypeScript) Source: https://github.com/alive24/ckb-ssri-std/blob/main/wikis/Quick Starts: Interact with SSRI Contract with @ckb-ccc.md This TypeScript snippet programmatically finds the OutPoint of an SSRI-compliant UDT script using its Type ID. It leverages the @ckb-ccc library and a signer client to query the blockchain for the specific cell, which is crucial for instantiating UDT contracts. ```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"); } ``` -------------------------------- ### Combining Multiple UDT Transfers into One Transaction (TypeScript) Source: https://github.com/alive24/ckb-ssri-std/blob/main/wikis/Quick Starts: Interact with SSRI Contract with @ckb-ccc.md This code shows how to combine multiple UDT transfers into a single transaction by passing a previously generated ccc.TransactionLike object to the transfer method. This allows for efficient batching of operations, reducing transaction fees and blockchain congestion. ```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; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.