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

Helper function to parseADA to Lovelace #163

Open
nhenin opened this issue Jan 10, 2024 Discussed in #143 · 1 comment
Open

Helper function to parseADA to Lovelace #163

nhenin opened this issue Jan 10, 2024 Discussed in #143 · 1 comment
Assignees

Comments

@nhenin
Copy link
Collaborator

nhenin commented Jan 10, 2024

Discussed in #143

Originally posted by nstanford5 December 21, 2023
Most DApps will present users with the ability to input token amounts to a UI component. Users typically think in terms of ADA amounts, but we need to send Lovelace amounts to the blockchain.

Should the SDK include a simple helper function to parseADA to Lovelace?

Something like..

const parseADA = (num: number) => { return num * 1000000; };

On the other side of that, when querying the blockchain for amounts -- it will return Lovelace that needs to be formatted to ADA to present to users.

Should we also include a formatLovelace function?

@nhenin nhenin self-assigned this Jan 10, 2024
@hrajchert
Copy link
Collaborator

As I responded in the discussion, I believe this should be part of a bigger thing that we can call TemplateParameters/ContractScheme/etc that is similar to the Marlowe Extended feature.

This could allow us to define a DSL for contract parameters with assertions (amount > x, deadline 1 > deadline 2, etc), with a human description (that can help us with Marlowe to english explainer) and with a proper serialization mechanism so we can simplify this type of code.

The proposed function parseADA is misleading as it is not parsing anything, it could be called lovelaceToAda, but multiplying a number for 1 Million is trivial and does not belong in the SDK IMO.

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

2 participants