Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factory Pattern Gno #1895

Open
kazai777 opened this issue Apr 5, 2024 · 5 comments
Open

Factory Pattern Gno #1895

kazai777 opened this issue Apr 5, 2024 · 5 comments

Comments

@kazai777
Copy link
Contributor

kazai777 commented Apr 5, 2024

Description

Hi 👋 I thought of creating a feature that would use the same principle as the Factory Pattern in Solidity. And I wanted to know if other people had already thought about this or if anyone had already started working on it?

@leohhhn
Copy link
Contributor

leohhhn commented Apr 15, 2024

Hey, this is currently something that we do not support. As discussed with @moul, this might be something that we will implement, but not right now - instead of relying only on known concepts from other languages like Solidity, we want to experiment with new blockchain programming patterns. One of these is this PR.

Basically, the idea is to have a central "registry" contract, that you can call NewToken in to make your contract, instead of having to deploy your own. Then, you would be calling each of the common GRC20 functions along with an identifier to the token that you want to execute the functions on.

I would suggest you try to play around with these ideas, and possibly even check out what other languages do for this specific case (Move, Rust for Solana/NEAR, etc). See what sort of limitations each of them have, what are the pros/cons, and possibly take an idea or two from them. Solidity was the first to do many things, which is why it's so well known, but at times it might not show the most optimal way of doing something, which is why we are very keen on exploring :)

@kazai777
Copy link
Contributor Author

Thanks for the reply, I'll look into it and try some things out :)

@moul
Copy link
Member

moul commented Apr 15, 2024

Another option is to consider using something developed by @ilgooz's team. I will leave it to him to decide when and what to reveal.

@moul
Copy link
Member

moul commented Apr 15, 2024

I plan to write another pattern example using Go objects. In this case, the factory will not expose an API with a named prefix. Instead, it will initialize an object that can be registered and exposed by other contracts, like a registry.

@kazai777
Copy link
Contributor Author

I was thinking of something more general, for example if a dapp needs a contract to manage funds, it would be nice to be able to create contracts independent of the contract itself to centralize management in one place. To take the lottery as an example, it would be nice for each lottery to have its own contract and be able to manage funds independently of the others. For example, each time a new lottery is created, a new contract would be created and would be unique to the lottery itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants