{"id":21180215,"url":"https://github.com/7i7o/tokengate","last_synced_at":"2026-03-04T06:31:31.636Z","repository":{"id":57681228,"uuid":"493245692","full_name":"7i7o/TokenGate","owner":"7i7o","description":"Gas Optimized NFT for Token Gating","archived":false,"fork":false,"pushed_at":"2023-03-13T13:47:47.000Z","size":35,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-05T16:22:55.519Z","etag":null,"topics":["ethereum","nft","solidity","token-gating"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/7i7o.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":"2022-05-17T12:40:25.000Z","updated_at":"2025-01-08T00:22:49.000Z","dependencies_parsed_at":"2024-10-30T03:23:58.499Z","dependency_job_id":null,"html_url":"https://github.com/7i7o/TokenGate","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":"0.19999999999999996","last_synced_commit":"346a7837f57dbc51a5c0e4404af8a614b79f3882"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/7i7o/TokenGate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7i7o%2FTokenGate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7i7o%2FTokenGate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7i7o%2FTokenGate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7i7o%2FTokenGate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/7i7o","download_url":"https://codeload.github.com/7i7o/TokenGate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7i7o%2FTokenGate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264505239,"owners_count":23618909,"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":["ethereum","nft","solidity","token-gating"],"created_at":"2024-11-20T17:42:01.979Z","updated_at":"2026-03-04T06:31:31.590Z","avatar_url":"https://github.com/7i7o.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ERC721TGNT (NFTs for Token Gating, Non-Transferable)\n\n## ERC721 Non-Transferable Implementation, focused on saving gas for Token Gating\n\n### Using owner Address as TokenId\n\nThe intent of this implementation is to save as much gas as possible by trimming down on storage and evm instructions from the stardard implementations (being OpenZeppelin's the most widely used).\n\nThe use of common implementations depend on storing data for owner, id, approved and (multiple) approvedForAll, and using this for common tokenGating wastes a lot of gas on deploying contracts and more importantly minting, which wastes users gas.\n\nSince the objective of token gating is allowing access of an address by checking a token ownership, several use cases don't need this access being exchanged on secondary markets. By removing these transfers, there's no need for approvals or aperators, allowing us to improve gas use on the smart contract thus making deployment, minting and burning far more efficient.\n\nThis implementation aims to provide a way for users and developers to take advantage of this and saving gas by inheriting it.\n\nThis project was developed using the [Foundry](getfoundry.sh) smart contract development toolchain.\n## Installing\n\n### npm\n\nIf you use npm, you can install by running: \n\n```bash\nnpm i @7i7o/tokengate\n```\n\n### Foundry\n\nIf you are using Foundry (or Forge)just run:\n\n```bash\nforge install 7i7o/TokenGate\n```\n\nand add a line in your remappings.txt file (it should sit on your main project folder) with:\n\n```\n@7i7o/tokengate=lib/TokenGate/\n```\n\n## Usage\n\nNow you can import it in your solidity files like this:\n\n```solidity\nimport \"@7i7o/tokengate/src/ERC721TGNT.sol\";\n```\n\nTo inherit this, you need to implement the contructor on your contract and pass a `Name` and a `Symbol` for your NFTs, like this:\n\n```solidity\ncontract Contract is ERC721TGNT {\n\n    constructor() ERC721TGNT(\"Name\", \"Symbol\") {}\n\n}\n```\n\n## Dev Instructions\n\nTo tinker with the implementation, you only need to fork this repo and start hacking.\n\nTo build (compile) you can run:\n\n```bash\nforge build\n```\n\nto build, run:\n\n```bash\nforge test\n```\n\n## Gas Comparison\n\nTo have a estimate of gas savings for users and deployers, i ran basic tests deploying a basic contract that inherited OpenZeppelin's ERC721 and another set that inherited ERC721TGNT, both exposing basic _safeMint functionality.\n\nI ran one test for creating a new contract, and another to create the contract and mint 1 token (to measure only minting gas).\n\nThe results of gas spent in each test for each contract can be seen in the table below\n\n| Function      |     TGNT      | OpenZeppelin  |  % Gas Saved by TGNT |\n| ------------- |--------------:| -------------:|---------------------:|\n| `deploy`      |        649500 |       1168364 |               44.41% |\n| `safeMint`    |         26930 |         49462 |               45.55% |\n\nThat's roughly **45%** gas saving on both **deploy** and **mint**.\n\n\n## Example of deployment\n\nTo see an example of usage, the contract has been inherited and deployed on Ethereum Mainnet, with the address [`0xEC800E57D8B258D69CCaBb0D807dA98c89E6C76a`](https://etherscan.io/address/0xEC800E57D8B258D69CCaBb0D807dA98c89E6C76a#code#F2#L1) \n\n\n___\nMIT License\n\nCopyright (c) 2022 7i7o\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7i7o%2Ftokengate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F7i7o%2Ftokengate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7i7o%2Ftokengate/lists"}