{"id":22192028,"url":"https://github.com/cryptape/anyone-can-pay","last_synced_at":"2025-03-24T20:44:23.675Z","repository":{"id":233858882,"uuid":"747542588","full_name":"cryptape/anyone-can-pay","owner":"cryptape","description":"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","archived":false,"fork":false,"pushed_at":"2024-01-25T08:22:15.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-01-30T01:17:28.016Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cryptape.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-24T06:19:55.000Z","updated_at":"2024-01-25T08:22:19.000Z","dependencies_parsed_at":"2024-04-17T14:29:41.542Z","dependency_job_id":null,"html_url":"https://github.com/cryptape/anyone-can-pay","commit_stats":null,"previous_names":["cryptape/anyone-can-pay"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptape%2Fanyone-can-pay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptape%2Fanyone-can-pay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptape%2Fanyone-can-pay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptape%2Fanyone-can-pay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryptape","download_url":"https://codeload.github.com/cryptape/anyone-can-pay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245351762,"owners_count":20601090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T12:18:46.429Z","updated_at":"2025-03-24T20:44:23.647Z","avatar_url":"https://github.com/cryptape.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ckb-anyone-can-pay\n\nCKB anyone-can-pay lock.\n\n[RFC Draft](https://talk.nervos.org/t/rfc-anyone-can-pay-lock/4438)\n\n## Build\n\n``` sh\nmake all-via-docker \u0026\u0026 cargo test\n```\n\n## Quick start\n\n### Create\n\n1, create a cell to receive UDT and CKB:\n\n```\nCell {\n    lock: {\n        code_hash: \u003cany-one-can-pay\u003e\n        args: \u003cpubkey hash\u003e\n    }\n    data: \u003cUDT amount\u003e\n    type: \u003cUDT\u003e\n}\n```\n\n2, create a cell to receive only CKB:\n\n```\nCell {\n    lock: {\n        code_hash: \u003cany-one-can-pay\u003e\n        args: \u003cpubkey hash\u003e\n    }\n    data: \u003cempty\u003e\n    type: \u003cnone\u003e\n}\n```\n\n3, we can add minimum amount transfer condition:\n\n```\nCell {\n    lock: {\n        code_hash: \u003cany-one-can-pay\u003e\n        args: \u003cpubkey hash\u003e | \u003cminimum CKB\u003e | \u003cminimum UDT\u003e\n    }\n    data: \u003cUDT amount\u003e\n    type: \u003cUDT\u003e\n}\n```\n\n`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`.\n\nIf the owner only wants to receive `UDT`, the owner can set `minimum CKB` to `255`.\n\n### Send UDT and CKB\n\nTo 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.\n\n```\n# inputs\nCell {\n    lock: {\n        code_hash: \u003cany-one-can-pay\u003e\n        args: \u003cpubkey hash\u003e | \u003cminimum CKB: 2\u003e\n    }\n    data: \u003cempty\u003e\n    type: \u003cnone\u003e\n    capacity: 100\n}\n...\n\n# outputs\nCell {\n    lock: {\n        code_hash: \u003cany-one-can-pay\u003e\n        args: \u003cpubkey hash\u003e | \u003cminimum CKB: 2\u003e\n    }\n    data: \u003cempty\u003e\n    type: \u003cnone\u003e\n    capacity: 200\n}\n...\n```\n\n### Signature\n\nThe 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).\n\nUnlock a cell with a signature has no restrictions, which helps owner to manage the cell as he wants.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptape%2Fanyone-can-pay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptape%2Fanyone-can-pay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptape%2Fanyone-can-pay/lists"}