Create contracts from other contracts #197
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created by: UlfNorell
From the Sophia discussion at the Sofia workshop.
Created by: UlfNorell
Possible design: Include source code of child contract. Compiler compiles it to a byte code literal that can be deployed with a new
CREATE_CONTRACT
instruction. From Sophia:Created by: nikita-fuchs
I havn't seen anything besides DAOs using this feature, also because this sort of thing is quite pricey. Although I was the one initially pushing for it some time ago, I wouldn't delay something more important as, say, native tokens for this.
Created by: UlfNorell
Native tokens is a massive undertaking that isn't really affected one way or the other by how we prioritise Sophia development.
Created by: evdoks
@UlfNorell I think Nikita is talking about resources that we can either allocate to further work on Sophia or to start working on Native Tokens. I assume that you mean is that there are no dependencies between those two.
PS 'resources' = @hanssv 🙄
Created by: UlfNorell
No, I'm saying the effort required for native tokens is vastly higher than for any of the current Sophia extension proposals, so it makes no sense to pit them against each other.
Created by: nikita-fuchs
Well I think it does, if the smaller effort would slow down the bigger one significantly? I mean, you guys know best. I just think that prioritizing the native tokens would make sense.
Created by: radrow
This should go live now.
Main usecases
Created by: UlfNorell
Can you elaborate on each of these cases, explaining for instance, when and by whom the byte code for the new contracts is produced, and what checks are required? Also, what are the concrete advantages over manual contract deployment?
In the first case (if I understand it correctly), the fungible-token contract is fixed, so it can be compiled and shipped together with the factory contract. No checks other than obvious run-time checks that the create contract transaction is well-formed are required.
I don't see how using the factory is any easier than manual deployment. Both cases involve creating a transaction with some data for the init function.
Regarding security concerns, it's not clear to me that there is a huge gain.
Manual deployment
Automatic deployment
Created by: mradkov
Currently without having this feature UX is a pain.
Example use case:
Token Bonding Curve [A]
Token Sale [B]
Token (AEX9) [C]
registering token for sale
Registry Contract [D]
to store an index of all available tokensCurrent flow:
Contract A
- requires signature and confirmation in the walletContract B
- requires signature and confirmation in the walletContract C
- requires signature and confirmation in the walletContract A
toContract B
- requires signature and confirmation in the walletContract B
toContract C
- requires signature and confirmation in the wallet.Contract C
toContract D
- requires signature and confirmation in the wallet.That is a total of 5 steps with 5 individual confirmations.
How you can do it in Solidity using a single contract deployment:
Done with single contract deployment - 1 signature required.
No. It's not as simple as that 🙃
As a user you also need to verify the bytecode of each individual contract as without it a raccoon can backdoor each subcontract. So don't forget to validate the bytecode either on the server side or the client side of every contract.
With contract factories you only need ONE contract which can produce the token/bonding curve etc... You only need to validate one contract one time on an external site - like on etherscan.
The same goes for the our governance aepp where some complex centralized validation infrastructure is required in order for it to be somewhat secure.
Consider a gaming platform where people are playing tick-tack-toe for money. Each game is coordinated by a contract factory which deploys new tick-tack-toe games and tracks their status. When someone wants to play, the contract factory automatically either deploys a new contract with the game or assigns you to an existing game. The lifecycle of each game is:
Let's say Alice wants to play against Bob:
Does Alice or Bob need to validate that C was deployed by the Factory? Of course not - If the only way for a contract to get registered in the factory is by being deployed by the factory itself then we know what C is by validating the factory.
Essentially when a contract factory tracks contracts deployed by itself then by validating the factory we can ensure that any deployed subcontracts were not being manipulated by someone.
@UlfNorell Could you give us a time estimate for this task?