txpipe / pallas

Rust-native building blocks for the Cardano blockchain ecosystem
Apache License 2.0
148 stars 60 forks source link

feat: TX builder #267

Open scarmuega opened 1 year ago

scarmuega commented 1 year ago

Problem:

Proposal:

Examples of some high-level functions that the lib could / should provide:

The above list is just a preliminary reference, final feature is not limited to just those functions.

The following are things that should NOT be part of the library:

rvcas commented 1 year ago

for reference: https://github.com/txpipe/pallas/pull/250

Totally fine if the above is thrown away btw. But perhaps a good reference for whoever picks this up.

Quantumplation commented 1 year ago

These may be covered by your list of examples, I'm tired and can't go through it lol. But, below is two examples of really common transaction types that we build at Sundae:

Simple token transfer tx

Transaction dependent on fee

Quantumplation commented 1 year ago

Most tx builders use a "available inputs + change address" abstraction, for balancing the transaction; the first case above becomes a lot easier if you can have multiple labeled sources / change addresses; so you can specify "here's all the inputs from the Server, and all change should go back to X; and here's all the inputs from the User, and all change should go back to Y;" and then allow the user to explicitly transfer funds between these two pools.

scarmuega commented 1 year ago

@Quantumplation nice feedback!

maybe create an abstraction representing a party which holds it's own UTxO set + change address. We could then support high-level operations such as transfer(from: party_a, to: party_b, assets) with all the balancing taken care of.

Is that what you had in mind?

Quantumplation commented 1 year ago

Yep, exactly! bonus points if you can extend that to include scripts, datums, etc.

I also had another thought: another common pattern is "I want to fit as many of these things as possible into the transaction", either processing escrows, or splitting assets into UTXOs with a specific size, etc; most transaction builders have good UX around grabbing as many inputs as we need, but no great experiences around the outputs.