{"id":19982587,"url":"https://github.com/sssshefer/erc1167-minimal-proxy","last_synced_at":"2025-03-01T20:13:00.887Z","repository":{"id":252645003,"uuid":"841029609","full_name":"sssshefer/ERC1167-minimal-proxy","owner":"sssshefer","description":"Minimal proxy Solidity smart contract implementation","archived":false,"fork":false,"pushed_at":"2024-08-11T14:44:31.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T10:48:26.718Z","etag":null,"topics":["blockchain","ethersjs","hardhat","solidity"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/sssshefer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-11T12:38:49.000Z","updated_at":"2024-08-11T14:45:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"d42ee95f-6646-4b40-824a-8c0d474cc158","html_url":"https://github.com/sssshefer/ERC1167-minimal-proxy","commit_stats":null,"previous_names":["sssshefer/minimal-proxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sssshefer%2FERC1167-minimal-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sssshefer%2FERC1167-minimal-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sssshefer%2FERC1167-minimal-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sssshefer%2FERC1167-minimal-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sssshefer","download_url":"https://codeload.github.com/sssshefer/ERC1167-minimal-proxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241418356,"owners_count":19959736,"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":["blockchain","ethersjs","hardhat","solidity"],"created_at":"2024-11-13T04:12:14.401Z","updated_at":"2025-03-01T20:13:00.867Z","avatar_url":"https://github.com/sssshefer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/user-attachments/assets/fa1bb4d7-0381-48f0-82cc-d8fbcd950270\" alt=\"proxy-image\"/\u003e\n\n# ERC1167-minimal-proxy\n\nThe **ERC1167-minimal-proxy** project showcases the implementation and usage of minimal proxy contracts (often referred to as \"clones\") based on the ERC1167 standard. This project provides a comprehensive guide to deploying and interacting with minimal proxy contracts, highlighting their efficiency and utility in various use cases. The project includes a simple example of deploying a proxy contract and executing functions through the proxy, demonstrating the practical benefits of this pattern.\n\n## Table of Contents\n- [Introduction](#erc1167-minimal-proxy)\n- [Theory Notes](#theory-notes)\n  - [What is Minimal Proxy](#what-is-minimal-proxy)\n  - [What is an Opcode](#what-is-an-opcode)\n  - [How Does It Work](#how-does-it-work)\n- [Features and Functionality](#features-and-functionality)\n- [Implementation](#implementation)\n  - [Contract Overview](#contract-overview)\n  - [Tests](#tests)\n- [Running the Project Locally](#running-the-project-locally)\n\n## Theory Notes\n\n### What is Minimal Proxy\nA minimal proxy contract is a lightweight contract that delegates all calls to a predefined implementation contract using the `DELEGATECALL` opcode. This pattern is popular in the Ethereum ecosystem for creating multiple instances of a contract that share the same logic, reducing gas costs by avoiding full contract deployment for each instance.\n\n### What is an Opcode\nAn opcode (short for \"operation code\") is a single instruction that specifies an operation for the Ethereum Virtual Machine (EVM) to execute. Opcodes are the low-level commands that drive the behavior of smart contracts on the Ethereum network. Each opcode represents a basic operation, such as arithmetic, data storage, or control flow, and is represented by a unique hexadecimal code. For example, `0xF3` corresponds to the `RETURN` opcode, which stops execution and returns output data. \n\n### How Does It Work\nThe minimal proxy contract works by delegating all calls to an implementation contract. The core of this pattern is a small piece of bytecode (known as the \"creation code\") that, when deployed, creates a contract forwarding all calls to the target implementation. The creation bytecode for a minimal proxy is constructed using a combination of opcodes and the address of the implementation contract. \n\nThe creation code typically looks like this:\n`3d60ad80600a3d3981f3363d3d373d3d3d363d73\u003cimplementation_address\u003e5af43d82803e903d91602b57fd5bf3`\nThis bytecode is responsible for creating a proxy contract that delegates calls to the specified implementation.\n\n## Features and Functionality\n- **Gas Efficiency:** Deploying minimal proxies is significantly cheaper than deploying full contracts.\n- **Delegation:** Proxies delegate calls to a predefined implementation contract, enabling code reuse.\n- **Factory Deployment:** Easily create new proxy instances with a factory contract.\n\n## Implementation\n\n### Contract Overview\nThis project consists of three main contracts:\n\n1. **ERC6551BytecodeLib:** A library that provides the creation code for deploying minimal proxies.\n2. **ProxyFactory:** A factory contract responsible for creating new minimal proxy instances.\n3. **Implementation:** A simple contract containing a state variable and a function to demonstrate the functionality of the proxy.\n\n### Tests\nThe project includes tests written in TypeScript to ensure that the minimal proxy pattern is implemented correctly. These tests deploy an implementation contract, use the `ProxyFactory` to create a proxy, and then interact with the proxy to verify that it correctly delegates calls to the implementation.\n\n## Running the Project Locally\nTo run this project locally:\n\n1. **Clone the repository:**\n    ```bash\n    git clone https://github.com/sssshefer/ERC1167-minimal-proxy.git\n    cd erc1167-minimal-proxy\n    ```\n\n2. **Install dependencies:**\n    ```bash\n    npm install\n    ```\n\n3. **Compile contracts:**\n    ```bash\n    npx hardhat compile\n    ```\n\n4. **Run tests:**\n    ```bash\n    npx hardhat test\n    ```\n\nThis setup allows you to explore the project and understand how minimal proxies work in practice.\n\n\u003chr/\u003e\n\n\u003ca href=\"https://ru.freepik.com/free-vector/people-carrying-arrows-opposite-directions_3585178.htm#fromView=search\u0026page=1\u0026position=5\u0026uuid=e89e33a2-08b8-495c-a4b0-84963195d57b\"\u003ePicture is from rawpixel.com on Freepik\u003c/a\u003e\n\n***Happy Hacking***\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsssshefer%2Ferc1167-minimal-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsssshefer%2Ferc1167-minimal-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsssshefer%2Ferc1167-minimal-proxy/lists"}