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

feat: chaining of txs #231

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

will-break-it
Copy link

@will-break-it will-break-it commented Oct 30, 2023

  • simple extension for tx_complete type API to support chaining of transactions
  • added test case

Example:
One can chain any complete transaction by using the newly available chain API, which takes a function to select one or more transaction output(s) of tx1 that shall be used an inputs for tx2. These outputs can be script or wallet outputs.

const tx1 = await lucid.newTx()
   .payToAddress('addr_test...', { lovelace: 2_000_000n })
   .complete();

const tx2 = await tx1
    .chain(utxos => utxos.find(({ address }) => address === 'addr_test...')!) // filter tx1 outputs to be chained by some predicate of your choice
    .payToAddress('addr_test...', { lovelace: 2_000_000n })
    .payToAddress('addr_test...', { lovelace: 2_000_000n })
    .complete();

@gavinharris-dev
Copy link

Hi @will991 - When chaining do you filter out any 'spent' UTxOs from the UTxO set? I appreciate that this is not an RFC, however I was thinking that the complete method should (with an option):

  1. Remove any UTxO(s) that have been spent within the Completed Transaction;
  2. Add into the UTxO set any new UTxO(s) that would be created at the Wallet Address

Node: This is all predicated on the idea that with Lucid selectWallet* methods configure Lucid with a single 'address'.

@will-break-it
Copy link
Author

@gavinharris-dev
The current state of available UTxOs is stored here. And it is updated based on the Tx outputs matched by payment credentials here.

Hope that helps!

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

Successfully merging this pull request may close these issues.

2 participants