Skip to content

Commit

Permalink
Merge pull request #16 from ckb-cell/docs/readme
Browse files Browse the repository at this point in the history
docs: Update readme
  • Loading branch information
duanyytop authored Jun 26, 2024
2 parents 38326e9 + 7539818 commit fd9a048
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A unique cell can be created on the Nervos CKB through [TypeID](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0022-transaction-structure/0022-transaction-structure.md#type-id) which makes sure the unique cell cannot be updated or destroyed.

The unique cell data can store any data, such as [XUDT](https://talk.nervos.org/t/rfc-extensible-udt/5337) token information and the contract will not check the content and format of the cell data.
The unique cell data can store any format data, such as [XUDT](https://talk.nervos.org/t/rfc-extensible-udt/5337) token information and the contract will not check the content and format of the cell data.

## Unique Type Script

Expand All @@ -11,18 +11,18 @@ unique type script:
code_hash:
unique_type
args:
type_id[0..20] // docs below describes how to generate this
type_id[0..20] // The following will provide a detailed explanation on how to generate the type_id
```
### How to generate args
### How to generate unique type script args
https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0022-transaction-structure/0022-transaction-structure.md#type-id
> There are two ways to create a new cell with a specific type id.
> 1. Create a transaction which uses any out point as tx.inputs[0] and has a output cell whose type script is Type ID. The output cell's type script args is the hash of tx.inputs[0] and its output index. Because any out point can only be used once as an input, tx.inputs[0] and thus the new type id must be different in each creation transaction.
> 2. Destroy an old cell with a specific type id and create a new cell with the same type id in the same transaction.
Implemetation can be found in `generator-example/src/index.ts`
Implementation can be found in `generator-example/src/index.ts`
```ts
const generateUniqueTypeArgs = (firstInput: CKBComponents.CellInput, firstOutputIndex: number) => {
const input = hexToBytes(serializeInput(firstInput));
Expand Down
2 changes: 1 addition & 1 deletion generator-example/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generator Example

``` sh
pnpm queue
pnpm install && pnpm queue
```

0 comments on commit fd9a048

Please sign in to comment.