{"id":19788769,"url":"https://github.com/hbarcelos/forge-multi-version","last_synced_at":"2025-05-01T00:31:28.208Z","repository":{"id":50320718,"uuid":"518604238","full_name":"hbarcelos/forge-multi-version","owner":"hbarcelos","description":"Using forge with multiple solc versions","archived":false,"fork":false,"pushed_at":"2022-07-27T21:33:47.000Z","size":12,"stargazers_count":26,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T05:53:10.000Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hbarcelos.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-07-27T20:34:55.000Z","updated_at":"2024-03-30T23:01:01.000Z","dependencies_parsed_at":"2022-08-29T05:30:21.834Z","dependency_job_id":null,"html_url":"https://github.com/hbarcelos/forge-multi-version","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/hbarcelos%2Fforge-multi-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbarcelos%2Fforge-multi-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbarcelos%2Fforge-multi-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hbarcelos%2Fforge-multi-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hbarcelos","download_url":"https://codeload.github.com/hbarcelos/forge-multi-version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224229909,"owners_count":17277257,"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-12T06:28:45.549Z","updated_at":"2024-11-12T06:28:46.292Z","avatar_url":"https://github.com/hbarcelos.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using `forge` with multiple `solc` versions\n\nThis is a proof of concept to enable multi-version Solidity projects with [Foundry](https://book.getfoundry.sh/).\n\nThis example uses Solidity `0.6.12` and `0.8.14`, but in theory it could work for any two or more versions.\n\n## Rationale\n\n- Use Foundry built-in [profiles](https://book.getfoundry.sh/reference/config#profiles) for different Solidity versions.\n  Use the `default` profile for the \"main\" version (`0.8.14` in this case).\n- Have separate `src` directories for each version.\n- Have separate `lib` directories for each version, but allow the non-default versions to pull compatible dependencies\n  from the default one.\n- Test files and Solidity scripts go into the `src` directories and not in separate `test` and `script` ones.\n\n## Usage\n\nCompile the non-default versions first:\n```\nFOUNDRY_PROFILE=0_6_x forge build\n```\n\nCompile the default version last:\n```\nforge build\n```\n\n---\n\n**⚠️ WARNING:** `forge` will overwrite the compiled files in `out/` for whichever contracts that were compiled with\n`FOUNDRY_PROFILE=0_6_x` with the compiled files using the default profile. In other words, any contracts that were\naccessible with the `0.6.x` compiler will be overwritten by the default profile using Solidity `0.8.x` if the commands\nare run in the order above. Keep that in mind if you are using this approach to deploy contracts, you might end up\nsubmitting the bytecode generated by a different compiler version than what you intended.\n\n---\n\nTo reference contracts from compiled with versions, use the [`getCode()` cheat code][get-code].\n\n  [get-code]: https://book.getfoundry.sh/cheatcodes/get-code\n\n```solidity\npragma solidity ^0.8.14;\n\nimport \"forge-std/Test.sol\";\n\ncontract MyTest is Test {\n    Contract myContract = new Contract();\n\n    function testDeployContractWithAnotherVersion() public {\n        address anotherAddress = deployCode(\"Contract6.sol:Contract6\");\n\n        // Different compiler versions will produce different bytecodes\n        assertTrue(keccak256(address(myContract).code) != keccak256(anotherAddress.code)); // [PASS]\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbarcelos%2Fforge-multi-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhbarcelos%2Fforge-multi-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhbarcelos%2Fforge-multi-version/lists"}