{"id":24838481,"url":"https://github.com/ratimon/redprint-forge","last_synced_at":"2025-04-09T22:13:15.648Z","repository":{"id":232993986,"uuid":"766487756","full_name":"Ratimon/redprint-forge","owner":"Ratimon","description":"A developer-friendly framework/library in solidity to deploy OPStack ’s contracts in a modular style.","archived":false,"fork":false,"pushed_at":"2025-02-15T09:08:03.000Z","size":369,"stargazers_count":51,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T22:13:08.357Z","etag":null,"topics":["ethereum","library","optimism","rollip","smartcontracts","solidity"],"latest_commit_sha":null,"homepage":"http://redprint.ninja/","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/Ratimon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2024-03-03T12:07:32.000Z","updated_at":"2025-02-18T14:12:29.000Z","dependencies_parsed_at":"2024-08-14T05:42:05.135Z","dependency_job_id":"95e6882b-b05a-4104-bfe9-99c3c654a3a7","html_url":"https://github.com/Ratimon/redprint-forge","commit_stats":null,"previous_names":["ratimon/redprint-forge"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ratimon%2Fredprint-forge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ratimon%2Fredprint-forge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ratimon%2Fredprint-forge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ratimon%2Fredprint-forge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ratimon","download_url":"https://codeload.github.com/Ratimon/redprint-forge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119292,"owners_count":21050755,"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":["ethereum","library","optimism","rollip","smartcontracts","solidity"],"created_at":"2025-01-31T06:20:26.538Z","updated_at":"2025-04-09T22:13:15.628Z","avatar_url":"https://github.com/Ratimon.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003eKeep Optimistic and be OPStack deployer!! \u003c/h1\u003e\n\n- [What is it for](#what-is-it-for)\n- [Quickstart](#quickstart)\n- [Contributing](#contributing)\n- [Acknowledgement](#acknowledgement)\n\n\u003e[!NOTE]\n\u003e You can find our alpha mvp and relevant examples [`here`](https://github.com/Ratimon/redprint-optimism-contracts-examples)\n\n\u003e[!WARNING]\n\u003e The code is not audited yet. Please use it carefully in production.\n\n\n## What Is It For\n\nOne of our Swiss army knife toolset: **redprint-forge** is a developer-friendly framework/library in solidity to modify \u0026 deploy OPStack ’s contracts in a modular style.\n\nThe features include:\n\n- Type-safe smart contract deployment\n\n- Re-usable  smart contract deployment and testing pipeline\n\n- Standardized framework, minimizing developer mistake and enhancing better security\n\n- All-Solidity-based so no context switching, no new scripting syntax in other languages\n\n- Tx Management via Safe Smart Contract Deploy Script\n\nTogether with [`Redprint Wizard UI`](https://github.com/Ratimon/redprint-wizard), which is a code generator/ interactive playground oriented for OPStack development, it does not only help novice developers to deploy OPStack's smart contracts to deploy on OP mainnet, but also help them to use generated deployment script in their own projects.\n\n\n## Quickstart\n### Quick Guide\n\n1.  Fork `optimism` 's monorepo:\n\n```bash\ngit clone --depth 1 --branch v1.9.4 https://github.com/ethereum-optimism/optimism.git\n``` \n\n\u003e[!NOTE]\n\u003e All OPStack's contracts are based on [`v1.9.4`](https://github.com/ethereum-optimism/optimism/tree/v1.9.4/packages/contracts-bedrock). So, you may just run:\n\n```bash\ngit clone https://github.com/ethereum-optimism/optimism.git\n``` \n\n2. Enter the working ditectory:\n\n```bash\ncd optimism/packages/contracts-bedrock\n``` \n\n3. Add the `redprint-forge` using your favorite package manager, e.g., with pnpm:\n\n```bash\npnpm init\n``` \n```bash\npnpm add redprint-forge\n``` \n```bash\npnpm install\n``` \n\n4. Modify OPStack 's [remapping](https://github.com/ethereum-optimism/optimism/blob/v1.9.4/packages/contracts-bedrock/foundry.toml) as following:\n\n```diff\n\n[profile.default]\n\n# Compilation settings\nsrc = 'src'\nout = 'forge-artifacts'\nscript = 'scripts'\noptimizer = true\noptimizer_runs = 999999\nremappings = [\n  '@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts',\n  '@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts',\n  '@openzeppelin/contracts-v5/=lib/openzeppelin-contracts-v5/contracts',\n  '@rari-capital/solmate/=lib/solmate',\n  '@lib-keccak/=lib/lib-keccak/contracts/lib',\n  '@solady/=lib/solady/src',\n  'forge-std/=lib/forge-std/src',\n  'ds-test/=lib/forge-std/lib/ds-test/src',\n  'safe-contracts/=lib/safe-contracts/contracts',\n  'kontrol-cheatcodes/=lib/kontrol-cheatcodes/src',\n  'gelato/=lib/automate/contracts'\n+ '@redprint-core/=src/',\n+ '@redprint-deploy/=node_modules/redprint-forge/script',\n+ '@scripts/=scripts/',\n+ '@redprint-test/=node_modules/redprint-forge/test/',\n+ '@redprint-forge-std/=lib/forge-std/src',\n+ '@redprint-openzeppelin/=lib/openzeppelin-contracts/contracts',\n+ '@redprint-openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts',\n+ '@redprint-safe-contracts/=lib/safe-contracts/contracts',\n+ '@redprint-lib-keccak/=lib/lib-keccak/contracts/lib',\n+ '@redprint-solady/=lib/solady/src',\n]\n...\n```\n\n\u003e[!TIP]\n\u003e We use @redprint-\u003cyourLib\u003e/ as a convention to avoid any naming conflicts with your previously installed libararies ( i.e. `@redprint-forge-std/` vs `@forge-std/`)\n\n\n5. Copy `.env` and modify as following.\n\n```sh\n\nRPC_URL_localhost=http://localhost:8545\n\n#secret management\nMNEMONIC=\"test test test test test test test test test test test junk\"\n# local network 's default private key so it is still not exposed\nDEPLOYER_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d\nDEPLOYER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8\n\n# script/Config.sol\nDEPLOYMENT_OUTFILE=deployments/31337/.save.json\nDEPLOY_CONFIG_PATH=deploy-config/hardhat.json\nCHAIN_ID=\nIMPL_SALT=$(openssl rand -hex 32)\nSTATE_DUMP_PATH=\nSIG=\nDEPLOY_FILE=\nDRIPPIE_OWNER_PRIVATE_KEY=9000\n\n# deploy-Config\nGS_ADMIN_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8\nGS_BATCHER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8\nGS_PROPOSER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8\nGS_SEQUENCER_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8\nL1_RPC_URL=http://localhost:8545\n```\n\n6. Copy a set of deploy scripts example except [`/deployer`](./script/deployer/):\n\n```sh\nrsync -av --exclude='deployer/' node_modules/redprint-forge/script/ script/\n```\n\nAlternatively:\n```sh\ncp node_modules/redprint-forge/script/example/* script/\n```\n\nNow, copy a test suite:\n```sh\ncp node_modules/redprint-forge/test/DeployAll.t.sol test/\n```\n\n7. Compile and run test:\n\nThis will take a while to compile:\n```sh\nforge b\n```\n\nThen run a test command against a copied set of deploy scripts:\n```sh\nforge test -vvvv --match-path test/DeployAll.t.sol\n```\n\n\u003e[!NOTE]\n\u003eBehind the scene, the test suite works by replicating the same environment as production script, because it utilizes the same deployment logic script inside `setUp()` as following:\n\n```ts\n\n/** ... */\n\n// deployment logic\nimport {DeployAllScript} from \"@scripts/000_DeployAll.s.sol\";\n\ncontract DeployAll_Test is Test {\n\n    /** ... */\n\n    function setUp() external {\n\n         /** ... */\n\n        deployerProcedue = getDeployer();\n        deployerProcedue.setAutoBroadcast(false);\n\n        DeployAllScript allDeployments = new DeployAllScript();\n        allDeployments.run();\n\n        deployerProcedue.deactivatePrank();\n\n    }\n    /** ... */\n\n}\n```\n\n\u003e[!NOTE]\n\u003e You can chekout [this](https://github.com/Ratimon/redprint-forge/blob/main/script/example/000_DeployAll.s.sol)\n\n\n### Tx Management Via Safe-Multisig\n\nYou can write solidity script, then execute it from command-line in order to make any smart contract calls, or send transactions from your own safe multi-sig wallet.\n\nYou can access both [`_upgradeAndCallViaSafe`](https://github.com/Ratimon/redprint-forge/blob/main/script/safe-management/SafeScript.sol#L27) and [`_callViaSafe`](https://github.com/Ratimon/redprint-forge/blob/main/script/safe-management/SafeScript.sol#L23) easily by inheriting and using from  in `redprint-forge` module ’s parent contract [`SafeScript`](https://github.com/Ratimon/redprint-forge/blob/main/script/safe-management/SafeScript.sol).\n \n#### Call and Upgrade Proxy Contract\n\nLet’s see a practical example when initializing one of OPStack's proxy contract ( eg. [`ProtocolVersions`](https://github.com/Ratimon/redprint-forge/blob/main/src/L1/ProtocolVersions.sol) ) by calling [`_upgradeAndCallViaSafe`](https://github.com/Ratimon/redprint-forge/blob/main/script/safe-management/SafeScript.sol#L27C1-L28C1):\n\n```ts\n\n/** ... */\n\n// `redprint-forge` 's core engine\nimport { SafeScript} from \"@redprint-deploy/safe-management/SafeScript.sol\";\n\n/** ... */\n\ncontract DeployAndInitializeProtocolVersionsScript is DeployScript, SafeScript {\n\n    /** ... */\n\n    function initializeProtocolVersions() public {\n      console.log(\"Upgrading and initializing ProtocolVersions proxy\");\n\n      /** ... */\n\n      address proxyAdmin = deployer.mustGetAddress(\"ProxyAdmin\");\n      address safe = deployer.mustGetAddress(\"SystemOwnerSafe\");\n\n      /** ... */\n\n      _upgradeAndCallViaSafe({\n          _proxyAdmin: proxyAdmin,\n          _safe: safe,\n          _owner: owner,\n          _proxy: payable(protocolVersionsProxy),\n          _implementation: protocolVersions,\n          _innerCallData: abi.encodeCall(\n              ProtocolVersions.initialize,\n              (\n                  finalSystemOwner,\n                  ProtocolVersion.wrap(requiredProtocolVersion),\n                  ProtocolVersion.wrap(recommendedProtocolVersion)\n              )\n          )\n      });\n      /** ... */\n    }\n\n}\n\n```\n\n\u003e[!NOTE]\n\u003e You can the see full example here: [`03B_DeployAndInitializeProtocolVersions.s.sol`](https://github.com/Ratimon/redprint-optimism-contracts-examples/blob/main/script/203B_DeployAndInitializeProtocolVersions.s.sol)\n\n#### Call to Any Contract with arbitrary data\n\nLet’s see another example at [`SafeScript`](https://github.com/Ratimon/redprint-forge/blob/main/script/safe-management/SafeScript.sol) itselfs. Our internal function just calls [`_callViaSafe`](https://github.com/Ratimon/redprint-forge/blob/main/script/safe-management/SafeScript.sol#L23):\n\n```ts\n/** ... */\n\nabstract contract SafeScript {\n\n  /** ... */\n\n  function _upgradeAndCallViaSafe( address _owner, address _proxyAdmin, address _safe, address _proxy, address _implementation, bytes memory _innerCallData) internal {\n\n      bytes memory data =\n          abi.encodeCall(ProxyAdmin.upgradeAndCall, (payable(_proxy), _implementation, _innerCallData));\n\n      Safe safe = Safe(payable(_safe));\n      _callViaSafe({ _safe: safe, _owner: _owner, _target: _proxyAdmin, _data: data });\n  }\n\n  /** ... */\n\n}\n```\n\n## Contributing\n\nWe are currently still in an experimental phase leading up to a first audit and would love to hear your feedback on how we can improve `Reprint`.\n\nIf you want to say **thank you** or/and support active development of redprint-forge:\n\n- Add a [GitHub Star](https://github.com/Ratimon/redprint-forge) to the\n  project.\n- Tweet about **redprint**.\n- Write interesting articles about the project on\n  [Medium](https://medium.com/), or your personal blog.\n- Keep Optimistic !!\n\n## Acknowledgement\n\nThis project would not have been possible to build without the advanced iniatiative from opensource software including  [forge-deploy](https://github.com/wighawag/forge-deploy), so we are deeply thankful for their contributions in our web3 ecosystem.\n\nIf we’ve overlooked anyone, please open an issue so we can correct it. While we always aim to acknowledge the inspirations and code we utilize, mistakes can happen in a team setting, and a reference might unintentionally be missed.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratimon%2Fredprint-forge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fratimon%2Fredprint-forge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratimon%2Fredprint-forge/lists"}