{"id":26054956,"url":"https://github.com/morpho-org/semitransferable-token","last_synced_at":"2025-04-11T02:51:13.681Z","repository":{"id":37860671,"uuid":"495968130","full_name":"morpho-org/semitransferable-token","owner":"morpho-org","description":"A token with revokable transfer restrictions.","archived":false,"fork":false,"pushed_at":"2024-07-11T11:12:51.000Z","size":869,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-25T00:40:43.338Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Solidity","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/morpho-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":"audits/Morpho_Omniscia.pdf","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-24T19:52:23.000Z","updated_at":"2024-10-27T05:10:04.000Z","dependencies_parsed_at":"2025-03-08T10:00:47.188Z","dependency_job_id":"68cbac4f-c0e4-4274-8d93-32f339cfb44a","html_url":"https://github.com/morpho-org/semitransferable-token","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fsemitransferable-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fsemitransferable-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fsemitransferable-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fsemitransferable-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morpho-org","download_url":"https://codeload.github.com/morpho-org/semitransferable-token/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248333101,"owners_count":21086191,"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-03-08T10:00:32.063Z","updated_at":"2025-04-11T02:51:13.660Z","avatar_url":"https://github.com/morpho-org.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"(remember to `git submodule update --init --recursive` after cloning)\n\n# Token with revocable transfer restrictions\n\n## Summary\n* Based on solmate code.\n* Adds authorizer `mint`.\n* Users can `burn` their tokens.\n* Requires authentication on `transfer`, `transferFrom` and `mint`.\n* Can remove authentication later.\n* Editable `script/deploy.sol` to set token name,symbol \u0026 owner.\n\n**The Auth contract differs from solmate's vanilla Auth** : `authority` is itself. This saves a SLOAD and a bit more.\n\n**The RolesAuthority contract differs from solmate's vanilla RoleAuthority** : it inherits the modified `Auth` and always has itself as a target.\n\n**The contract is structured** as inheriting from `ERC20` and `RolesAuthority`. It defines itself as its own authority, so authenticated methods call `this.canCall` to check authorization.\n\n**The owner is given in the constructor** and the owner can mint, and transfer at will. Once the proper authorizations have been setup, the owner should be set to `0`.\n\nWe decide on the following roles:\n\n| Role | Can call                   |\n|------|----------------------------|\n| 0    | `transfer`, `transferFrom` |\n| 1    | `mint`                     |\n\n**To set roles**, owner should call (once):\n```soldity\ntoken.setRoleCapability(0,Token.transfer.selector,true);\ntoken.setRoleCapability(0,Token.transferFrom.selector,true);\ntoken.setRoleCapability(1,Token.mint.selector,true);\n```\n**This will be done automatically when calling `deploy.sol`**\n\n**To give transfer rights** to an address `addr`, owner should call:\n```solidity\ntoken.setUserRole(addr,0,true);\n```\n\n**To enable transfers for everyone**, owner should call:\n```\ntoken.setPublicCapability(Token.transfer.selector,true);\ntoken.setPublicCapability(Token.transferFrom.selector,true);\n```\nCompared to regular transfers, there will then be 1 extra SLOAD (loading the boolean `isCapabilityPublic(address(token), Token.transfer*.selector)`).\n\n**To give mint rights**, to an address `addr`, owner should call\n```solidity\ntoken.setUserRole(addr,1,true); // for mint\n```\n\n**To remove itself**, owner should call (⚠️ There is no going back ⚠):\n```solidity\ntoken.setOwner(address(0));\n```\n\n## Audits\n\nThe code has been audited by [Omniscia](https://omniscia.io) and the report can be found [online](https://omniscia.io/morpho-specialized-token/) or in this file [Morpho_Omniscia](./audits/Morpho_Omniscia.pdf).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fsemitransferable-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorpho-org%2Fsemitransferable-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fsemitransferable-token/lists"}