Lobster Challenge: How to participate

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone in this short video i want to give a brief overview over the lobster challenge and explain how you can participate so the lobster challenge the lobster smart contract is a simple pluto smart contract that i deployed to participate in the celebrations of the alonso hard fork event and the idea is to give a name to charles's stuffed toy lobster and roughly how it works is that 500 people can participate by creating transactions that add their own random number to the random number that is being tracked by the contract and after those 500 votes are in this will be used to generate a final random number that then gives the name and you can read all the details in the github repository that i created for this purpose that's input output hk and then lobster minus challenge so all the details are in here so let's first briefly explain how it works so first of all we need the address of the lobster script you can find it here in the readme so that's this address here and let's first look what utxos which unspent transaction outputs are sitting at this address right now so i have a very simple script that you can also find in this repository in the scripts folder mainnet utxoat but if we look at that script briefly it's just a very thin wrapper about functionality provided by the cardano cli and it just takes one argument which is the file name that contains an address and then it just displays the utxo sitting at that address so for this to work you need a cardano node running with the newest version so that in particular you have access to the cardano cli and you always need this socket path for communication with the node and in my case it's called node.socket so if yours has a different name you would need to update this script accordingly and i have created a file with this lobster address so this here is the address that you also saw in the readme okay so let's see what's sitting there right now by executing this script and giving it that parameter this file with the address of the lobster script and we see that right now there are six utexos which is a bit unusual if everybody did what i thought they would do there would only be one so there's only this one that keeps track of the votes and the random number but in cardano the way the eu txo model works everybody can at any time send anything to any address so there's no validation where you send what validation only happens if you try to spend an output so there's no way to prevent people from sending stuff to this address and for that reason in order to find the right utxo the relevant one that really keeps track of the random number and the votes i minted this nft here this is this with this policy id and token name lobster nft this is also listed here in the readme of the github repository so this is this policy id and this token name so the utxo that contains this nft is the relevant one we can ignore all the others and then there are two more native tokens used those two have the same policy id this one here that starts with fd so you see that's the same here and that policy id is a very simple one that just means there is no restriction on minting or burning so whereas this one is an nft so there can only ever be exactly one of those these two are completely free so anybody can create new ones or burn existing ones and there are two relevant for this contract one with token name lobster counter and one with token lobster votes the idea is that the value sitting at this cote x oh that contains the unit nft keeps track of the current random number with the amount of the lobster counter token so 669 lobster counter tokens are at this utxo right now so that means the current random number is 669 and then the lobster votes token keeps track of how many votes there have been so there are 15 lobster votes tokens so right now 15 people have already voted the idea is if you want to vote you must create a transaction that consumes this utxo and creates a new one at the same address which again contains the nft updates the lobster counter with your own random number and increases the lobster votes by one so if i wanted to vote now for example with the random number 13 so the random number must be between 1 and 100 so 13 would be fine so that would then be 682 if i add 13 to this so i would create a new output at the same address that contains the nft and then mint 13 lobster counter tokens and then put all 682 to this new output and mint one lobster vote token so that then in the end there are 16. so that's all i created the script to make it easier to create this transaction so if we look at it briefly it's called lobster minus contribute and that takes seven arguments and then uses these to assemble the correct transaction so that uses the cardano cli transaction build command to to build the transaction then it signs it and submits it and the arguments are first is a utxo with funds that i have access to to pay for transaction fees and provide collateral then the utxo at the script address that holds the nft and the state then one of my addresses to receive the change then the signing file that will allow me to unlock this first argument this first mutex o the old counter value the new counter value and the old value of votes so let's try this let's first check again so this is the lobster script now i also need the utxo for the transaction fees so i have an address called address.wallet so that's one of my personal addresses where there are some funds so let's check the utxos there and i can see this last one for example i can use to pay for transaction fees so if i want to demonstrate that i can do lobster contribute so the first argument was this wallet utex o so i can just read that from here so i take this and now i must the syntax used as to to give this tx ix the index i use hash and then the index so in my case 0. so the next argument is the script utxo so that's this one here and that has transaction index one so it's this hash one now the next argument was wallet address so that's this address wallet to receive the change then the signing key file in my case that's called skt.wallet now the old count that we can read from here that was 669 then the new count so if i want to pick 13 as my number and the new count as i said before is 682 and finally the old number of votes which is 15. okay and that press enter and everything seems to have worked so there's some information and it says submit the transaction no error message so now we can check at the lobster address again whether it took effect and of course that can take a couple of seconds because on average there's a block on cardano every 20 seconds but it's only on average so it can also take longer so let's just see whether something happened already and indeed this already took effect so now we have 16 votes and the counter has updated to 682 and that's it so that's how you can contribute and at your own vote and once 500 of you have voted then we will provide a final transaction to bring the number to 501 where we add our own number so we picked one in the beginning and the whole contract is parameterized by that number so we can't change that after the fact so after 500 votes are in we will add our own number that we picked in the beginning to the count and then this can be a large number so then we take the remainder of dividing by the length of the list of names so the list of names is also in this repository so i just took some available list of of names from the internet and that list has 1219 entries so indeed says from 0 to 1218 so in the end we we add our own secret number then divide by 1219 look at the reminder and that will be a number between 0 and 1218 and then depending on what number that is we can just look up the name and that's all so if 500 of you or now it's only 483 or something 84 participate then the lobster will finally have his name so good luck and have fun
Info
Channel: Lars Brünjes
Views: 4,422
Rating: 4.9080458 out of 5
Keywords: Plutus, Haskell, Cardano, Smart Contract
Id: 6xEAnMaov3E
Channel Id: undefined
Length: 11min 38sec (698 seconds)
Published: Mon Sep 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.