Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2166aa4
First Commit
Mar 22, 2026
ba0fd01
WIP
Mar 22, 2026
18ddac2
WIP
Mar 22, 2026
c88dfb5
Resumen
fndecroix Mar 22, 2026
72342bb
Version inicial
fndecroix Mar 22, 2026
22b4d85
Initial frontend
Mar 22, 2026
0073c72
First iteration of Aiken script, and tests for validating the two use…
Mar 22, 2026
3756c38
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
5ad9bb3
Fetch real ADAs price
Mar 22, 2026
f08aff0
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
f06b374
added comments
Mar 22, 2026
960d424
Adds Eternl integration
Mar 22, 2026
bd35293
Connects to preprod
Mar 22, 2026
c6dab99
First iteration: deployment, future refactor, move everything to backend
Mar 22, 2026
6097454
Refactor directories
Mar 22, 2026
cd39b7e
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
827febb
Pushed the rest
Mar 22, 2026
11572aa
Tests passing
Mar 22, 2026
ffc23b9
WIP: fixed lock
Mar 22, 2026
67a9cfb
WIP: fixed unlock
Mar 22, 2026
1b07918
Changed to pk instead of seed
Mar 22, 2026
64ba8fd
Revert "Changed to pk instead of seed"
Mar 22, 2026
585a7ce
Improves UX
Mar 22, 2026
50774f4
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
b10a48f
Script failing
Mar 22, 2026
f2e8fa0
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
b02a7d4
traces added
Mar 22, 2026
8162717
Tests for unlock added
Mar 22, 2026
7997eb9
Endpoints (#1)
jdiaz-eryx Mar 22, 2026
59493a5
Readme in its final form
Mar 22, 2026
ffb9055
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
1303c21
Algunos cambios
fndecroix Mar 22, 2026
953086e
Merge remote-tracking branch 'origin/main'
fndecroix Mar 22, 2026
0a7c86e
WIP: readme
Mar 22, 2026
048cab2
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
aadfd3a
Readme with frontend images
Mar 22, 2026
eec3fac
restores aiken script and tests pass
Mar 22, 2026
b510479
wip
fndecroix Mar 22, 2026
5d4ac47
Merge branch 'main' into roto
Mar 22, 2026
ada5c39
Renames
Mar 22, 2026
308ad0e
Merge branch 'main' into roto
Mar 22, 2026
1112a9d
Removes unused "Created" filter from UserDashboard
Mar 22, 2026
cc927d6
Extended readme
Mar 22, 2026
8405d79
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
ec2a7e1
finished README
ChinoCribioli Mar 22, 2026
62e285d
Merge branch 'main' of github.com:eryxcoop/pyth-examples
ChinoCribioli Mar 22, 2026
92792e0
WIP
Mar 22, 2026
0883a4a
Merge branch 'main' into roto
Mar 22, 2026
1e16f60
WIP
Mar 22, 2026
b5d602c
clarification to README
ChinoCribioli Mar 22, 2026
2dd0f5c
Fixes unlock
Mar 22, 2026
a43307c
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
3974062
Extended readme
Mar 22, 2026
a3b6402
Merge remote-tracking branch 'origin/main'
Mar 22, 2026
2d81ae8
Fixes bug on creation
Mar 23, 2026
6996e75
Merge remote-tracking branch 'origin/main'
Mar 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ typings/

# Cargo build output
target/

# Local SQLite files
lazer/cardano/backend/data/*.db

# Backend build output
lazer/cardano/backend/dist/
56 changes: 56 additions & 0 deletions lazer/cardano/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Payth: calibrate uncertainty

This project aims to bring Pyth to Cardano with a simple, small and yet useful use case. Right now it's not a product per se, but it could become one in some ways.

## Project description

Imagine you want to submit a grant proposal for a project idea you had that will improve Cardano significantly. You do your research, desing a feasible solution, and estimate a budget based on the amount of time and effort you expect to put on the solution. But, the grant will be paid in *ADA*, while your budget is estimated in *USD*.

Of course, you could convert the budget to ADA using the current exchange rate, but delivery may take months or even years. During that time, the rate can fluctuate dramatically, potentially reaching entirely different value ranges. Payth solves this problem.

The idea is pretty basic: an applicant, Anne, wants to do some task that will be paid in the future by some sponsor Bill. The transaction is gonna be in ADA, but Anne wants the price fixed in USD to avoid possible fluctuations. This could be benefitial, economically speaking, to any of them depending on the market. So Anne fixes a price in USD and, using the off-chain Pyth API, determines the corresponding amount of ADA at the given moment. She makes a request to Bill, and he **locks** in a Cardano Validator that amount of ADA, plus a certain margin (right now that margin is fixed to 100%).

When both actors agree the task is complete, Bill proceeds to **unlock** the funds. How much? Well, the amount of ADA corresponding to the USD agreed, but using the current relation between USD and ADA. This is where **Pyth** comes in to compute on-chain how much ADA should be sent to Anne and how much should return to Bill.

In the case that Anne leaves the job undone, or any real life condition that interrupts the relationship, Bill has the option to retrieve the locked funds. So, in summary, there are 2 possible flows: **lock --> unlock** and **lock --> cancel**.

This of course can improve in many ways:
* Add validity times for the unlock or the cancel actions
* Give flexibility to the margin given by Bill
* Allow other currencies to be used instead of USD

## Use cases
Catalyst and other rounds of funding could optionally use this system to reduce uncertainty for developers, but also it could work for freelance initiatives, service retainers and bounties or open tasks.

## Codebase overview
The project is divided into 2 main sections: backend and frontend.
* The **frontend** connects the user with their Eternl wallet and makes requests to Pyth off-chain API to track the current ADA and USD value in the market. It also handles user interactions and request to the backend for creating a Task, completing a Task and retrieving money if the task is aborted. It is divided in 2 screens "Applicant" and "Sponsor" where each role has a different view.
* The **backend** provides 3 endpoints for the 3 actions, which in this context correspond to **lock**, **unlock** and **cancel** scripts. Each of them handles the deploy of a different transaction in cardano, using the **Evolution** framework. It also contains the Aiken code that will regulate the **unlocking** of funds. It also contains a battery of Aiken and Typescript tests.

## Try it yourself
* Go to the ```frontend``` directory, run ```npm i``` and run the frontend with ```npm run dev```.
* Go to the ```backend``` directory, run ```npm i``` and run the server with ```npm run api```.
* Go to the ```backend``` directory, create a ```.env``` file like the `.env.example` and fill it with your own credentials. Give funds to the sponsor address.
* Go to the ```frontend``` directory, create a ```.env``` file like the `.env.example` and fill it with your own credentials.
* To run the tests, run `aiken check` for the Aiken tests and `npm run test` for the backend tests.

**Disclaimer:** some actions may take more than one attempt or take some time to make impact, sorry for the complications.

Note that the project must be run in Google Chrome, or any browser that supports Eternl Wallet extension (but it was tested in Chrome).

## Frontend overview
Here you can see the header of the page after connecting the wallet

![header.png](images/header.png)

Then you can choose which role are you on:

![role.png](images/role.png)

If you are an applicant, you can create your request

![create.png](images/create.png)

and then see a list of created requests

![tasks.png](images/tasks.png)
15 changes: 15 additions & 0 deletions lazer/cardano/backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Blockfrost API key for Cardano preprod
BLOCKFROST_PROJECT_ID=preprodXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

BLOCKFROST_URL=https://cardano-preprod.blockfrost.io/api/v0

# Sponsor wallet seed phrase (24 words)
SPONSOR_SEED_PHRASE=word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12 word13 word14 word15 word16 word17 word18 word19 word20 word21 word22 word23 word24

# Pyth Lazer deployment PolicyId on preprod
PYTH_POLICY_ID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

# Pyth Lazer API token
PYTH_LAZER_TOKEN=your_pyth_lazer_token_here

NETWORK=preprod
27 changes: 27 additions & 0 deletions lazer/cardano/backend/aiken.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file was generated by Aiken
# You typically do not need to edit this file

[[requirements]]
name = "aiken-lang/stdlib"
version = "v3.0.0"
source = "github"

[[requirements]]
name = "pyth-network/pyth-lazer-cardano"
version = "main"
source = "github"

[[packages]]
name = "aiken-lang/stdlib"
version = "v3.0.0"
requirements = []
source = "github"

[[packages]]
name = "pyth-network/pyth-lazer-cardano"
version = "main"
requirements = []
source = "github"

[etags]
"pyth-network/pyth-lazer-cardano@main" = [{ secs_since_epoch = 1774216218, nanos_since_epoch = 134812250 }, "a46dacd97a22eb07feeaf966d48c3116c8249ddc836705656e3135cea285bcfc"]
14 changes: 14 additions & 0 deletions lazer/cardano/backend/aiken.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name = "pyth-examples/pay-with-pyth"
version = "0.0.1"
license = "Apache-2.0"
description = "Payment agreements in USD settled in ADA using Pyth oracle prices"

[[dependencies]]
name = "aiken-lang/stdlib"
version = "v3.0.0"
source = "github"

[[dependencies]]
name = "pyth-network/pyth-lazer-cardano"
version = "main"
source = "github"
Loading