Skip to content

Commit 403a0c3

Browse files
committed
Update readme
1 parent 5bd5756 commit 403a0c3

File tree

2 files changed

+96
-93
lines changed

2 files changed

+96
-93
lines changed

README.md

+2-93
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,3 @@
1-
# ckb-anyone-can-pay
1+
# ckb production scripts
22

3-
CKB anyone-can-pay lock.
4-
5-
[RFC Draft](https://talk.nervos.org/t/rfc-anyone-can-pay-lock/4438)
6-
7-
## Build
8-
9-
``` sh
10-
make all-via-docker && cargo test
11-
```
12-
13-
## Quick start
14-
15-
### Create
16-
17-
1, create a cell to receive UDT and CKB:
18-
19-
```
20-
Cell {
21-
lock: {
22-
code_hash: <any-one-can-pay>
23-
args: <pubkey hash>
24-
}
25-
data: <UDT amount>
26-
type: <UDT>
27-
}
28-
```
29-
30-
2, create a cell to receive only CKB:
31-
32-
```
33-
Cell {
34-
lock: {
35-
code_hash: <any-one-can-pay>
36-
args: <pubkey hash>
37-
}
38-
data: <empty>
39-
type: <none>
40-
}
41-
```
42-
43-
3, we can add minimum amount transfer condition:
44-
45-
```
46-
Cell {
47-
lock: {
48-
code_hash: <any-one-can-pay>
49-
args: <pubkey hash> | <minimum CKB> | <minimum UDT>
50-
}
51-
data: <UDT amount>
52-
type: <UDT>
53-
}
54-
```
55-
56-
`minimum CKB` and `minimum UDT` are two optional args, each occupied a byte, and represent `10 ^ x` minimal amount. The default value is `0` which means anyone can transfer any amount to the cell. A transfer must satisfy the `minimum CKB` **or** `minimum UDT`.
57-
58-
If the owner only wants to receive `UDT`, the owner can set `minimum CKB` to `255`.
59-
60-
### Send UDT and CKB
61-
62-
To transfer coins to an anyone-can-pay lock cell, the sender must build an output cell that has the same `lock_hash` and `type_hash` to the input anyone-can-pay lock cell; if the input anyone-can-pay cell has no `data`, the output cell must also be empty.
63-
64-
```
65-
# inputs
66-
Cell {
67-
lock: {
68-
code_hash: <any-one-can-pay>
69-
args: <pubkey hash> | <minimum CKB: 2>
70-
}
71-
data: <empty>
72-
type: <none>
73-
capacity: 100
74-
}
75-
...
76-
77-
# outputs
78-
Cell {
79-
lock: {
80-
code_hash: <any-one-can-pay>
81-
args: <pubkey hash> | <minimum CKB: 2>
82-
}
83-
data: <empty>
84-
type: <none>
85-
capacity: 200
86-
}
87-
...
88-
```
89-
90-
### Signature
91-
92-
The owner can provide a secp256k1 signature to unlock the cell, the signature method is the same as the [P2PH](https://github.com/nervosnetwork/ckb-system-scripts/wiki/How-to-sign-transaction#p2ph).
93-
94-
Unlock a cell with a signature has no restrictions, which helps owner to manage the cell as he wants.
3+
CKB scripts used in production.

docs/ckb-anyone-can-pay.md

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# ckb-anyone-can-pay
2+
3+
CKB anyone-can-pay lock.
4+
5+
[RFC Draft](https://talk.nervos.org/t/rfc-anyone-can-pay-lock/4438)
6+
7+
## Build
8+
9+
``` sh
10+
make all-via-docker && cargo test
11+
```
12+
13+
## Quick start
14+
15+
### Create
16+
17+
1, create a cell to receive UDT and CKB:
18+
19+
```
20+
Cell {
21+
lock: {
22+
code_hash: <any-one-can-pay>
23+
args: <pubkey hash>
24+
}
25+
data: <UDT amount>
26+
type: <UDT>
27+
}
28+
```
29+
30+
2, create a cell to receive only CKB:
31+
32+
```
33+
Cell {
34+
lock: {
35+
code_hash: <any-one-can-pay>
36+
args: <pubkey hash>
37+
}
38+
data: <empty>
39+
type: <none>
40+
}
41+
```
42+
43+
3, we can add minimum amount transfer condition:
44+
45+
```
46+
Cell {
47+
lock: {
48+
code_hash: <any-one-can-pay>
49+
args: <pubkey hash> | <minimum CKB> | <minimum UDT>
50+
}
51+
data: <UDT amount>
52+
type: <UDT>
53+
}
54+
```
55+
56+
`minimum CKB` and `minimum UDT` are two optional args, each occupied a byte, and represent `10 ^ x` minimal amount. The default value is `0` which means anyone can transfer any amount to the cell. A transfer must satisfy the `minimum CKB` **or** `minimum UDT`.
57+
58+
If the owner only wants to receive `UDT`, the owner can set `minimum CKB` to `255`.
59+
60+
### Send UDT and CKB
61+
62+
To transfer coins to an anyone-can-pay lock cell, the sender must build an output cell that has the same `lock_hash` and `type_hash` to the input anyone-can-pay lock cell; if the input anyone-can-pay cell has no `data`, the output cell must also be empty.
63+
64+
```
65+
# inputs
66+
Cell {
67+
lock: {
68+
code_hash: <any-one-can-pay>
69+
args: <pubkey hash> | <minimum CKB: 2>
70+
}
71+
data: <empty>
72+
type: <none>
73+
capacity: 100
74+
}
75+
...
76+
77+
# outputs
78+
Cell {
79+
lock: {
80+
code_hash: <any-one-can-pay>
81+
args: <pubkey hash> | <minimum CKB: 2>
82+
}
83+
data: <empty>
84+
type: <none>
85+
capacity: 200
86+
}
87+
...
88+
```
89+
90+
### Signature
91+
92+
The owner can provide a secp256k1 signature to unlock the cell, the signature method is the same as the [P2PH](https://github.com/nervosnetwork/ckb-system-scripts/wiki/How-to-sign-transaction#p2ph).
93+
94+
Unlock a cell with a signature has no restrictions, which helps owner to manage the cell as he wants.

0 commit comments

Comments
 (0)