{"id":21220293,"url":"https://github.com/k1-r1/clonecontractdemos","last_synced_at":"2026-01-01T22:06:49.678Z","repository":{"id":43396584,"uuid":"465476982","full_name":"K1-R1/CloneContractDemos","owner":"K1-R1","description":"This repo demos usage of Openzeppelin's clone library in order to improve the deployment of factory smart contracts in certain conditions","archived":false,"fork":false,"pushed_at":"2022-03-05T17:36:42.000Z","size":188,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T16:46:39.888Z","etag":null,"topics":["hardhat","openzeppelin","smart-contracts","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/K1-R1.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-03-02T21:36:49.000Z","updated_at":"2022-04-14T13:08:40.000Z","dependencies_parsed_at":"2022-09-05T19:41:27.929Z","dependency_job_id":null,"html_url":"https://github.com/K1-R1/CloneContractDemos","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/K1-R1%2FCloneContractDemos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K1-R1%2FCloneContractDemos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K1-R1%2FCloneContractDemos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K1-R1%2FCloneContractDemos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/K1-R1","download_url":"https://codeload.github.com/K1-R1/CloneContractDemos/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243667973,"owners_count":20328036,"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":["hardhat","openzeppelin","smart-contracts","solidity"],"created_at":"2024-11-20T22:10:12.783Z","updated_at":"2026-01-01T22:06:49.567Z","avatar_url":"https://github.com/K1-R1.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CloneContractDemos\n\nThis repo demos usage of Openzeppelin's clone library in order to improve the deployment of factory smart contracts in certain conditions. Clones, as described in [ERC1167](https://eips.ethereum.org/EIPS/eip-1167), are very small, and cheap to deploy, smart-contract that delegates all incoming calls to a master functionality contract. The address of this master contract being stored directly in the contract code, no `sload` is required.\n\nThe gas report produced by the tests shows the gas savings one can expect from using clones.\n\n## Examples\n\n1. **ERC20**\n\n  - Gas report:\n\n    | Contract     | Methods        | Gas       |\n    | ------------ | -------------- | --------: |\n    | FactoryNaive | constructor    | 1,245,959 |\n    | FactoryProxy | constructor    | 1,675,235 |\n    | FactoryClone | constructor    | 1,305,848 |\n    | FactoryNaive | createToken    | 1,179,977 |\n    | FactoryProxy | createToken    |   368,401 |\n    | FactoryClone | createToken    |   209,109 |\n    | FactoryNaive | ERC20.transfer |    51,092 |\n    | FactoryProxy | ERC20.transfer |    52,776 |\n    | FactoryClone | ERC20.transfer |    51,870 |\n\n2. **UniswapV2**\n\n  - Gas report:\n\n    | Contract               | Methods    | Gas       |\n    | ---------------------- | ---------- | --------: |\n    | UniswapV2Factory       | createPair | 2,020,039 |\n    | UniswapV2FactoryClones | createPair |   218,099 |\n\n  - Comment:\n\n    While deployment cost is greatly reduced, each transaction (including internal transaction) to a pair will require an additional delegate call from the proxy to the `UniswapV2Pair` implementation. These delegate calls, while cheap on a \"per-transaction\" basis, will eventually make the clone option more expensive to the community.\n\n    It is a good thing that UniswapV2 doesn't use clones for pairs with high volume; however some low-traffic pairs would have benefited from a cheap deployment.\n\n3. **Argent**\n\n  - Gas report:\n\n    | Contract            | Methods                    | Gas     |\n    | ------------------- | -------------------------- | ------: |\n    | WalletFactory       | createCounterfactualWallet | 322,302 |\n    | WalletFactoryClones | createCounterfactualWallet | 265,422 |\n\n## Advantages and disadvanteges of clones\n\n**Advantages**\n- Cheaper deployment\n- Compatible with proxy based factories\n- Cheaper to call than a storage-based proxy\n\n**Disadvantages**\n- Non-upgradable\n- Calls are more expensive; leading to potentially greater expense in some cases, as outlined for Uniswap above.\n\n## Made with\n- Solidity\n- Hardhat\n\n## This repo is inspired by;\n- Openzeppelin's workshop; [Contract Clones Workshop](https://github.com/OpenZeppelin/workshops/blob/master/02-contracts-clone/README.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1-r1%2Fclonecontractdemos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk1-r1%2Fclonecontractdemos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1-r1%2Fclonecontractdemos/lists"}