PaimaStudios / paima-engine

Novel trustless web3/blockchain gaming engine.
MIT License
55 stars 19 forks source link

Cardano transfer CDE #262

Closed SebastienGllmt closed 4 months ago

SebastienGllmt commented 10 months ago

Expected use-case: detect if somebody sent ADA to us to buy something in the game. Use tx metadata / datum to specify what they are buying

This CDE takes in a payment credential (could be a payment key hash, could be a script hash) and monitors all ADA sent to that credential.

The main question is: what data does Paima get to see when it happens?

  1. It can't just be the tx cbor, because then you don't know the context of the inputs (other than tx hash and id)
  2. It can't be the Plutus context since it doesn't include tx metadata (which we want)

So we have two choices:

  1. Give the entire tx context + extra information about the tx inputs (in Carp these are two separate queries, but we'd have to modify the tx history endpoint to give both at once)
  2. Give some subset of the tx info that we deem sufficient

Picking (2) maybe is useful for most basic case possible for people who don't want to deal with the complexity of (1). In which case, I would give the following:

Update to the state machine should see the full transaction CBOR from Cardano. The reason I think we have to do this (instead of providing a simpler interface) is because a lot of use-cases may want

  1. List of outputs the funds were sent to that contain the stake credential
  2. List of all inputs
  3. Transaction metadata
  4. Output datum for the UTXO created (hash or inline)

One thing mentioned by Eugene is that we can actually remove "list of inputs" from the requirements if we have users specify the address to credit the data to in the game as part of the metadata (which we probably want for a lot of cases anyway)

Important note: there may be multiple outputs with the same address in the transaction, so this CDE should not run "per output", but rather once for the transaction in general

SebastienGllmt commented 9 months ago

See #280