{"id":19147816,"url":"https://github.com/refcell/metamorphic","last_synced_at":"2025-05-07T03:04:15.288Z","repository":{"id":62008793,"uuid":"556946895","full_name":"refcell/metamorphic","owner":"refcell","description":"Huff-based Smart Contracts for creating Metamorphic (or \"redeployable\") EVM Contracts.","archived":false,"fork":false,"pushed_at":"2023-06-21T16:14:49.000Z","size":1720,"stargazers_count":46,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T03:02:36.570Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/refcell.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-10-24T20:18:31.000Z","updated_at":"2024-07-05T13:03:08.000Z","dependencies_parsed_at":"2024-11-09T07:52:36.113Z","dependency_job_id":"80ad443e-7681-4d3c-96dd-33a3df3aba76","html_url":"https://github.com/refcell/metamorphic","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/refcell%2Fmetamorphic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Fmetamorphic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Fmetamorphic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Fmetamorphic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/refcell","download_url":"https://codeload.github.com/refcell/metamorphic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252804206,"owners_count":21806769,"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":"2024-11-09T07:52:26.787Z","updated_at":"2025-05-07T03:04:15.235Z","avatar_url":"https://github.com/refcell.png","language":"Solidity","funding_links":[],"categories":["Solidity"],"sub_categories":[],"readme":"\u003cimg align=\"right\" width=\"150\" height=\"150\" top=\"100\" src=\"./assets/metamorphic.jpg\"\u003e\n\n# metamorphic ![tests](https://img.shields.io/github/workflow/status/abigger87/metamorphic/ci/main?label=tests) ![license](https://img.shields.io/github/license/abigger87/metamorphic?label=License) ![solidity](https://img.shields.io/badge/solidity-^0.8.15-lightgrey) ![huff](https://img.shields.io/badge/huff-0.3.0-8b6c5c)\n\n[Huff](https://github.com/huff-language) Smart Contracts for creating Metamorphic (or \"redeployable\") EVM Contracts.\n\n\u003e **Note**\n\u003e This is a rewrite of [0age](https://github.com/0age)'s [metamorphic contracts](https://github.com/0age/metamorphic) in [Huff](https://github.com/huff-language).\n\n\n### A Trip Down Ethereum History\n\nPrior to [EIP-1014](https://eips.ethereum.org/EIPS/eip-1014) (included in the Constantinople hard fork), contracts on ethereum were _completely_ immutable. Code deployed to a given address could only be created and subsequently destroyed using the `CREATE` and `SELFDESTRUCT` opcodes. Migrating contracts involved replaying state onto a new contract, which is expensive and not scalable.\n\nFortunately, [EIP-1014](https://eips.ethereum.org/EIPS/eip-1014) introduced the `CREATE2` opcode, a form of [\"wild magic\"](https://medium.com/@jason.carver/defend-against-wild-magic-in-the-next-ethereum-upgrade-b008247839d2) allowing a contract to be **redeployed to the same address with different bytecode**.\n\n`CREATE2` uses the **caller’s address**, a supplied **salt** parameter, and the **initialization code** of the contract that is created. Altering any one of these parameters will result in your bytecode being deployed to a completely different contract address.\n\nCool, so we have completely deterministic, redeployable contracts on Ethereum using `CREATE2`, right?\n\nWell, this fails if the initialization code of the contract is non-deterministic. [0age](https://github.com/0age) presents a simple example: consider a contract that calls into some external contract and uses the variable return data to construct the final bytecode. Then the initialization code is in fact non-deterministic, and `CREATE2` will generate an entirely new address for each time the contract is redeployed if the return data from the external contract changes.\n\n\n\n\n\n\n\n\n// TODO:\n\n\n### Usage\n\n**Deploying Metamorphic Contracts**\n\n// TODO:\n\nClone factory contracts should use the [`HuffCloneLib`](src/HuffCloneLib.huff) library. `CLONE` is the main macro for creating clones.\n\nContracts intended to be cloned should include [`HuffClone`](src/HuffClone.huff) to get access to the helper macros for reading immutable args.\n\nTo see an example usage of the library, check out [`ExampleClone`](src/ExampleClone.huff) and [`ExampleCloneFactory`](src/ExampleCloneFactory.huff).\n\n**Installing as a Foundry Library**\n\nTo install with [Foundry](https://github.com/foundry-rs/foundry):\n\n```\nforge install abigger87/metamorphic\n```\n\n\u003e **Warning**\n\u003e\n\u003e These contracts are **unaudited** and are not recommended for use in production.\n\u003e\n\u003e Although contracts have been rigorously reviewed, this is **experimental software** and is provided on an \"as is\" and \"as available\" basis.\n\u003e We **do not give any warranties** and **will not be liable for any loss** incurred through any use of this codebase.\n\n\n### Contracts\n\n```txt\n.\n├─ src\n|  ├─ interfaces\n|  |  ├─ IImmutableCreate2Factory.sol — \n|  |  ├─ IMetamorphicFactory.sol — \n|  |  └─ IMetapod.sol — \n|  ├─ ImmutableCreate2Factory.huff — \n|  ├─ MetamorphicFactory.huff — \n|  ├─ Metapod.huff — \n|  └─ TransientContract.huff — \n└─ tests\n   └─ 🧪🧪🧪\n```\n\n### Acknowledgements\n\n- [femplate](https://github.com/0age/metamorphic)\n- [huffplate](https://github.com/abigger87/huffplate)\n- [forge-std](https://github.com/brockelmore/forge-std)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefcell%2Fmetamorphic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefcell%2Fmetamorphic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefcell%2Fmetamorphic/lists"}