1

I want to construct public lists that can be altered by people who own a specific token.

Is there a way I can group data together into an array like structure and allow users to append to it?

I understand metadata will play a fundamental role here, and I guess it will have something to do with the wallet updating the arrays digital signature.

5
  • 1
    How large is this array going to be and what shall it contain ?
    – Jey
    May 4 at 18:08
  • It will contain IPFS hashes of files, the size could vary but possibly up to 500 entries
    – kannastor
    May 4 at 18:41
  • What function does the array serve? Does it only serve information or do you want to use it with some logic?
    – Fermat
    May 5 at 9:42
  • purely as an immutable information log that can be queried using blockfrost for example
    – kannastor
    May 5 at 10:25
  • Do you want it to be an append only list?
    – Fermat
    May 5 at 15:05

2 Answers 2

1

The transaction size is limited. So your list cannot grow too large. But assuming you stay within these constraints, you can achieve what you want by (i) parametrising your validator with a type that contains the currency symbol of the needed token and then (ii) checking in your validator if the token with this currency symbol is in the inputs. Additionally you would check that the list of hashes (which you would store in the datum) is only appended and not altered.

With the Vasil hard fork in June, you can have another approach to (ii). You could add the UTxO that contains the token as a reference input and check in the validator that (a) the reference input contains the token and (b) that the transaction is signed by the holder of this reference UTxO.

Edit:

If you want a solution without smart contracts you could indeed use the metadata but it would also mean that the list update is controlled by a central party (which would be you). A possible design would be the following one:

  • The location of the list is the metadata of the most recent transaction containing a specific token that you own. Let's call this token the list-NFT.
  • The users that want to append the list make a transaction to your wallet address. This transaction contains in its metadata the entry to be appended. The transaction would also contain a specific token that proves that the user has the right to append the list.
  • You have a service running that regularly filters the payments to your wallet address, verifies the presence of the token, and makes a transaction containing the list-NFT and the appended list.
2
  • thank you for information on this, i appreciate it. I was thinking users could all add entries to the same metadata key and true entries could be found by querying the blockchain with some off chain logic to confirm the person owned the nft at that time. Smart contracts seem like a better option though.
    – kannastor
    May 5 at 10:32
  • Ok, I understand. I edited the answer.
    – Jey
    May 5 at 11:07
0

I think there are two kinds of solutions. The first is the most cost efficient and is focused on offchain indexing of the database, anybody can do it but there is no logic onchain. The second one is where you use plutus (and especially version 2, hard fork will be 29 of june and plutus will be fully available 1 epoch later).

For the former you can just let holders of a token create metadata transaction that contain atleast x tokens y. Then with a DB-sync instance anyone can index the latest state of the database. You even can introduce some overriding rules.

The second solution could be to use the reference capabilities of plutus V2. With the upcoming hard fork referencing outputs will be possible. With this you could make a database sitting on an script address where each UTxO is an entry. You could use this database in the future if needed. To prevent false entries you could create a minting policy which created some validity token if x amount of token are present. The cool thing about this solution is that the data is pretty localized and the present state is well defined and easy to obtain.

Hope this helps and I would love to see you make one of these!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.