stellar / basic-payment-app

An example payments application demonstrating integrations of various features and SEPs in a user-facing product.
https://github.com/stellar/basic-payment-app
Apache License 2.0
9 stars 27 forks source link

Add a claimable balance feature #16

Open ElliotFriend opened 1 month ago

ElliotFriend commented 1 month ago

When sending a payment to a user's contact, if the contact doesn't have a trustline for that asset the transaction will fail. That's because we're only using the payment operation. We should detect this case, and offer to create a claimable balance for the user.

CollinsC1O commented 1 month ago

@ElliotFriend can I work on this

onlydustapp[bot] commented 1 month ago

Hi @CollinsC1O! Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

PabloVillaplana commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Full Stack developer with 6 years of experience in the industry, I am super excited to be able to contribute to Web 3 projects, this to continue paving my way as an Open Source Contributor. I am from Dojo Coding Community

How I plan on tackling this issue

Detect Missing Trustline Before Payment: Before sending a payment, check if the recipient has an established trustline for the asset. If the trustline is missing, proceed to the next step.

Offer to Create Claimable Balance: If the recipient does not have a trustline, prompt the user with an option to create a claimable balance. This would allow the recipient to claim the payment once they establish the necessary trustline.

Fallback to Claimable Balance Creation: Upon user confirmation, automatically create a claimable balance instead of proceeding with the regular payment operation. This ensures that the transaction won't fail, and the recipient can claim the asset later.

Provide Clear User Feedback: Communicate clearly with the user, explaining why the payment could not be completed directly and offering the claimable balance as an alternative solution.

Jayse007 commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I would like to take this task, and it will be delivered within (26, September, 2024-30, September, 2024). I am a programmer who has intensive knowledge in Python and Javascript. I have worked on a lot of problems which has given me insights in detecting problems and coming up with optimized solutions.

How I plan on tackling this issue

I would use an if statement to check if the user's contact doesn't have a trustline and if this is the case; the if block would handle it by creating a claimable for the user.

josephchimebuka commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello @ElliotFriend I am Joseph I am a Software developer and blockchain developer and I am also an active contributor here on only dust here is my profile https://app.onlydust.com/u/josephchimebuka. This is my first time to contribute to this repo ill appreciate the opportunity to contribute.

How I plan on tackling this issue

I will ensure the issue is solved by adding a claimable balance feature I will complete this in 2-3 days

ShantelPeters commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockchain developer and technical writer with vast experiences with languages like css, react, typescript and javascript.

How I plan on tackling this issue

I will implement a check before processing the payment to verify if the contact has a trustline for the asset; if not, prompt the user with an option to create a claimable balance for the contact, ensuring a smoother transaction experience and preventing payment failures.

estherbreath commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a smart blockchain developer.

I can leverage on my background to solve this issue by implementing an automated trustline check and Claimable Balance creation system.

Design a smart contract that verifies the recipient's trustline status before initiating a payment, and if absent, automatically generate a Claimable Balance.

This approach combines your knowledge of state management and conditional execution from smart contract development with the Stellar network's Claimable Balance feature, providing a seamless and efficient solution to the trustline problem

How I plan on tackling this issue

I will take the following steps;

1. Implement a smart contract that checks if the recipient has a trustline for the asset being sent. 
2. If the trustline exists, proceed with the normal payment operation. 
3. If the trustline doesn't exist, automatically create a Claimable Balance instead. 
4. implement periodic cleanup of unclaimed balances to manage network efficiency. 
od-hunter commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Please can I be assigned this issue? I'll love to contribute to this project please. I am a blockchain Developer, and my experience includes html, css, react, JavaScript,TypeScript and solidity, python and Cairo.

How I plan on tackling this issue

To solve this issue, I'd take the following steps:

  1. I'll detect trustline error when the payment fails.
  2. I'll prompt the sender to create a claimable balance if the recipient lacks a trustline.
  3. I'll create the claimable balance using Stellar SDK, allowing the recipient to claim the asset once they add a trustline.
  4. I'll notify the recipient to add a trustline to claim the balance.

Please assign me.

Joewizy commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi my name is Joseph Gimba a computer engineer graduate that has passion for web3 and blockchain development, I have experience in writing smart contracts as well as using Javascript to a create Frontend for my projects built.

