{"id":25715084,"url":"https://github.com/cqlyj/simple-tba-erc6551","last_synced_at":"2026-06-12T06:02:40.663Z","repository":{"id":261637537,"uuid":"884858567","full_name":"cqlyj/simple-tba-erc6551","owner":"cqlyj","description":"Simple ERC6551 Standard Walk-through Demo","archived":false,"fork":false,"pushed_at":"2024-11-08T04:34:10.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-14T11:46:57.888Z","etag":null,"topics":["erc6551","example","foundry","smart-contracts","solidity","walkthrough"],"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/cqlyj.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":"2024-11-07T14:14:14.000Z","updated_at":"2025-02-24T06:41:48.000Z","dependencies_parsed_at":"2024-11-07T16:42:35.224Z","dependency_job_id":"af223cde-1001-484a-8934-4262af38ce39","html_url":"https://github.com/cqlyj/simple-tba-erc6551","commit_stats":null,"previous_names":["cqlyj/tba-erc6551","cqlyj/simple-tba-erc6551"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cqlyj/simple-tba-erc6551","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqlyj%2Fsimple-tba-erc6551","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqlyj%2Fsimple-tba-erc6551/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqlyj%2Fsimple-tba-erc6551/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqlyj%2Fsimple-tba-erc6551/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cqlyj","download_url":"https://codeload.github.com/cqlyj/simple-tba-erc6551/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cqlyj%2Fsimple-tba-erc6551/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34231212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["erc6551","example","foundry","smart-contracts","solidity","walkthrough"],"created_at":"2025-02-25T13:34:29.626Z","updated_at":"2026-06-12T06:02:40.658Z","avatar_url":"https://github.com/cqlyj.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Token Bounded Account - ERC6551 - Minimal Walkthrough\n\nThis project is a minimal walkthrough of the ERC6551 standard. The ERC6551 standard is a token bounded account standard that allows for the creation of a token that is bound to an account. This means that the token can only be transferred to the account that it is bound to.\n\n# Getting Started\n\n## Requirements\n\n- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)\n  - You'll know you did it right if you can run `git --version` and you see a response like `git version x.x.x`\n- [foundry](https://getfoundry.sh/)\n  - You'll know you did it right if you can run `forge --version` and you see a response like `forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)`\n\n## Quickstart\n\n```\ngit clone https://github.com/cqlyj/tba-erc6551\ncd tba-erc6551\nmake\n```\n\n## Testing\n\nRun:\n\n```\nforge test\n```\n\n# Usage - Walkthrough the ERC6551 standard\n\n1. Set up your environment variables:\n\n```bash\ncp .env.example .env\n```\n\nIf you just want to run this in local anvil chain, the .env.example already have those pre-configured. You can just delete other env variables.\n\n2. Spin up a local anvil chain:\n\n```bash\nmake anvil\n```\n\n3. Spin up a new terminal and run:\n\n```bash\nmake walk-through\n```\n\nThen you can see that we first deploy `MyNft` contract, then deploy `Registry` contract, then deploy `AccountImplementation` contract with the anvil account index 0.\nMint the NFT to the anvil account index 1, then `createAccount` and try to execute function in the `AccountImplementation` contract. Here we just send 1 ethers to the anvil account index 0.\nYou can see outputs log below:\n\n```bash\n== Logs ==\n  Most recently deployed Registry contract:  0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512\n  Account created:  0x026091B08c11e2F39f1e0E9a9599dbf732824300\n  1 ethers transferred to anvilAccount\n  anvilAccount balance:  10000998121551806573964\n  anvilAccount2 balance:  9999000000000000000000\n```\n\nWe successfully transferred 1 ethers to the anvil account index 0. Since the owner of Nft is anvil account index 1, so the balance of anvil account index 1 is deducted by 1 ethers.\n\nYou can try change the address to other address rather than the anvil account index 1, the transaction will revert since the NFT is not owned by other address.\nSimply change the code in `RegistryInteractions.s.sol`:\n\n```diff\nfunction execute(address accountImplementationAddress) public {\n        bytes memory data = abi.encodeWithSignature(\n            \"execute(address,uint256,bytes,uint8)\",\n            anvilAccount,\n            1e18,\n            \"\",\n            uint8(0)\n        );\n        // the MyNft is minted to anvilAccount2\n-       vm.startBroadcast(anvilAccount2);\n+       // Any address other than anvilAccount2 will revert, here we change to anvilAccount.\n+       vm.startBroadcast(anvilAccount);\n\n        (bool success, ) = accountImplementationAddress.call{value: 1e18}(data);\n        if (!success) {\n            console.log(\"Failed to execute transaction\");\n        }\n\n        console.log(\"1 ethers transferred to anvilAccount\");\n        console.log(\"anvilAccount balance: \", address(anvilAccount).balance);\n        console.log(\"anvilAccount2 balance: \", address(anvilAccount2).balance);\n\n        vm.stopBroadcast();\n    }\n```\n\nThen you can see output like this:\n\n```bash\n [74039] 0x0165878A594ca255338adfa4d48449f69242Eb8F::createAccount(0xa513E6E4b8f2a923D98304ec87F64353C4D5C853, 0x0000000000000000000000000000000000000000000000000000000000000000, 31337 [3.133e4], 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707, 0)\n    ├─ [34655] → new \u003cunknown\u003e@0xf6917B9Cb25FEBec3c14c12404436C12A9DeE19d\n    │   └─ ← [Return] 173 bytes of code\n    ├─ emit ERC6551AccountCreated(account: 0xf6917B9Cb25FEBec3c14c12404436C12A9DeE19d, implementation: 0xa513E6E4b8f2a923D98304ec87F64353C4D5C853, salt: 0x0000000000000000000000000000000000000000000000000000000000000000, chainId: 31337 [3.133e4], tokenContract: 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707, tokenId: 0)\n    └─ ← [Return] 0xf6917B9Cb25FEBec3c14c12404436C12A9DeE19d\n\n  [9674] 0xf6917B9Cb25FEBec3c14c12404436C12A9DeE19d::execute{value: 1000000000000000000}(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, 1000000000000000000 [1e18], 0x, 0)\n    ├─ [6979] 0xa513E6E4b8f2a923D98304ec87F64353C4D5C853::execute{value: 1000000000000000000}(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, 1000000000000000000 [1e18], 0x, 0) [delegatecall]\n    │   ├─ [2642] 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707::ownerOf(0) [staticcall]\n    │   │   └─ ← [Return] 0x70997970C51812dc3A010C7d01b50e0d17dc79C8\n    │   └─ ← [Revert] Account__InvalidSigner()\n    └─ ← [Revert] Account__InvalidSigner()\n\nError: Simulated execution failed.\n```\n\nYeah, we have a `Account__InvalidSigner` error.\n\n## Contact\n\nLuo Yingjie - [luoyingjie0721@gmail.com](luoyingjie0721@gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcqlyj%2Fsimple-tba-erc6551","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcqlyj%2Fsimple-tba-erc6551","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcqlyj%2Fsimple-tba-erc6551/lists"}