-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
How can I chain transaction? #145
Comments
Hey, what Lucid version are you on? I'm not sure if you are on an older version or have |
@alessandrokonrad Removing the Here's what I'm currently doing: const tx = await lucid
.newTx()
...
.complete();
const signedTx = await tx.sign().complete();
const h = signedTx.toHash();
const i = signedTx.txSigned
.to_js_value()
.body.outputs.findIndex((out: any) => out.address === xxx);
const outputJs = signedTx.txSigned.to_js_value().body.outputs[i];
const output = signedTx.txSigned.body().outputs().get(i);
const tx2 = lucid
.newTx()
.collectFrom(
[
{
txHash: h,
outputIndex: i,
assets: valueToAssets(output.amount()),
address: outputJs.address,
datum: Buffer.from(
signedTx.txSigned
.body()
.outputs()
.get(i)
.datum()
.as_data()
.get()
.to_bytes()
).toString("hex"),
},
],
unitData
)
... |
|
Yup, the provider is blockfrost, is it because blockfrost doesn't support tx chaining yet? |
@alessandrokonrad In that case, would switching to another provider like |
I think blockfrost actually supports chaining, but you can check out the the Kupmios provider too. I think you just have to try out what works and what not. The difficulty is just coin selection. Lucid may select UTxOs that you already spent. You can disable coin selection, but that makes it harder of course. As I said I may gonna write something more high level for this. If you have ideas for that too, feel free to share and contribute to Lucid. |
@alessandrokonrad a high-level API for tx-chaining would be quite awesome! :O |
I looked into it, and thought it might have to rest on keeping track of the spent/created outputs somewhere, and replace one or some of the utxo-getters. Rn I'm trying to wrap my head around how to best achieve this, as it appears this varies based on wallet/wallet-selection-method. Will create a pull request once I got something. |
We get around this by tracking which UTxOs are spent and then removing them from coin selection. We're currently doing this tracking outside of the Lucid instance, but I think Lucid could be updated to track this internally within Lucid. The main issue would be that Lucid typically queries for new UTxOs during building of transactions, so any spent UTxOs would be re-added.
Can confirm that Blockfrost supports chaining, up to a limit. We got to about 3 transactions chained before Blockfrost throws an error. |
Added an API that simplifies chaining txs here. |
I'm trying to use lucid to chain transaction, meaning to create a transaction that consumes output from another transaction in mempool, which is yet to be confirmed on-chain, it is possible to do it on Cardano, but it's not obvious how can I do it using lucid.
I tried to do it but I got this error
The error seems to be coming from the call to
construct
functionlucid/src/lucid/tx.ts
Lines 584 to 588 in 4c92f56
But if this error truly comes from Ogmios, I do know that they support transaction chaining, in their
EvaluateTx
API, they take an argument calledadditionalUtxoSet
, not sure if Lucid supports it or not.Appreciate if I could get help on this issue.
The text was updated successfully, but these errors were encountered: