Skip to content

AI Chat feedbacks #82

@jinglescode

Description

@jinglescode

able to read website and create better context?

I did this:

Image

read this website https://buidlerfest.com/registration, and build this transaction with MeshTxBuilder.

it basically return standard replies:

Image

then i copy the entire page as text:

build this transaction with MeshTxBuilder.

Let's break down the transaction:

Parties
We have 3 parties involved in the transaction:

buyer: You, the one who wants to purchase the ticket.
issuer: The script responsible for validating the minting of the ticket NFT.
treasury: A holding account that will receive the ADA for all ticket purchases.
Inputs
The transaction takes 2 inputs:

funds: This input represents the funds for the ticket purchase and must contain enough ADA to cover the ticket price and transaction fees.
current state: This input contains the current state of the whole registration process (a datum with the current ticket count)
Outputs
The transaction has 3 outputs:

ticket + change: This output contains the minted ticket NFT and whatever change is left over from the payment.
new state: This output contains the updated state of the registration process (the same datum with an incremented ticket count)
payment: This output contains the ADA for the ticket purchase.
Shared State
The registration process makes use of a shared state to control the minting. There's an inline datum stored at a specific UTxO that holds the value of the total number of already purchased tickets.

Whenever a new ticket is purchased, this UTxO is consumed and a new one is created with a similar datum that holds the incremented number of tickets.

The structure of the datum is the following (using cardano-cli JSON notation):

{
"constructor": "0",
"fields": [
{
"int": ""
}
]
}


(where <next ticket number> holds the integer value that represents the next ticket to be minted)

To find the specific UTxO that holds the state, we use a "beacon token". This is a unique NFT that allows you to pinpoint the required UTxO within the issuer's address.

Constraints
For the tx to be valid, you need to make sure you comply with all the requirements enforced by the issuer script. These are:

The transaction must pay the ticket price to the treasury
The shared state ticket counter must be incremented by exactly 1
The ascii name of the ticket asset must be TICKET{x} where {x} is the ticket number
Ticket price must be:
400 ADA if submitted before 2026-Feb-01 12:00 UTC
500 ADA if submitted since 2026-Feb-01 12:00 UTC
Gotchas
You'll need to add collateral to your transaction (since it runs scripts)
You can use a script reference to provide the script (see quick reference below)
There could be contention of the shared state, make sure you don't have a stale UTxO when sending your Tx.
You need to specify an upper bound for the validity range, which is used by the script to decide the price value.
The number of your ticket NFT must be equal to the number in the state datum.


Quick Reference
| Field	| Value | 
| ISSUER BEACON POLICY | e1ddde8138579e255482791d9fba0778cb1f5c7b435be7b3e42069de |
| ISSUER BEACON NAME |	425549444c45524645535432303236 (hex) |
| TREASURY	|addr1qx0decp93g2kwym5cz0p68thamd2t9pehlxqe02qae5r6nycv42qmjppm2rr8fj6qlzfhm6ljkd5f0tjlgudtmt5kzyqmy8x82 |
| ISSUER SCRIPT REF	|31596ecbdcf102c8e5c17e75c65cf9780996285879d18903f035964f3a7499a8#0 |
| TICKET POLICY	|1d9c0b541adc300c19ddc6b9fb63c0bfe32b1508305ba65b8762dc7b |
| ISSUER	|addr1wywecz65rtwrqrqemhrtn7mrczl7x2c4pqc9hfjmsa3dc7cr5pvqw |

It returned a few steps, but the transaction part is not complete/wrong out-of-the-box:

const txBuilder = new MeshTxBuilder({
  fetcher: provider,
  verbose: true,
});

// Find the UTxO for the shared state using the beacon token
const beaconUTxO = utxos.find(utxo => utxo.output.amount.some(a => a.unit === '1d9c0b541adc300c19ddc6b9fb63c0bfe32b1508305ba65b8762dc7b'));

if (!beaconUTxO) throw new Error('Beacon UTxO not found');

// Increment the ticket count in the datum
const newTicketCount = beaconUTxO.datum.fields[0].int + 1;

const ticketName = `TICKET${newTicketCount}`;
const ticketNameHex = stringToHex(ticketName);

const unsignedTx = await txBuilder
  .txIn(beaconUTxO.input.txHash, beaconUTxO.input.outputIndex, beaconUTxO.output.amount, beaconUTxO.output.address)
  .txInCollateral(collateral.input.txHash, collateral.input.outputIndex, collateral.output.amount, collateral.output.address)
  .txOut(changeAddress, [{ unit: 'lovelace', quantity: (await wallet.getBalance()) - ticketPrice }])
  .txOutInlineDatumValue({
    constructor: '0',
    fields: [{ int: newTicketCount }],
  })
  .txOut('addr1qx0decp93g2kwym5cz0p68thamd2t9pehlxqe02qae5r6nycv42qmjppm2rr8fj6qlzfhm6ljkd5f0tjlgudtmt5kzyqmy8x82', [{ unit: 'lovelace', quantity: ticketPrice.toString() }])
  .mintPlutusScriptV2()
  .mint('1', '1d9c0b541adc300c19ddc6b9fb63c0bfe32b1508305ba65b8762dc7b', ticketNameHex)
  .mintingScript('31596ecbdcf102c8e5c17e75c65cf9780996285879d18903f035964f3a7499a8')
  .mintRedeemerValue({
    alternative: 0,
    fields: ['mesh'],
  })
  .complete();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions