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

chore(testnet): examples using psp22 contract #337

Open
chungquantin opened this issue Oct 10, 2024 · 7 comments
Open

chore(testnet): examples using psp22 contract #337

chungquantin opened this issue Oct 10, 2024 · 7 comments
Labels
api Pop API kudos List this issue on morekudos.com

Comments

@chungquantin
Copy link
Collaborator

chungquantin commented Oct 10, 2024

We would want to showcase the power of Pop API through and example contracts. With the upcoming #108 , we need some example contracts that use the Fungible contract to build a real DApps.

Description

Contract in examples/fungible is the base contract that follows the PSP22 standard. In the "Use Cases" section of that contract, you can find several examples of how the contract can be used. The PSP22 contract in the example crate can be applied to any case that requires a fungible mechanism:

Ideas Description
Uniswap-like AMM Build an automated market maker (AMM) protocol where users can provide liquidity in PSP22 token pairs and earn fees.
Staking Rewards System Create a staking contract where users stake PSP22 tokens and earn rewards in the form of additional PSP22 or another token.
Decentralized Lending Implement a lending platform where users can deposit PSP22 tokens as collateral to borrow other assets.
DAO Treasury Management Use PSP22 tokens as governance tokens to manage a DAO's treasury and fund allocation proposals.
Subscription Payment System Build a service where users can pay recurring subscription fees using PSP22 tokens.
Yield Farming Protocol Develop a farming contract where users lock PSP22 tokens to earn rewards in governance or utility tokens.
Charity Donation Pool Create a transparent donation platform where contributors send PSP22 tokens to support causes, with tracking of usage.

It’s worth noting that this does not have to be just an example contract but can be used as a real DApps contract as well. In summary, the idea is to have more contracts that leverage examples/fungible for fungible token management across a variety of use cases.

Integration Guide

To use the fungible contract in your ink! contract, you can use the contract_ref! macro with the contract address as a parameter. Here is the example https://github.com/r0gue-io/sub0-ink-challenges-solution/blob/7b48d58a2e727530400b70e3ee7b137458de00d1/challenges/challenge-7/lib.rs#L179

References

@chungquantin chungquantin changed the title feat(testnet): examples using psp22 contract chore(testnet): examples using psp22 contract Oct 10, 2024
@chungquantin chungquantin added the api Pop API label Oct 10, 2024
@chungquantin chungquantin added the kudos List this issue on morekudos.com label Nov 18, 2024
@ndkazu
Copy link

ndkazu commented Dec 12, 2024

@chungquantin , can this be considered as one example contract using the Fungible contract:
https://github.com/r0gue-io/pop-node/tree/main/pop-api/examples/fungibles
What I'm really asking is if I can look at it to get an idea of what is expected.

@chungquantin
Copy link
Collaborator Author

@ndkazu the contract in examples/fungible is the base contract that follows the PSP22 standard. In the "Use Cases" section of that contract, you can find several examples of how the contract can be used. The PSP22 contract in the example crate can be applied to any case that requires a fungible mechanism:

  • Staking: Implementing a staking pool contract where participants deposit fungible tokens to stake, with rewards distributed based on the amount staked.
  • Governance: Enabling token holders to participate in decentralized decision-making, such as voting on proposals or network upgrades.
  • Rewards Distribution: Distributing tokens as incentives for actions like participating in a network, completing tasks, or using a service.

It’s worth noting that this does not have to be just an example contract but can be used as a real DApps contract as well. In summary, the idea is to have more contracts that leverage examples/fungible for fungible token management across a variety of use cases. So I would recommend you to start with something like an AMM, Staking or DAO contract.

@ndkazu
Copy link

ndkazu commented Dec 12, 2024

@chungquantin , examples/fungibles being a contract , I assume a new dao_contract would make use of a cross-contract call to be able to use the fungibles contract. The problem I see is that the fungible_contract reference is not re-exported : pub use self::fungibles::FungibleRef;. Am I missing something?

@chungquantin
Copy link
Collaborator Author

chungquantin commented Dec 12, 2024

@ndkazu Here is the example to use the fungible contract using contract_ref! macro: https://github.com/r0gue-io/sub0-ink-challenges-solution/blob/7b48d58a2e727530400b70e3ee7b137458de00d1/challenges/challenge-7/lib.rs#L179

Edit: I updated the PR description to list some ideas I have in mind.

@Daanvdplas
Copy link
Collaborator

Daanvdplas commented Dec 12, 2024

The problem I see is that the fungible_contract reference is not re-exported : pub use self::fungibles::FungibleRef

That is a good point though.

Be mindful though that based on your use case you might not need the Psp22 contract. Lets say for your use case you only need to make a transfer. Then it is much better to just use the api::transfer in your contract, in stead of making cross contract calls to the Psp22 contract. Much better in the sense that it will be cheaper for the accounts calling your contract most likely.

When deploying smart contracts on a Polkadot parachain, it's best to design them with specialized logic. Specialized contracts generate less data for the Proof of Validity (PoV) required by the relay chain during validation. In contrast, contracts that handle multiple functionalities increase the PoV size, leading to greater validation overhead. Focusing on single-purpose contracts helps keep the PoV smaller and ensures more efficient validation.

@ndkazu
Copy link

ndkazu commented Dec 13, 2024

I opened a Dao_example PR. Still a work in progress, but would love to get some reviews at this stage, as I am also discovering ink! while doing this.

@ndkazu
Copy link

ndkazu commented Dec 15, 2024

We would want to showcase the power of Pop API through and example contracts. With the upcoming #108 , we need some example contracts that use the Fungible contract to build a real DApps.

Description

Contract in examples/fungible is the base contract that follows the PSP22 standard. In the "Use Cases" section of that contract, you can find several examples of how the contract can be used. The PSP22 contract in the example crate can be applied to any case that requires a fungible mechanism:
Ideas Description
Uniswap-like AMM Build an automated market maker (AMM) protocol where users can provide liquidity in PSP22 token pairs and earn fees.
Staking Rewards System Create a staking contract where users stake PSP22 tokens and earn rewards in the form of additional PSP22 or another token.
Decentralized Lending Implement a lending platform where users can deposit PSP22 tokens as collateral to borrow other assets.
DAO Treasury Management Use PSP22 tokens as governance tokens to manage a DAO's treasury and fund allocation proposals.
Subscription Payment System Build a service where users can pay recurring subscription fees using PSP22 tokens.
Yield Farming Protocol Develop a farming contract where users lock PSP22 tokens to earn rewards in governance or utility tokens.
Charity Donation Pool Create a transparent donation platform where contributors send PSP22 tokens to support causes, with tracking of usage.

It’s worth noting that this does not have to be just an example contract but can be used as a real DApps contract as well. In summary, the idea is to have more contracts that leverage examples/fungible for fungible token management across a variety of use cases.

Integration Guide

To use the fungible contract in your ink! contract, you can use the contract_ref! macro with the contract address as a parameter. Here is the example https://github.com/r0gue-io/sub0-ink-challenges-solution/blob/7b48d58a2e727530400b70e3ee7b137458de00d1/challenges/challenge-7/lib.rs#L179

References

* https://github.com/use-ink/ink-examples

The same kind of detailed explanation might be required for Issue #378.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Pop API kudos List this issue on morekudos.com
Projects
None yet
Development

No branches or pull requests

3 participants