lucid
lucid copied to clipboard
feat: chaining of txs
- [x] simple extension for
tx_complete
type API to supportchain
ing of transactions - [x] 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();
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):
- Remove any UTxO(s) that have been spent within the Completed Transaction;
- 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'.