Comments (6)
Hey @mrwillis - no worries, here is fine.
- The contract should not be a solidity
library
- it should be an ordinary contract but likely with an initialization pattern such as the one in the example. Yes - theThing
that is deployed initially is the master contract - the code for which is run for each of the 'clones' but with the clones' storage. - The one without the numeric suffix is the easiest to start with. The numbered ones can be used to squeeze a few bytes of deployment cost out of the system by using a vanity contract address for the master. Not necessary in most cases. The numbers refer to the number of non-leading-zero bytes in the vanity address of the master contract.
Make sense?
Good luck and happy cloning!
Rock on,
pete
from clone-factory.
from clone-factory.
@mrwillis Just to elaborate on what pete said a little bit, there is no Solidity source for the cloned contracts. We wrote the assembly so it was as small as possible while still having complete return data and revert capabilities. If I were to write the equivalent of what it does in Solidity, it would just be a payable fallback function that takes the call data and calls the master contract with it, returns the result (including revert data), and does nothing else. If you wrote this in Solidity though, the bytecode would be a good amount larger.
from clone-factory.
Thanks all for the help. I managed to get it to work. I got my 500 line contract to be deployed with ~100k gas! Great improvement.
from clone-factory.
Thanks Pete.
Just so I have this clear, there still are contracts being deployed, it's just that these contracts simply delegatecall
ing everything to the master contract, is this right?
As well, if you had to write the source of the clones (in solidity), what would it look like? Just the storage members, the event and static declarations, and a bunch of methods with one line forwarding the call to the master with delegatecall
?
Thanks again.
from clone-factory.
Great stuff, @mrwillis - I'll close this issue for now, feel free to reopen or just comment on it if you have further questions.
from clone-factory.
Related Issues (20)
- Action required: Greenkeeper could not be activated 🚨
- EIP-1167 - Minimal Proxy Contract HOT 38
- Odd behaviour with msg.sender HOT 2
- Should not destroy cloned contract HOT 1
- Include in OpenZeppelin? HOT 2
- Use in production? HOT 5
- Why so many clone factory contracts? HOT 3
- create2 HOT 8
- Immutably owned clones HOT 3
- failure of the delegatecall should revert with return data
- Update for newer Solidity version HOT 1
- Estimate right amount of gas to receive ether
- Are custom errors bubbled up too?
- Settle on either "package-lock.json" or "yarn.lock"
- Outdated version of Solidity compiler version. HOT 2
- I can't call this function
- Use returndatasize HOT 1
- How would one update the address the proxy is using? HOT 11
- Implementation on Rinkeby HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clone-factory.