{"id":15918468,"url":"https://github.com/0xfps/diamond","last_synced_at":"2025-03-24T08:33:36.261Z","repository":{"id":53923978,"uuid":"519998876","full_name":"0xfps/Diamond","owner":"0xfps","description":"A practical outlook into the Diamond contract structure.","archived":false,"fork":false,"pushed_at":"2023-01-20T08:39:42.000Z","size":31,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"dev","last_synced_at":"2025-03-19T03:13:48.326Z","etag":null,"topics":["diamond","ethereum","facets","solidity"],"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/0xfps.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}},"created_at":"2022-08-01T06:57:14.000Z","updated_at":"2024-12-27T19:55:15.000Z","dependencies_parsed_at":"2023-02-12T00:45:29.356Z","dependency_job_id":null,"html_url":"https://github.com/0xfps/Diamond","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/0xfps%2FDiamond","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfps%2FDiamond/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfps%2FDiamond/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfps%2FDiamond/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xfps","download_url":"https://codeload.github.com/0xfps/Diamond/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245235803,"owners_count":20582309,"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":["diamond","ethereum","facets","solidity"],"created_at":"2024-10-06T18:42:16.435Z","updated_at":"2025-03-24T08:33:35.984Z","avatar_url":"https://github.com/0xfps.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Diamond\n\n### EIP-2535\n\nA practical outlook into the Diamond contract structure.\n\n\u003cbr/\u003e\n\nFor more information on Diamonds and Facets:\n- https://eips.ethereum.org/EIPS/eip-2535.\n- https://soliditydeveloper.com/eip-2535.\n- [Diamond Contract Codebase](https://github.com/mudgen/diamond-2-hardhat).\n\n###\n## WHY DO WE USE A LIBRARY FOR DIAMOND STORAGE?\nPersonally, I think that using libraries with internal functions gives us that opportunity to interact with the library imported when  the facet is imported. \n\nAs the library functions are internal, they are added to the bytecode of the Diamond contract hence the library's `myStorage()` can share the same storage with the Diamond, giving it the ability to write, read and modify a particular storage slot in the Diamond, hence storages can be easily read and modified.\n\nBecause, if we used a contract, we cannot explicitly interact with it, unless we initialize a new contract which makes things difficult.\n\n\n## STEPS\n\n- Deploy `facets/AdditionFacet.sol`.\n- Deploy `Diamond.sol`.\n- Get selectors from `facets/AdditionFacet.sol` using `getAddHash` and `getReturnTotalHash` or simply copy `\"add(uint256,uint256)\"` and `\"returnTotal()\"`.\n- Set the selectors in the `Diamond.sol` using the `addFunctionBySelector` or `addFunctionByString`.\n- \u003e Set the `\"add(uint256,uint256)\"` and `\"returnTotal()\"`.\n- Call the `add` function in the `Diamond.sol`.\n- Check the `testTotal` variable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xfps%2Fdiamond","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xfps%2Fdiamond","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xfps%2Fdiamond/lists"}