Fábricas de contrato
-
-
Parece "Create_Contract {Storage" G;Parâmetro 'P;Código ...} `Trabalharia,masissoiráincorporar otamanho de um contrato umpouco,e parece que deveria haver umamaneira de lidar comissograciosamente comonainstanciação de classe deestilo Java de solidez.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
-
Senão,umexemplo limpoem Michelson seria legal.If not, a clean example in Michelson would be nice.
- 0
- 2019-03-11
- Rob
-
OK legal,provavelmente um caminhoparafora.ok cool, probably a ways out then.
- 0
- 2019-03-12
- Rob
-
Eu coloquei um comentário queeu deleteipara convertê-loem uma resposta.Euperdi seu comentário quefoi adicionado depois.Minhas desculpasporisso.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 respostas
- votos
-
- 2019-03-12
Há uma discussãomuito sucintano anúnciopara smartpy https://medium.com/@smartpy_io/introducing-smartpy-and-smartpy-I-D4013Bee7d4e#15ee .
Aideia éter um contrato quemantenha umbig_mape cadaelemento dobig_map representa um contrato.
Issonão é absolutamente restrito a Smartpye é diretamentefactívelem Michelson,Liquidez ou Fi.
Este assuntotambém apareceu aqui: qual é o contêinerbigmape por queissoimporta?
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?
-
Eu aprecio sua respostae não quero queisso se depare comnegativo,mas sinto queprecisamos criar uma soluçãomais abrangenteparaesseproblemano curtoprazoparatornar o desenvolvimento da DAPP Produtivo.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
-
Eupossofacilmente concordar queestanão é a soluçãofinale única.I can easily agree that this is not the final and only solution.
- 0
- 2019-03-12
- FFF
-
Referência abaixopara ver umexemplo do queeuestavapensandoreference below to see an example of what I was thinking
- 0
- 2019-03-14
- Rob
-
- 2019-03-14
Aquiestá umexemplo de um contrato lidando comissoem liquidez. Há o desafio único deescreverfunções que sópodem utilizar chamadas deprocedimento remotonofinal de suaexecução:
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); };
Issome fazpensar seisso levará aendpoints que são como "ordem"e "pickup",ou seja,um 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.
Houve algumapesquisa sobre como umafábrica de contratopode serfeitaem Michelson/Liquidez?
Paraelaborar,em solidez umafábrica de contratopodeparecer:
(referenciado de https://ethereum.stackexchange.com/questions/13415/Deploy-contrato-de-contratoem solidez )
Este é um recursopoderosono desenvolvimento da DAPP,poispermite criar umaestrutura orientada a objetospara o seu Dapp onde as solicitaçõespodem criarnovos contratos. É umpadrão de designbem estabelecido,então o que seria oequivalentenoecossistema de Tezos?