aiken-lang / site

Website and Docs for Aiken
https://aiken-lang.org
Apache License 2.0
8 stars 49 forks source link

Persistent Errors Encountered in Vesting Tutorial Using Aiken and Lucid #46

Open santiagoziel opened 1 year ago

santiagoziel commented 1 year ago

System Specifications

Problem Description

I'm a beginner in Cardano development, testing out Aiken and Lucid, and I'm currently facing issues with the tutorial located here: https://aiken-lang.org/example--vesting.

While the "Hello World" example worked fine, the 'Vesting' tutorial has been problematic, particularly when unlocking the funds. I've encountered numerous errors, primarily around the following line of code:

const tx = await lucid
    .newTx()
    .collectFrom(utxos, redeemer)
    .addSigner(await lucid.wallet.address()) // this should be beneficiary address
    .validFrom(currentTime)
    .validTo(laterTime)
    .attachSpendingValidator(from)
    .complete();

Expected Behavior

The tutorial's example code should execute without errors, specifically the transaction should be successfully created and the funds should be unlocked as per the steps outlined in the tutorial.

Current Behavior

Initially, The code on the examaple would not compile, i added types and fixed a variable name. Then I received a transaction submission error:

"transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (OutsideValidityIntervalUTxO (ValidityInterval {invalidBefore = SJust (SlotNo 28573407), invalidHereafter = SJust (SlotNo 28580607)}) (SlotNo 28573348))))])"
if (result?.status_code === 400) throw new Error(result.message);

After addressing this by removing the .validFrom and .validTo lines to match the previous example, I started receiving another error:

error: Uncaught (in promise) "Redeemer (Spend, 0): The provided Plutus code called 'error'.\n\nExBudget {\n    mem: 13835841,\n    cpu: 9936288424,\n}\n\n"

Steps to Reproduce & Attempted Solutions

Im running the tutorial code on the Preprod network. I've tried the following steps to resolve this:

  1. Looked up the error message, but no clear explanations or solutions were found.
  2. Adjusted the Smart Contract to take in a redeemer, as some people encountered a similar error when sending the wrong redeemer to a Smart Contract.
  3. Stripped most of the logic from the Smart Contract, considering the error message seemed to hint at exceeding the node's budget. This didn't resolve the issue.
  4. Made both the "owner" and the "beneficiary" work with the same key pair. ( This worked once but failed on the next attempt)
  5. Checked the UTXOs, waited for a certain number of confirmations, tried passing only one UTXO, and made several other minor adjustments.

Despite these attempts, the issue persists. The few times it did work, it failed again on the next try, leading me to believe that the successful attempts might have been due to luck rather than a concrete solution.

VledicFranco commented 1 year ago

Also to add, trying the same tutorial, the code as it is in the tutorial doesn't even compile. and the namings between the functions are a bit confusing.

rvcas commented 1 year ago

@VledicFranco @santiagoziel I didn't build that one but those tutorials are in the https://github.com/aiken-lang/site repo. Not in this one. We'll review the tutorial and see what went wrong.

avi69night commented 3 weeks ago

tey this

const beneficiaryAddress = 'addr1...'; // Replace with the actual beneficiary address

const tx = await lucid .newTx() .collectFrom(utxos, redeemer) .addSigner(beneficiaryAddress) // Use the beneficiary address .validFrom(currentTime) .validTo(laterTime) .attachSpendingValidator(from) .complete();