{"id":24054655,"url":"https://github.com/cardinal-cryptography/psp22-example","last_synced_at":"2025-05-09T01:49:29.187Z","repository":{"id":103035409,"uuid":"566965047","full_name":"Cardinal-Cryptography/psp22-example","owner":"Cardinal-Cryptography","description":"Example PSP22 token implementation showcasing usage of various traits and off-chain interaction.","archived":false,"fork":false,"pushed_at":"2023-07-10T13:04:40.000Z","size":190,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T21:18:36.482Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/Cardinal-Cryptography.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,"publiccode":null,"codemeta":null}},"created_at":"2022-11-16T19:38:40.000Z","updated_at":"2024-11-29T14:07:47.000Z","dependencies_parsed_at":"2025-02-26T10:44:40.195Z","dependency_job_id":"d3bb2ca6-0b13-4777-8925-8f3e21e4d80f","html_url":"https://github.com/Cardinal-Cryptography/psp22-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fpsp22-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fpsp22-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fpsp22-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cardinal-Cryptography%2Fpsp22-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cardinal-Cryptography","download_url":"https://codeload.github.com/Cardinal-Cryptography/psp22-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253176439,"owners_count":21866142,"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":"2025-01-09T03:49:15.663Z","updated_at":"2025-05-09T01:49:29.177Z","avatar_url":"https://github.com/Cardinal-Cryptography.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NOTE: `main` branch of this repository contains contracts compatible with ink! 4.\n\n# Example PSP22 (ERC20) token contract\n\nThis repo contains an example implementation of the very basic PSP22 token standard using [OpenBrush library](https://openbrush.io/).\n\nWe're purposefully omitting more advanced constructs and focus on the basics to present self-contained, working example of a contract that implements various OpenBrush extensions for PSP22 token that people may find interesting:\n* [Token metadata](https://docs.openbrush.io/smart-contracts/PSP22/Extensions/metadata)\n* [Ownable modifiers](https://docs.openbrush.io/smart-contracts/ownable)\n* [Mint](https://docs.openbrush.io/smart-contracts/PSP22/Extensions/mintable)/[Burn](https://docs.openbrush.io/smart-contracts/PSP22/Extensions/burnable) functionality\n\nThe following extensions from the OpenBrush docs are missing:\n* [Wrapper](https://docs.openbrush.io/smart-contracts/PSP22/Extensions/wrapper)\n* [Flashmint](https://docs.openbrush.io/smart-contracts/PSP22/Extensions/flashmint)\n* [Pausable](https://docs.openbrush.io/smart-contracts/PSP22/Extensions/pausable)\n* [Capped](https://docs.openbrush.io/smart-contracts/PSP22/Extensions/capped)\n* [Timelock](https://docs.openbrush.io/smart-contracts/PSP22/Utils/token-timelock)\n\nbut should be possible to add if followed the guidelines presented here.\n\n## Repository structure\n\nThis repository contains two directories:\n* `/contracts` - containing implementations described above\n* `/client-cli` - a command-line tool for interacting with the deployed contract(s). We've tried to set some coding standards that focus on readability of the code which should maximize the educational value of the examples.\n\n## Setup\n\nBefore starting the work on the contracts make sure you have the necessary tools installed. Please follow our [official guide](https://docs.alephzero.org/aleph-zero/build/installing-required-tools).\n\n### Building contracts\n\nin `/contracts` subfolder, run `cargo +nightly contract build`.\n\n### Building CLI client.\n\nin `/client-cli` subfolder, run `cargo build --release`. This will create a binary in the standard `/targets/release/psp22-client` path.\n\n### Deploying contracts\n\nYou can use any of the online wallets connected to a network that is compatible with the correct version of ink! used. Or you can choose to run a local network.\n\nIn `/contracts` subfolder, run `./setup.sh` which, by default, will deploy to your local instance of the network.\n\n## Usage\n\nIf you wish to interact with already-deployed contracts you can use the `client-cli`:\n\n```shell\nUtilities for interacting with a sample PSP22 contract\n\nUsage: psp22-client [OPTIONS] -c \u003cCONTRACT_ADDRESS\u003e \u003cCOMMAND\u003e\n\nCommands:\n  psp22    \n  ownable  \n  help     Print this message or the help of the given subcommand(s)\n\nOptions:\n  -n, --node \u003cNODE_ADDRESS\u003e   WS endpoint address of the node [default: ws://localhost:9944]\n  -c \u003cCONTRACT_ADDRESS\u003e       On-chain address of a contract\n  -m \u003cCONTRACT_METADATA\u003e      Path to contract's metadata [default: metadata.json]\n  -h, --help                  Print help information\n  ```\n\n### Examples\n\n(I have previously deployed the example which now lives under address: `5FBHFs7eG9ZkajQgkwTA39WZ8yYXq43cAPyro1Pkkb6JejEy`)\n\n#### **Total supply:**\n\n  ```shell\n  psp22_example/client-cli$ ./target/release/psp22-client -n ws://localhost:9943 -c 5FBHFs7eG9ZkajQgkwTA39WZ8yYXq43cAPyro1Pkkb6JejEy psp22 total-supply\nTotal supply of the underlying token: 1000000\n```\n\n#### **Token metadata:**\n```shell\npsp22_example/client-cli$ ./target/release/psp22-client -n ws://localhost:9943 -c 5FBHFs7eG9ZkajQgkwTA39WZ8yYXq43cAPyro1Pkkb6JejEy psp22 get-token-metadata\nTokenMetadata { name: Some(\"TEST0\"), symbol: Some(\"T0\"), decimals: 12 }\n```\n\n#### **Balance of:**\n```shell\npsp22_example/client-cli$ ./target/release/psp22-client -n ws://localhost:9943 -c 5FBHFs7eG9ZkajQgkwTA39WZ8yYXq43cAPyro1Pkkb6JejEy psp22 balance-of -a 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\nBalance of d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...): 1000000\n```\n\n#### **Transfer:**\n```shell\npsp22_example/client-cli$ ./target/release/psp22-client -n ws://localhost:9943 -c 5FBHFs7eG9ZkajQgkwTA39WZ8yYXq43cAPyro1Pkkb6JejEy psp22 transfer --recipient 5Eo5ZxVUGbT6D8cfAvAxQFhzt3ZqBEb5oE8KCWR9vjvTPSMy --amount 100000 --account-seed //Alice\n\npsp22_example/client-cli$ ./target/release/psp22-client -n ws://localhost:9943 -c 5FBHFs7eG9ZkajQgkwTA39WZ8yYXq43cAPyro1Pkkb6JejEy psp22 balance-of -a 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\nBalance of d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...): 900000\n\npsp22_example/client-cli$ ./target/release/psp22-client -n ws://localhost:9943 -c 5FBHFs7eG9ZkajQgkwTA39WZ8yYXq43cAPyro1Pkkb6JejEy psp22 balance-of -a 5Eo5ZxVUGbT6D8cfAvAxQFhzt3ZqBEb5oE8KCWR9vjvTPSMy\nBalance of 78c9dcd1f5af0a3f67dda5d07847ad8aa4e5bd015f88669aa7e4b874040cca5b (5Eo5ZxVU...): 100000\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardinal-cryptography%2Fpsp22-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcardinal-cryptography%2Fpsp22-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcardinal-cryptography%2Fpsp22-example/lists"}