Fábricas por contrato
-
-
Aparece como 'CREATE_CONTRACT {almacenamiento'g;parámetro 'p;code ...} `funcionaría,peroesto aumentará unpocoeltamaño de un contrato,yparece que debería haber unamanera demanejaresto conelegancia,comoen lainstanciación de clases deestilo Java de Solidity.It appears like `CREATE_CONTRACT { storage 'g ; parameter 'p ; code ... }` would work, but this will bloat the size of a contract a bit, and it feels like there should be a way to handle this gracefully like in Solidity's Java style class instantiation.
- 0
- 2019-03-11
- Rob
-
Sino,unejemplo claroen Michelson seríabueno.If not, a clean example in Michelson would be nice.
- 0
- 2019-03-11
- Rob
-
bueno,probablemente una salidaentonces.ok cool, probably a ways out then.
- 0
- 2019-03-12
- Rob
-
Pongo un comentario queborrépara convertirloen una respuesta.Extrañétu comentario que se agregó después.Mis disculpasporesto.I put a comment that I deleted to convert it into an answer. I missed your comment that was added afterwards. My apologies for this.
- 1
- 2019-03-12
- FFF
-
2 respuestas
- votos
-
- 2019-03-12
Hay una discusiónmuy sucintaen el anuncio de SmartPy https://medium.com/@SmartPy_io/introducing-smartpy-and-smartpy-io-d4013bee7d4e#15ee .
Laideaestener un contrato que contenga unbig_map y cadaelemento delbig_map representa un contrato.
Estono se limitaen absoluto a SmartPy y sepuede realizar directamenteen Michelson,Liquidity o Fi.
Estetematambién apareció aquí: ¿Quéesel contenedor BigMap ypor quéesimportante??
There is a very succinct discussion in the announcement for SmartPy https://medium.com/@SmartPy_io/introducing-smartpy-and-smartpy-io-d4013bee7d4e#15ee.
The idea is to have a contract that holds a big_map and each element of the big_map represents a contract.
This is absolutely not restricted to SmartPy and it is directly doable in Michelson, Liquidity or Fi.
This subject also appeared here: What is the BigMap container and why does it matter?
-
Agradezco su respuesta yno quiero queestoparezcanegativo,pero creo que debemosencontrar una soluciónmásintegral aesteproblema a cortoplazopara queel desarrollo de DAPP seaproductivo.I appreciate your response and don't want this to come across negative, but I feel we need to come up with a more comprehensive solution to this problem in the near term to make DAPP development productive.
- 0
- 2019-03-12
- Rob
-
Puedofácilmenteestar de acuerdoen queestanoes la única y definitiva solución.I can easily agree that this is not the final and only solution.
- 0
- 2019-03-12
- FFF
-
referencia a continuaciónpara ver unejemplo de lo queestabapensandoreference below to see an example of what I was thinking
- 0
- 2019-03-14
- Rob
-
- 2019-03-14
Aquí hay unejemplo de un contrato quemanejaestoen liquidez. Existeel desafío único deescribirfunciones que solopueden utilizar llamadas aprocedimientos remotos alfinal de suejecución:
type plus_storage = { count: nat, plus_owner: address, }; contract PlusOne = { type storage = plus_storage; let%init storage = (y: nat) => { count: y, plus_owner: Current.sender(), }; let%entry main = (p: nat, storage) => { if (Current.sender() != storage.plus_owner) { failwith("invalid caller"); }; ([], storage); } }; type storage = { owner: key, pl: address, }; let%init storage = (contract_owner: key) => { owner: contract_owner, pl: KT1111111111111111111111111111111111, } let%entry other = (param: nat, storage) => { let t: option(PlusOne.instance) = Contract.at(storage.pl); let t = switch(t) { | None => Current.failwith() | Some(inst) => inst }; let op = Contract.call( ~dest=t, ~amount=0tz, ~entry=main, ~parameter=param); ([op], storage); }; let%entry main = ((), storage) => { let manager = Crypto.hash_key(storage.owner); let delegate = Some(manager); let spendable = false; let amount = Current.amount(); let init_value: nat = 0; let (c_op, c_addr) = Contract.create( ~manager, ~delegate, ~spendable, ~delegatable=false, ~amount, ~storage={count: init_value, plus_owner: Contract.address(Contract.self())}, (contract PlusOne), ); let storage = storage.pl = c_addr; ([c_op], storage); };
Mepregunto siesto dará lugar apuntosfinales que sean como "pedido" y "recogida",es decir,un restaurante.
Here's an example of a contract handling this in liquidity. There's the unique challenge of writing functions that can only utilize remote procedure calls at the end of their execution:
type plus_storage = { count: nat, plus_owner: address, }; contract PlusOne = { type storage = plus_storage; let%init storage = (y: nat) => { count: y, plus_owner: Current.sender(), }; let%entry main = (p: nat, storage) => { if (Current.sender() != storage.plus_owner) { failwith("invalid caller"); }; ([], storage); } }; type storage = { owner: key, pl: address, }; let%init storage = (contract_owner: key) => { owner: contract_owner, pl: KT1111111111111111111111111111111111, } let%entry other = (param: nat, storage) => { let t: option(PlusOne.instance) = Contract.at(storage.pl); let t = switch(t) { | None => Current.failwith() | Some(inst) => inst }; let op = Contract.call( ~dest=t, ~amount=0tz, ~entry=main, ~parameter=param); ([op], storage); }; let%entry main = ((), storage) => { let manager = Crypto.hash_key(storage.owner); let delegate = Some(manager); let spendable = false; let amount = Current.amount(); let init_value: nat = 0; let (c_op, c_addr) = Contract.create( ~manager, ~delegate, ~spendable, ~delegatable=false, ~amount, ~storage={count: init_value, plus_owner: Contract.address(Contract.self())}, (contract PlusOne), ); let storage = storage.pl = c_addr; ([c_op], storage); };
It makes me wonder if this will lead to endpoints that are like "order" and "pickup", ie a restaurant.
¿Se ha realizado algunainvestigación sobre cómo sepodría realizar unafábricapor contratoen Michelson/Liquidity?
Para desarrollar,en Solidity unafábricapor contratopodría verse así:
(referenciado desde https://ethereum.stackexchange.com/questions/13415/deploy-contract-from-contract-in-solidity )
Estaes una característicapoderosaen el desarrollo de DAPP,ya que lepermite construir unaestructura orientada a objetospara su DAPP donde las solicitudespueden crearnuevos contratos. Es unpatrón de diseñobien establecido,entonces,¿cuál seríaelequivalenteen elecosistema de Tezos?