{"id":13561531,"url":"https://github.com/bitlightlabs/bitlight-rgb20-contract-testnet4","last_synced_at":"2025-04-03T17:31:08.707Z","repository":{"id":248486532,"uuid":"828797377","full_name":"bitlightlabs/bitlight-rgb20-contract-testnet4","owner":"bitlightlabs","description":"Demonstrating the RGB20 Contract using RGB v0.11.0-beta and Testing RGB Features on Testnet4","archived":false,"fork":false,"pushed_at":"2024-07-15T06:42:42.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-04T13:37:40.050Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://bitlightlabs.com","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitlightlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2024-07-15T06:37:25.000Z","updated_at":"2024-07-31T07:01:59.000Z","dependencies_parsed_at":"2024-07-15T09:22:42.198Z","dependency_job_id":"446bea37-67db-4df1-a377-4f668b4e8407","html_url":"https://github.com/bitlightlabs/bitlight-rgb20-contract-testnet4","commit_stats":null,"previous_names":["bitlightlabs/bitlight-rgb20-contract-testnet4"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitlightlabs%2Fbitlight-rgb20-contract-testnet4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitlightlabs%2Fbitlight-rgb20-contract-testnet4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitlightlabs%2Fbitlight-rgb20-contract-testnet4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitlightlabs%2Fbitlight-rgb20-contract-testnet4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitlightlabs","download_url":"https://codeload.github.com/bitlightlabs/bitlight-rgb20-contract-testnet4/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247046859,"owners_count":20874733,"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-08-01T13:00:57.971Z","updated_at":"2025-04-03T17:31:03.699Z","avatar_url":"https://github.com/bitlightlabs.png","language":"Rust","funding_links":[],"categories":["Services"],"sub_categories":["Main RGB Standards"],"readme":"# bitlight-rgb20-contract-testnet4\nDemonstrating the RGB20 Contract using RGB v0.11.0-beta and Testing RGB Features on Testnet4\n\n## Pre-request\n\nTo complete the demo, you need to set up the following toolchains:\n\n**⚠️ Warning:** Because the `RGB-WG` official repository has not yet merged the Testnet4-related PR, we are temporarily relying on the bitlightlabs repository.\n\n1. [Git][git]\n2. [Rust][rust]\n3. [RGB-CLI][rgb-cli]\n\n[git]: https://git-scm.com/\n\n[rust]: https://www.rust-lang.org/tools/install\n\n[rgb-cli]: https://github.com/will-bitlight/rgb\n\n### RGB-CLI\n\nFirst, clone it from GitHub:\n\n```bash\ngit clone https://github.com/will-bitlight/rgb.git\ncd rgb\ngit checkout testnet4\n```\n\nThen, build it, copy the binary to `~/.cargo/bin/`:\n\n```\ncargo build --package rgb-wallet --bin rgb --release \ncp target/release/rgb ~/.cargo/bin/\n```\n\n### Key preparation\n\nUsers should prepare two funded keys in advance on bitcoin-testnet4.\n\nIf not, you can use the public test key provided by bitlight below.\n\n```\n# Alice\n[5183a8d8/86'/1'/0']tpubDDtdVYn7LWnWNUXADgoLGu48aLH4dZ17hYfRfV9rjB7QQK3BrphnrSV6pGAeyfyiAM7DmXPJgRzGoBdwWvRoFdJoMVpWfmM9FCk8ojVhbMS/\u003c0;1;9;10\u003e/*\"\n\n# Bob\n[3abb3cbb/86'/1'/0']tpubDDeBXqUqyVcbe75SbHAPNXMojntFu5C8KTUEhnyQc74Bty6h8XxqmCavPBMd1fqQQAAYDdp6MAAcN4e2eJQFH3v4txc89s8wvHg98QSUrdL/\u003c0;1;9;10\u003e/*\n```\n\n## Create and Import Contract\n\nTo create a RGB20 contract, just clone this repo to you local machine. Then\ncompile and run it.\n\n```bash\ngit clone https://github.com/bitlightlabs/bitlight-rgb20-contract-testnet4.git\ncd bitlight-rgb20-contract-testnet4\n```\n\nedit main.rs, change the beneficiary to alice's address\n\nNote: The following `1240a...f6d51e` is the transaction-id in which Alice receives the payment. `0` is the index of the output of the transaction.\n\n```rust\nlet beneficiary_txid = Txid::from_hex(\"1240a21693434f5e872551ded3d349692490db7839aff89a1667e78d36f6d51e\").unwrap();\nlet beneficiary = Outpoint::new(beneficiary_txid, 0);\n```\n\n```\nmake run\n```\n\n```text\nThe issued contract data:\n{\"ticker\":\"TEST\",\"name\":\"Test asset\",\"details\":null,\"precision\":\"centiMicro\"}\namount=adMhBHaQ, owner=bc:tapret1st:1240a21693434f5e872551ded3d349692490db7839aff89a1667e78d36f6d51e:0, witness=~\ntotalSupply=adMhBHaQ\n\nContracts are available in the examples directory\n---------------------------------\n./examples:\n-rw-r--r--  1 bitlight  staff  5639 Jul 12 21:52 rgb20-simplest.rgb\n-rw-r--r--  1 bitlight  staff  7548 Jul 12 21:52 rgb20-simplest.rgba\n---------------------------------\n```\n\nNow, we are creating a RGB20 #TEST contract, which stores in `examples` fold.\n\n\nBefore importing contracts, let's import our wallets to rgb.\n\nExport `LNPBP_NETWORK` env set the network environment used by the wallet to bitcoin-testnet4.\n\nExport `MEMPOOL_SERVER` env set the data source used by the wallet to mempool-testnet4\n\n```bash\nexport LNPBP_NETWORK=testnet4\nexport MEMPOOL_SERVER=\"https://mempool.space/testnet4/api\"\n```\n\nCreate rgb wallet container for Alice:\n\n```bash\n# rgb -d .alice create default --tapret-key-only \u003calice-fixed-xpub-descriptor\u003e\n$ rgb -d .alice create default --tapret-key-only \"[5183a8d8/86'/1'/0']tpubDDtdVYn7LWnWNUXADgoLGu48aLH4dZ17hYfRfV9rjB7QQK3BrphnrSV6pGAeyfyiAM7DmXPJgRzGoBdwWvRoFdJoMVpWfmM9FCk8ojVhbMS/\u003c0;1;9;10\u003e/*\"\n\nLoading descriptor from command-line argument ... success\nSyncing keychain 0 ........... keychain 1 .......... keychain 9 ........... keychain 10 .......... success\nSaving the wallet as 'default' ... success\n\n$ rgb -d .alice utxos\n\nHeight     Amount, ṩ    Outpoint                                                            \ntb1pn0s2pajhsw38fnpgcj79w3kr3c0r89y3xyekjt8qaudje70g4shs8keguu  \u00260/0\n34489         245069    f5fcd7d27fe8e0915942f65c97886a2bffc674fcd1d77f5e952f4bebac8cf601:0\n34506         100000    f656506f6909ab44b78320859dd5bd8b3f2634a471c706649574cba485392dc7:1\n\ntb1pr3rupmav8a7av7dqfyvynu2wk02lduggnh9ln4ndze9aqvuv9y3smxy992  \u00269/0\n34527         108000    1240a21693434f5e872551ded3d349692490db7839aff89a1667e78d36f6d51e:0\n\nLoading descriptor from wallet default ... success\n\nWallet total balance: 453069 ṩ\n\n```\n\nCreate rgb wallet container for Bob:\n\n```bash\n# rgb -d .bob create default --tapret-key-only \u003cbob-fixed-xpub-descriptor\u003e\n\n$ rgb -d .bob create default --tapret-key-only \"[3abb3cbb/86'/1'/0']tpubDDeBXqUqyVcbe75SbHAPNXMojntFu5C8KTUEhnyQc74Bty6h8XxqmCavPBMd1fqQQAAYDdp6MAAcN4e2eJQFH3v4txc89s8wvHg98QSUrdL/\u003c0;1;9;10\u003e/*\"\n\nLoading descriptor from command-line argument ... success\nSyncing keychain 0 ........... keychain 1 .......... keychain 9 ........... keychain 10 .......... success\nSaving the wallet as 'default' ... success\n\n$ rgb -d .bob utxos\n\nHeight     Amount, ṩ    Outpoint                                                            \ntb1plphl407vyfpml2thhypzuqk232256njnaw4zhtmyrrku66pqn9ustvvjsd  \u00260/0\n34491          66123    6b5c3df74418e04a9f580625288f53c321121a2028c572c984940b60f8de7725:0\n\ntb1p9yjaffzhuh9p7d9gnwfunxssngesk25tz7rudu4v69dl6e7w7qhqellhrw  \u00269/0\n34528         121000    ce8dc940f5ff7c5867b9102f2e9e6588fa8f668c0d41d01d803b50f41c0ba56c:1\n\nLoading descriptor from wallet default ... success\n\nWallet total balance: 187123 ṩ\n\n```\n\nImport contract for Alice\n\n```\n$ rgb -d .alice import examples/rgb20-simplest.rgb\n\nImporting consignment rgb:csg:OzVmRfgj-9IJSfE1-mA6T3a0-j3eTOk8-nOgjsaQ-etElCHc#athena-voyage-everest:\n- validating the contract rgb:WvHfDZDt-8UNnXDY-JuOjr2A-1n8T3hV-avzUeh2-sfNyku4 ... success\nConsignment is imported\n```\n\nAfter that, we can inspect contracts state with `rgb state` command.\n\nget the state of the contract for Alice\n\n```bash\n$ rgb -d .alice contracts\n\nrgb:WvHfDZDt-8UNnXDY-JuOjr2A-1n8T3hV-avzUeh2-sfNyku4    bitcoin                 2024-07-12      rgb:sch:KzMZV9bO7gFhox97!klj0FonG2ZKnjuOIg2tFChu$YA#lucas-episode-silicon       \n  Developer: ssi:anonymous\n\n# rgb -d \u003cDATA_DIR\u003e state \u003cCONTRACT_ID\u003e \u003cIFACE\u003e\n$ rgb -d .alice state 'rgb:WvHfDZDt-8UNnXDY-JuOjr2A-1n8T3hV-avzUeh2-sfNyku4' RGB20Fixed\n\nGlobal:\n  spec := (ticker=(\"TEST\"), name=(\"Test asset\"), details=~, precision=8)\n  terms := (text=(\"\"), media=~)\n  issuedSupply := (100000000000)\n\nOwned:\n  assetOwner:\n    value=100000000000, utxo=bc:tapret1st:1240a21693434f5e872551ded3d349692490db7839aff89a1667e78d36f6d51e:0, witness=~ \n```\n\nImport contract For Bob:\n\n```bash\n$ rgb -d .bob import examples/rgb20-simplest.rgb\n$ rgb -d .bob contracts\n$ rgb -d .bob state 'rgb:WvHfDZDt-8UNnXDY-JuOjr2A-1n8T3hV-avzUeh2-sfNyku4' RGB20Fixed\n\nGlobal:\n  spec := (ticker=(\"TEST\"), name=(\"Test asset\"), details=~, precision=8)\n  terms := (text=(\"\"), media=~)\n  issuedSupply := (100000000000)\n\nOwned:\n  assetOwner:\n```\n\nNow we have successfully created an rgb20 token, and the owner\nis `bc:tapret1st:1240a21693434f5e872551ded3d349692490db7839aff89a1667e78d36f6d51e:0`, which belongs to Alice.\n\n## Transfer\n\nThere are about five steps in a complete transfer:\n\n1. Create an invoice\n2. Construct a PSBT\n3. Make a transfer\n4. Accept the transfer\n\n### Create an invoice\n\nTo receive 1,000 #Test, Bob needs to create an invoice and send it to Alice.\n\n```bash\n$ rgb -d .bob invoice 'rgb:WvHfDZDt-8UNnXDY-JuOjr2A-1n8T3hV-avzUeh2-sfNyku4' RGB20Fixed 2000\n\nrgb:WvHfDZDt-8UNnXDY-JuOjr2A-1n8T3hV-avzUeh2-sfNyku4/RGB20Fixed/TadF+tb:utxob:!TvWPzkY-Sx6U9fY-S5Cjx3V-!D3v75N-DefZ5W7-ymNJceu-vAgLw\n```\n\n### Make a transfer\n\n```bash\n$ rgb -d .alice transfer 'rgb:WvHfDZDt-8UNnXDY-JuOjr2A-1n8T3hV-avzUeh2-sfNyku4/RGB20Fixed/TadF+tb:utxob:!TvWPzkY-Sx6U9fY-S5Cjx3V-!D3v75N-DefZ5W7-ymNJceu-vAgLw' transfer.consignment alice.psbt\n```\n\nThe consignment is saved in the `transfer.consignment` file, and needs to be sent to Bob, who is waiting to accept it.\n\n### Accept transfer\n\nAfter receiving the `transfer.consignment` file, Bob could validate it before accepting.\n\n```bash\n$ rgb -d .bob validate transfer.consignment\nThe provided consignment is valid\n```\n\nBob accepts the consignment:\n\n```bash\n$ rgb -d .bob accept -f transfer.consignment\nTransfer accepted into the stash\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitlightlabs%2Fbitlight-rgb20-contract-testnet4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitlightlabs%2Fbitlight-rgb20-contract-testnet4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitlightlabs%2Fbitlight-rgb20-contract-testnet4/lists"}