How I plan on tackling this issue

Using try & catch if the user does not have a Trustline then the catch block prompts the user to create a claimable balance to be able to receive payment. another approach would be asking the user if he wants us to automatically create a trustline for him automatically to receive the funds.

PabloVillaplana commented 1 month ago

@ElliotFriend Hi, can you give me more details about this issue? Steps to reproduce the use case?

ElliotFriend commented 1 month ago

Hi, there @PabloVillaplana! Thanks for taking the issue on! Hope all this info helps, and if not feel free to reach out and ask more questions!

The current state of BasicPay allows sending a regular payment operation of any asset that your account holds. That will work as long as the receiving account has a trustline for that particular asset. But, in the case where the recipient account does not have a trustline, the regular payment operation will fail.

So, we should do something like the following:

  1. We're already checking if the account exists when we select it for a payment in /src/routes/dashboard/send/+page.svelte, so we should hook into that logic to get the recipient account's balances array.
  2. When selecting the asset to send, see if the recipient holds the asset we're trying to send
  3. If not, give the user an opportunity to select "create a Claimable Balance instead"
  4. If they choose this option, we should add both the recipient account and the user's account as claimants on the CB (in case the user needs to claim it at some point in the future).
  5. I'm fine using unconditional claim predicates for both of these, just for simplicity's sake.

Helpful Docs and Links

ElliotFriend commented 3 weeks ago

Hi, @PabloVillaplana! Thanks for the interest in this issue. Since I haven't seen a PR yet for this issue, I'm going to un-assign it and make it available for ODHack9. You should definitely feel free to apply again, though!

Thanks again!

caxtonacollins commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am applying to this issue via https://app.onlydust.com/hackathons/odhack-90.

I am Collins Cxaton, a fullstark developer with a strong background in integrating APIs and designing responsive UI components based on Figma designs. I have experience in working with cryptocurrency wallets and displaying real-time wallet balances by integrating financial APIs. My skills in React and JavaScript allow me to effectively manage currency conversions and data handling.

How I plan on tackling this issue

First, when a user attempts a payment, check if the recipient has a trustline for the asset. This can be done by querying the user’s account and assets.

Integrate a conditional check before initiating the payment operation. If the recipient lacks a trustline, prevent the payment and display an appropriate message to the sender; if If the recipient lacks a trustline, offer the sender the option to create a claimable balance for the recipient. And Implement a function that allows the sender to create a claimable balance, using an appropriate API or smart contract method.

lLasty, notify the sender when a claimable balance is created; also i will create a test case and update the documentation

suhas-sensei commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

would love to work on this

aniruddhaaps commented 3 weeks ago

I’d like to resolve this.

Eka1210 commented 3 weeks ago

My background and how it can be leveraged:

I'm a Computer Science student with experience in JavaScript, and I’m eager to apply my skills to web3 projects. While this is my first time working with decentralized systems, I have a solid foundation in software development and problem-solving. My experience with JavaScript will be especially useful when working with payment flows and handling the detection logic required for this issue.

How I plan on tackling this issue:

1.I will review how payments are currently processed and identify where the transaction fails when the contact lacks a trustline for the asset.

  1. Using JavaScript, I’ll add logic to detect if the contact doesn’t have a trustline for the asset before attempting the payment operation.
  2. If the trustline is missing, I will provide an option to create a claimable balance for the user instead of letting the transaction fail.
  3. I will test the new functionality to ensure the flow works smoothly and no other parts of the payment system are affected.
  4. Lastly, I will submit a pull request explaining the changes, ensuring the payment process is more resilient.
blessingbytes commented 3 weeks ago

Would love to tackle this!

Benjtalkshow commented 3 weeks ago

I am a Full Stack Developer specializing in Next.js, TypeScript, Node.js, Cairo and Rust . With over 31 contributions across projects in the OnlyDust ecosystem, I’ve developed strong proficiency in delivering high-quality solutions and resolving complex issues within tight deadlines. My experience spans frontend, backend, smart contracts, and the optimization and maintenance of scalable codebases.

