Skip to content

feat: chaining of txs#231

Open
will-break-it wants to merge 1 commit intospacebudz:mainfrom
will-break-it:chaining
Open

feat: chaining of txs#231
will-break-it wants to merge 1 commit intospacebudz:mainfrom
will-break-it:chaining

Conversation

@will-break-it
Copy link
Copy Markdown

@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();

@will-break-it will-break-it force-pushed the chaining branch 2 times, most recently from 837a8b7 to 04f9507 Compare November 3, 2023 14:08
@gavinharris-dev
Copy link
Copy Markdown

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
Copy Markdown
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