0
0
Blockchain / Solidityprogramming~30 mins

Minimal proxy (clone) pattern in Blockchain / Solidity - Mini Project: Build & Apply

Choose your learning style9 modes available
Minimal Proxy (Clone) Pattern in Solidity
📖 Scenario: You are building a smart contract system on Ethereum. You want to create many lightweight copies (clones) of a main contract to save gas and storage. This is useful when you have a standard contract logic but want separate instances for different users.
🎯 Goal: Build a minimal proxy contract that clones a main contract using the EIP-1167 minimal proxy pattern. You will create the main contract, then write a factory contract that deploys clones pointing to the main contract.
📋 What You'll Learn
Create a main contract called LogicContract with a public uint variable value and a function setValue(uint _value) to update it.
Create a factory contract called CloneFactory with a function createClone(address target) that deploys a minimal proxy clone of target using assembly.
Store the address of the deployed clone in a public variable lastClone.
Write a function getCloneValue() in the factory that calls value() on the last clone and returns it.
Print the address of the last clone and the value stored in it.
💡 Why This Matters
🌍 Real World
Minimal proxy clones save gas and storage on Ethereum by reusing contract logic. This pattern is widely used in DeFi and NFT projects to deploy many instances cheaply.
💼 Career
Understanding minimal proxies is important for blockchain developers working on scalable smart contract systems and optimizing gas costs.
Progress0 / 4 steps
1
Create the main contract with a value variable and setter
Create a contract called LogicContract with a public uint variable named value. Add a public function setValue(uint _value) that sets value to _value.
Blockchain / Solidity
Need a hint?

Think of LogicContract as the main blueprint. It has a number value and a way to change it.

2
Add the clone factory contract with createClone function
Create a contract called CloneFactory. Inside it, declare a public address variable lastClone. Add a public function createClone(address target) that deploys a minimal proxy clone of target using assembly and stores the clone address in lastClone. Use the standard EIP-1167 bytecode pattern for the clone.
Blockchain / Solidity
Need a hint?

Use assembly to write the minimal proxy bytecode. The pattern is fixed and uses the create opcode.

3
Add a function to get the value from the last clone
In the CloneFactory contract, add a public view function getCloneValue() that calls the value() function on the lastClone address using staticcall and returns the uint value.
Blockchain / Solidity
Need a hint?

Use staticcall to safely call the value() function on the clone without changing state.

4
Print the last clone address and its stored value
Add a public view function printLastCloneInfo() in CloneFactory that returns the lastClone address and the uint value from getCloneValue(). Then write a simple script or test that deploys LogicContract, deploys CloneFactory, creates a clone of LogicContract, sets the value on the clone to 42, and prints the clone address and value.
Blockchain / Solidity
Need a hint?

Return both the clone address and its stored value. The test script simulates deployment and interaction.