To implement the claimable balance feature, I would approach it with the following steps:

  1. The first step in the process would be checking if the recipient has an active trustline for the asset being sent. This can be done by querying the blockchain to see if a trustline exists between the recipient's account and the asset in question. If the trustline exists, the payment proceeds as usual. If it doesn't, the system would trigger the creation of a claimable balance.

  2. If no trustline is detected, the system would present the sender with an option to create a claimable balance instead of immediately failing the transaction. This can be handled at the user interface level, where the user will be informed that the recipient lacks a trustline and offered the ability to send the payment as a claimable balance.

  3. If the user chooses to proceed, the system will generate a claimable balance operation. This involves creating a transaction that specifies the recipient as the claimant, with the condition that they must establish a trustline to claim the asset. In Stellar, the CreateClaimableBalance operation can be used to hold the asset in a special balance until the recipient meets the claim conditions.

  4. Once the claimable balance is created, the recipient should be notified that there is a pending balance waiting for them. This notification can be triggered through the platform's notification system or by a more direct message like email. The recipient will be instructed to set up a trustline for the specified asset to claim the balance.

  5. To implement this, the user interface will need to be adjusted to account for both the detection of the missing trustline and the offer to create a claimable balance. Also, the user should be able to view pending claimable balances and manage the process from the app, giving full visibility into the status of the transaction.

Finally, thorough testing will be essential to ensure that this feature works across different assets and account types. Special care should be taken to handle edge cases, such as when the recipient establishes a trustline but does not claim the balance promptly or when a recipient fails to set up the trustline altogether.

deeseeker commented 3 weeks ago

Is it okay if I tackle this?

kelvinparmar commented 3 weeks ago

Can I start working on this?

shubha-me commented 3 weeks ago

Can I take this from here?

Emmanex01 commented 3 weeks ago

Can I contribute to this one?

deeseeker commented 2 weeks ago

Could I take a shot at this?

OWK50GA commented 2 weeks ago

Can I handle this task?

bruhhgnik commented 2 weeks ago

I’d like to work on this, im pretty sure it will be over in a day

jedstroke commented 2 weeks ago

Can I contribute to this one?

martinvibes commented 2 weeks ago

hey @fricoben Can I contribute to this one? Let me handle this issue!

mimisavage commented 2 weeks ago

Mind if I try this one?

Aditya-040 commented 2 weeks ago

I'd like to take this issue.

MrRoudyk commented 2 weeks ago

May I try my hand at this?

About me: Software Engineer with 10 years of experience. For the past 5 years, I’ve specialized in HR Tech solutions. I’m passionate about exploring new technologies and currently looking to deepen my expertise in blockchain, smart contracts, and decentralized applications. I have also contributed to open source development at OnlyDust (My OnlyDust Profile).

How I plan on tackling this issue: Before sending a payment, I'll check if the recipient has a trustline for the asset. If not, I'll prompt the user to create a claimable balance instead of the regular payment. Upon the user's confirmation, I'll automatically create the claimable balance, ensuring the transaction doesn't fail. I'll also provide clear feedback to the user, explaining why the direct payment couldn't be completed and offering the claimable balance as an alternative

Akshola00 commented 2 weeks ago

Can I start working on this?

sonimwangi commented 2 weeks ago

I'd like to take this issue.

Kaminar-i commented 2 weeks ago

Can I take this issue?

Kaminar-i commented 2 weeks ago

Please can I work on this, haven't gotten issues to contribute to yet

0xdevcollins commented 2 weeks ago

Can I be assigned to this?

sigmadawg commented 2 weeks ago

im a newbie contributor, i'd be grateful if you'd give me the opportunity to work in this.

Michaelkingsdev commented 2 weeks ago

Can I try solving this issue?

KoxyG commented 2 weeks ago

I @ElliotFriend I am koxy, a stellar ecosystem contributor, can you pls assign this task to me?. I would work on this by implementing the change trust operation on stellar's SDK.

saimeunt commented 1 week ago

I'm a returning contributor and I'd like to try this one. I will carefully study the structure of the project and provide a solution based on the description of the issue.

SoarinSkySagar commented 1 week ago

Could I take on this issue? I've worked on this repository in the previous ODHack and I'm confident that I'll be able to resolve this issue. ETA: 1 Day