https://github.com/cryptape/anyone-can-pay
A Lock script for CKB that can accept any amount of Simple UDT or CKB payment: https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0026-anyone-can-pay/0026-anyone-can-pay.md
https://github.com/cryptape/anyone-can-pay
Last synced: about 1 year ago
JSON representation
A Lock script for CKB that can accept any amount of Simple UDT or CKB payment: https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0026-anyone-can-pay/0026-anyone-can-pay.md
- Host: GitHub
- URL: https://github.com/cryptape/anyone-can-pay
- Owner: cryptape
- Created: 2024-01-24T06:19:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-25T08:22:15.000Z (over 2 years ago)
- Last Synced: 2025-01-30T01:17:28.016Z (over 1 year ago)
- Language: C
- Size: 43.9 KB
- Stars: 0
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ckb-anyone-can-pay
CKB anyone-can-pay lock.
[RFC Draft](https://talk.nervos.org/t/rfc-anyone-can-pay-lock/4438)
## Build
``` sh
make all-via-docker && cargo test
```
## Quick start
### Create
1, create a cell to receive UDT and CKB:
```
Cell {
lock: {
code_hash:
args:
}
data:
type:
}
```
2, create a cell to receive only CKB:
```
Cell {
lock: {
code_hash:
args:
}
data:
type:
}
```
3, we can add minimum amount transfer condition:
```
Cell {
lock: {
code_hash:
args: | |
}
data:
type:
}
```
`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`.
If the owner only wants to receive `UDT`, the owner can set `minimum CKB` to `255`.
### Send UDT and CKB
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.
```
# inputs
Cell {
lock: {
code_hash:
args: |
}
data:
type:
capacity: 100
}
...
# outputs
Cell {
lock: {
code_hash:
args: |
}
data:
type:
capacity: 200
}
...
```
### Signature
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).
Unlock a cell with a signature has no restrictions, which helps owner to manage the cell as he wants.