Creative Constraints for Dapp Development: Workshop by Ann Kilzer (Devcon5)
Devcon·Fri, Oct 9, 2020, 12:00 AM
Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more. https://archive.devcon.org/archive/watch/5/creative-constraints-for-dapp-development Can the challenges of blockchain development — gas limitations, storage scarcity, and decentralized computation — create conditions for creative DApp development? Are the parts of Solidity that often confound developers actually starting points for creative thinking? 20 minutes: Survey of Creative and Whimsical DApps We will review games and whimsical DApps, from CryptoZombies and CryptoKitties, ERC721 collectables, to some of my personal projects, including a fruit-backed cryptocurrency, and a blockchain treasure hunt. 20 minutes: DApp Idea Generation We will brainstorm how to make fun and whimsical DApps. The room will break into small teams and draw random cards as idea prompts. One set of cards will contain Solidity features, others will contain game types and themes. 80 minutes: Build-a-long The next 80 minutes will be a hands-on DApp build-a-long of a Japanese-style treasure hunt known as a “Stamp Rally” in Solidity. (Sample code: https://github.com/ann-kilzer/blockchain-stamp-rally). Participants will build key parts of the app in Remix, and interact with a publicly hosted version of the UI. If participants want to continue learning and experimenting afterwards, there will be extensions in the repo. My goal is to show participants that blockchain development can be fun, creative, and approachable. Speaker(s): Ann Kilzer Skill level: Beginner Track: UX & Design Keywords: technical Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum Learn more about devcon: https://www.devcon.org/ Learn more about ethereum: https://ethereum.org/ Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. Devcon 5 was held in Osaka, Japan on Oct 8 - 11, 2019. Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/
Transcript
[Applause] thanks for attending my workshop my name's Dan yeah again a little bit about myself is I'm a software engineer and visual artist I'm up for engineering perfect and this is a picture of me with a real yeah so and yeah perfect we ready to start up in Tokyo or 10 engineers now a couple part-time staff and we're going to be middle of where layer or etherium we're trying to make blockchain easier to use so this is a workshop it's going to be about 90 minutes there's going to be a lot of different components to this workshop so I want to set some expectations first of all so I pitched this talk and is beginner-friendly and it's a mix level audience it's def con so I'm sure there's people in the audience that could probably code circles around me solidity there might be people that are writing their first smart contract so if you're in the former category maybe you can help your neighbor out hoping to learn something or maybe you see a way of writing solidity that's different or unique and you can make a pull request against my open source code fork the repo you know get creative with it if I mentioned something that he worked on that were a project that you really like feel free to give some small talk box I'm going to cover a lot of different creative projects in the space and you know hopefully I think there's just a lot of really exciting stuff out there so let's get it next I want to talk about what I mean by creative constraints and there's a couple more seats at the front so feel welcome [Music] so in university I studied fine art and bustled study computer science math and my dirty secret is my art classes were harder but I continued to study printmaking and painting in Japan and this is a woodblock print that I'm working on it so in printmaking might think about okay a one image here of this train and cherry blossoms and I have to think about the technical parts of separating into different blocks and getting some colored layers so I was thinking a lot about the connection between art and science and how technical things can be very creative I think art has a lot of process encoding has a lot of creativity so that's one thing that I think about the other thing is that sometimes in art and technology we encounter a roadblock so here this man is running into the door you can't unlock the door and sometimes if we take a step back we can see a new way forward I find solidity challenging but I also find it exciting and interesting and there is you know new ways of thinking that can be brought about when you encounter a challenge that have to be creative to get around so in the second part of the talk I went into a survey of games and creative projects in theory so first of all it's ERC 20 tokens so this is probably one of the most common terms that we talked about it's a fungible token can anyone in ten words or fewer give me a definition that was fungible yeah they're always they call the same sounds pretty good any other definitions invisible that's a separate a separate one so basically one unit is exchangeable for another unit of the same thing they can be interchangeable so in currency we can swap one for the other and traditionally in video games there's often in-game currencies but they're hosted on a particular server so in second life you have Linden dollars but that's all centralized in a second lights databases no currencies in games can actually live in their own world and it'll be traded in the open market so a couple examples would be decentralized mana and the Loom token in contrast we also have ERC 7:21 circles which are non flexible and great for collectibles so they illustrate for this picture I took is from a shop in Shibuya Tokyo called mondo racket there's also a store in Osaka as these of you know vinyl collectible figurines that are very popular in Japan and around the world and they're actually quite expensive maybe tens of thousands of yen hundred US dollars and they're all one-of-a-kind and so we're seeing something that you watch chains like let's make some one-of-a-kind pivots so I have a lot of examples to share this one is super cute they love these little brown guys they're of AXI infinity these are based off of axolotls the japanese word for these two the poetry book but society but basically they're generated via you know code and they have different features this one's for a good turn I'm gonna carrots another long hair is a watermelon on its head and what they're useful for is assembling in small font squadrons and fighting in battle so you basically collect these things and then the cave is the fight you can also breed them and so that would combine some of the code and mix them together so here a clover and baby and sort of this stage of it growing up into a weird little bird yeah another example of the RC 720 one is more just of a collectible but there's this kind of fun experience when you get to create a new building so you take some of these to the smart contract and it generates a one-of-a-kind building you know it has different features like a different background the arrow claws there are different heights some of them have rooftop pools I wasn't lucky enough but those are early curved okay T's is probably the most famous ERC 721 and this is let's see I mean there's a lot of delight in just what you might find so there's all these features of cats and as you know new cats are bred and generated you know you can discover interesting mutations that adds a lot of whimsy and delight to these contract so you know it's kind of fun to see this cat at the jumble background and demon horns and plain fur and this other aren't one that kind of looks like a seal so this you you know there's a ton of popularity and it's pretty fun crypto kaiju combines these real-world viola figurines using NFC blockchain so there's some neat mashups of the fiscal world and the digital world and another example not again but it's still really cool the Austrian Postal Service issued this crypto stamps that's both a collectible and I guess you could mail someone you cared about a really cool letter the other nice thing about ERC 7:21 is they can be just swapped and traded in different marketplaces there's a couple more seats at the front so feel free to step inside so open sea is a very popular marketplace that has a lot of crypto collectibles box lock allows trading of item to item codex is interesting that they're actually taking things that are not on the blockchain like real world art and assets and trying to connect it to a RC 721 and there's plenty more that I'm not mentioning but what's needed it's not locked into any particular place okay then I step back and just features of solidity that we might see in games so payable functions this is really integral how do you buy your code okay you said money you send your ease to a smart contract maybe you're playing a betting man you said you know ease to some betting pool time stamps are pretty interesting too pomo 3d is just fascinating because it's based on the concept of fear of missing out so the basic rules are when the timer ends the last player to enter the game wins the pot that's cool and anyone could pay to join the pool and extend the game by two minutes the creator's described it as a psychological social experiment in Korean I did a fun project its timestamps when I was doing my consensus project so my co-workers created as one of our first demos a Diamondback decrypted currency and there's a lot of projects that are putting assets in you know back from things and I thought well what's valuable in Japan and you think that's valuable in Japan is free you go to any department store you might find a fancy muskmelon that's worth maybe $100 this is pretty normal in Japan they're used as gifts reading on the site I think the most expensive ones went for to 27,000 usl is purchased a pair and they have nice stems and they have a little bow on it so I thought this would be really fun to make a cryptocurrency but the thing is fruit goes bad so what do you do that use the timestamp and when the fruit Roz we can't trade it anymore so we use the now keyword in solidity and you have to be a little careful with now a consensus is giving a security best practices later this week and they also have a lot of sunlight but keep in mind that with the now keyword planner schemes sort of punch it a little bit and not get caught so just it's better to use whiter time spans with doing comparisons it's an open-source project it's not a real ICO it's a satire but I read the Lobo it's like the enduring Lobo is split it's just some elements of broken and huh so here's a little bit of the code in the transfer function here we have this is expired helper function that basically compares the current time to now hash functions will you see hash functions in the workshop at the end the game we're building register reminder and hash functions we take a string or a bit of memory and run it through a function like ketchup that's the famous one in solidity and we you know get out some bytes summary transactions it's not just a particular theorem but I think it's really interesting and the actually infinity of folks did a really cool job with this so with Assyrian transactions you're paying gas and you're also paying in time and in a game you know that delay there's people get impatient one I don't want to wait 15 seconds for an action to happen so axiom finiti has a lot of gameplay and that happens off chain and then you can summarize it by clicking the sync impending experience sign a transaction and send it and then you know then you're incentivized to do this to level up your little critter at certain levels they can breed or you know grow and so it's a nice balance of putting things on the blockchain but not slowing down games play and keeping the incentives for people to keep playing camp it's also possible to use summarization and side-chains so rather than just putting things on the server you could put it on a separate block you could you know choose a blockchain that's more optimized for speed computation or scalability and I'm just going to name drop a couple put a couple people versus people that work in this space loom especially is really in the gaming space and they're all about side chains so they have a like a developer SDK that helps set up side chains and I think actually actually infinity is working with Pluto Omi's ago was one of the first developers in the plasma it Syrian side chain and then you know there's other companies to be more general side chain things like off chain Labs is doing server privacy-preserving such an called arbiter so this is concept of burning which would be maybe sending a token to the zero address and you know maybe even use that in the game we say high stakes cryptic ad betting and now we've locked up our kitties forever and 0xm it's also possible to layer and match up smart contracts because contracts are public anyone can interact with them and that's just a really fascinating thing with blockchain so does anyone know who's maybe time crypto zombies tutorial does anyone know what Curtis Ami's eat yeah they eat crypto kitties I found one unit shaped like a table it's very funny and it's fun because while it can't actually destroy the crypto Kitty it doesn't hurt it it does take the information and use that in their game and it's a fantastic tutorial it taught me to live anew so I had never committed Kittyhawks is pretty fun it's an e rc 721 on another year C 721 it was a Google from plugin and although I think it's not in the chrome story Lawrence wait but you could have taken your crypto Katie and given it you know a very dapper hat and a mustache and if your accessories and then there's meta verses which are just ecosystems that you know combine different blockchain technologies so just Central and end is a big one where you get parcels of land and you could put some of your crypto collectibles in there and they're partnering with different companies different startups so they just had a really big game jam and this was one of the demos you know some of the video assets and things which are different they make it a little character yeah I definitely want to explore this someone okay so the first part had talked a lot about things in salinity in the second part I'm going to move a little bit talking about some of the challenges but with the caveat that challenges often bring us new ways of thinking and I you know opportunities for creative problem-solving so one of the challenges is that there's a lot of different tokens out there and here's a couple that are just in the game space just that's just a handful you might have to use if you play some of these games and it's not always easy to get those tokens so I'll give you a case study for my personal life I am a US citizen residing in Japan and I wanted to get my token so I can play central and I have to complete the know your customer or kyc process so I go to an exchange in Japan and say I'd love to sign up it looks really cool and say well your assistant maybe should do it in the United States so I emailed the US side sign up through their website say well you don't have a u.s. mailing address where you're getting your bills paid we can't really don't know if you are where are you so oh no thanks I go to another exchange but they said it's very difficult for us to verify US citizens and our government doesn't make it easy so you know I'm norisse but thankfully coinbase I can after a couple feathers on face let me get some etherion so great partially the way there and then I turn my etherium into wrapped etherium or wet this token makes the etherium behave more like the ERC 20 spec and so the next step is just get some rana okay so I go to the relay order book and I put in a buy order for a hundred mana and nobody saw it maybe five days later somebody sells me and I know to dissemble to play my avatar name and because of rounding error at 99.999 live that's not enough mana okay back to the order but one mana please somebody couple days later somebody gets it I can register my name so story has a happy ending but it's not the easiest onboarding process - okay when you have to wait like 10 days another challenge is setting price and this is really personal to creators there's always a balance between making a profit on something and then getting people to buy it at lowering barriers to entry and that's you know a very personal thing but it's just there's a trade-off there the price also changed its day to day so yes actually here's an example from sorry this is kind of small but it goes from June of this year to mid-september we can see at towards the end of September that gas prices are quite a bit higher meanwhile the underlying currency is quite volatile as well so it just changes data and here's didn't another example when I went to generate my block city this little building in Atlanta notice I'm calling the same smart contract here at 0 to 4 a same smart contract three days apart same cost in ethereal but the underlying cost in u.s.
dollars is totally different so on the first day it's 8 dollars and 97 cents for the price and then the Gaspee is $3.75 three days later the transaction fee is 11 dollars and 10 cents and the Gaspee is only $1 24 so the overall transaction or while it's cheaper but it's interesting how these variables we get very independently there's also been a shift in just how games are played in terms of how to be charged for games when I was a girl you know you could get your you get your box your game you get your for discuss your mom would install it all day and then you play it over and over you play it as much as you want now games are they often have microtransactions it's no longer no longer a flat cost so he and like cow clicker you know you got to keep clicking on that cow it may be you you pay to turn that count with a beef later but it's no longer a flat price and then that you know some people like that in games some people don't it's just a different practice it can work well in cryptocurrency though because you pay in small chunks so we're trying to but people might you know friend of ability to pay there's also a time delay I talked about this a little bit when we were talking about summary transactions and how actually infinity solved it so there's this you know wait for it waiting for transactions to be mined and I think the crypto pays team did a nice job of having some cute animations and buildings I have this ghost cat while you wait for your cat to load and that can be a little exciting like whatever you're going to get so it can be an opportunity blockchain also is very at risk to security exploits FOMO 3d and I mentioned before let's review the rule so when the timer ends the last player will win the bull and anyone could paint join the pool and extend the game by two minutes however this team at SEC bit wrote this really awesome article I highly recommend and they figured out how to exploit the whole etherium network to win the game they basically sent some very high cost transactions that used up all the gas and ultimately failed but they were able to prevent anyone else from calling that smart contract in the next few blocks so we read more in a sec that's article if you're interested it's it's very interesting another consideration is you know how decentralized our games the etherium wasn't made to support - le potato like images or you know large objects that's not what strength is it's more about establishing trust so some of these things it's like where do you put the artwork where do you put any cache data before you loaded it onto the blockchain sometimes things go sour despite the best intentions you know if a development team falls apart or their servers go down how easy easy is it for another party to come and recreate the game one example you know I think the kid has project looks awesome but it's no longer available in the Chrome Web Store so it's very hard to play this game now that Google said I'm not sure if circumstances but it's not really playable so this is not a game but this is an art project that and he does a really good job of putting a lot of the data on chain it's Auto black clips by a group called larva labs and these are ERC 7:21 collectables and these patterns are generated through a smart contract and you know not too hard for someone to build the image when the image is not stored on the spark contract but the data is you could add a couple text characters and just use some code that you'd run to regenerate the image if you need another consideration is that in theory in this public so who's playing Dungeons and Dragons before I look like it it's a lot of Dungeons & Dragons you want to think about information lighting so we have this character community's got the game master screen screen and he's you know if you are a game master they're often hiding information for people that's slowly revealing it to build storage drive area maybe create some dramatic tension so you might want that in your damn you know contract calls are public and people can read those people can go and read events and see the data even your ID is a pseudonym it's not truly anonymous so it just might consider that ok this next part we're going to do a little bit of a hands-on activity and first I'm going to explain the rules so yeah we will use some of the ideas that we thought about solidity and we're going to take those and make our own pants so in for our purposes we're going to think about three Academy characteristics of games so we already talked a lot about see the features of solidity that might incorporate yes and I want to dive into the detail of what the other two current categories are so this is we're going to do it a little bit of a card game it's going to be kind of like apples to apples or parsnips humanity okay so game categories what type of game are we playing I'm going to name a couple that might not become a knowledge just in case you draw the card so you know what it is so one category of game is called a god-king and this is not in any specific religious sense this is more than errant on depression entity that can control a world so in some cities you have this sky view you know of this world that you can build things and you know decide how your citizens work and creating these things rollercoaster tycoon maybe it's just focus on the theme park and building rollercoasters one of my favorite games zooming up from 1991 since anyone played it so good but you're basically an ant you manage an ant colony and you can become any ant you can become the Queen can become a worker ant or a soldier and you're fighting for control of the back yard against rival ants and humans and lawnmowers another category of game that you probably will see any nosaka is a gotcha plant and this is a castle dispenser dispenses a toy it has a little bit of randomness because there's usually six different types of toys and there's even a bit point one I saw you can patriot again to get a plastic bit coin see if you can find it this one has a chain saw and drill and then some some like we know she needs calluses a famous artist in Japan they're really fun and interesting but it's just a bit of random granite or Spencer okay let's talk about theme or setting this type of card Peter setting is critical to a game and a lot of story told without even any human presence so I think all my favorite games are from the early nineties my other this is probably my very favorite computer game but it's missed it's anyone play missed yeah this little channel would there's no people in it it's just this abandoned place it's misty and kind of dark and you can see that people may have lived up above and you're just curious about how do I get in there how do I get into that world so the even setting is very important we can draw inspiration from the world around us so Osaka has lots of fun neon and giant giant puffer fish and things to see there's the world of Japanese mythology you know Kuniyoshi prints and boys fighting fish and samurai writing toads it's pretty okay so I'm going to go through a couple examples of how the game to play so we're going to have different types of cards and there's different colors and their symbols on them too if the colors are to see the green stars in the game category we're going to draw two of those and discard one blue cards have moon on them we're going to draw three and discard one so you have two cards left and salinity features are going to draw two and discard want and so maybe you'll get a keep a hand like this and you decide to pick your favorite okay I'm going to choose a racing game the features the theme is that it's post-apocalyptic and it's about ducks and I'm using the burning functions on sending things to the zero address so maybe I may be game called mad cracks to the pond warrior and you know it's someone hostile world or ducks have to fight for survival or get sent to zeros another example here let's take a roleplay game and we take trains and Japanese mascots and we're using layering of smart contracts so perhaps I decide to use PRC 7:21 collectibles and layer them together to build a Japanese rail network featuring cute mascots and wonderful trains that try to entice people to come ride my railway ok so now we're going to play it first what we're going to do is break into groups of maybe four to five people and you can move your chairs a little bit as long as we move the chairs back at the end of the workshop and some of us will be around the handout of deficit parts actually another credit is talking assistance in our shop that's so affects place and this has been awesome and thanks for making these great ideas some of the things I turned for like a yak freak says Betty arena and capybara racing where the losers character is burned so there's a really wonderful ideas that you can feel free to take your cards or play or later if you'd like and I'd like to move into if it's okay with people to move into the next part of the exercise where we'll build that game in salinity together and maybe you can take some of those ideas yeah this one is really cool I mean you've got some sort of fairy tale with the cursed cursed clothing objects and treasure tons of like DMV level so yeah save this one because this game who seems to happen so if that's okay with you let's go maybe pull our rock tops and move into the next part all right there's a bit of my legs here you know and hopefully the internet follow along with the slide here it's awful other people that are claiming solidity for the first time in this round okay well we're trying to help you if you have questions raise your hand little tour message keep everyone together yeah we're building stavroula is a game with that often telemetry companies and so this one is a game I can delete it to go around and when you get back to the Train and there's a competition to this of fishwich oh this is a thousand year old tradition this is when you go to Shinto shrines and who assembles his really beautiful stamps and only contains about 300 yards per page to get this written and well this stamp is actually the holy object with something that should be sacred it not mix with this type of scale this is got to be one of the origins of this fire game so because I wanted to make my co-workers laugh and do something fun I thought it would be really fun to go to stamp rally on the blockchain we're in Sybil's Thank You physical address you and enter a passphrase or you know in a virtual world and for such an important your address as your clear idea and then you can we collect all stamps you can win a prize so here's a little bit of what the front end looks like step on stamp rally it's an open source project on github and yeah you know there's a button read click to collect with Stampin together the correct passphrase for a place it will load the picture so first let's make sure that we all have some material so does anyone not have to test that rinkeby testbed aetherium doesn't not know what that means I guess so and that's okay because we can go through it together if anyone doesn't have you'll need that a mask okay so yeah we'll go through this and for those of you have been doing this a long time you please have a mutation or maybe even help out your gamer but you'll want to go to madame a co and download let's see download this tool I'm on slide 81 by the way of people are people able to access the slides yeah you up the key holding each other look great but you know such public Senate tablets or things so yeah we want to install that about and that is 12 years and so will follow my slide so again who doesn't have been a massive insult so yeah [Music] but you can follow along on the slide I'll tell you which is white hot so hopefully if you clean it up yeah and make sure to use zeros not the letter O in the week so that you can get the slide extra both be zero so I'm going to set up so this is basically it's a tool that lets us Skinner after the appearing blond child so one install it it's a bet amount that I owe and I'm on slide eight so with your new meta maps you'll point yes let's get set up to create a wallet if you already have a seat trace then probably you use it before but it's easiest it's just like yes let's get set up and there's a point two seven secret backer phrase and this is a really important step but for the the purpose of getting through this workshop we're going to return to this later or you might use your account forever so it's important there's a link on this slide slide 83 but it's really important to use your backup phrase because in a decentralized ecosystem you can call your bank I forgot my passport that doesn't exist grab my password okay it should look like this okay so the next step would be to get some room to be test Network and can anyone tell me what the difference was you test that work in the main that is there's no value there's so many things yeah there's a lot of things England whatever different problem were things but one of the purposes is you know just gives us a way to try things about before making our team life so that's a that really short version sure there's a lot more depth there and use a box if you have a Twitter or Facebook account if you don't have one of those ask your neighbor to send you something we're going to go on the rinkeby test now that's one of the so this is my carrot sauce it's uh pretty beat-up I oh well my slides are also there public and that toriel don't github - so sorry cut the Wi-Fi but it is possible to sort of follow a lot of this material after so I'm really keen we're seeing you know how you can get freaking these has to eat their gear needs you to click in that bouncing on the little box and make sure you're on the Rica me networking select that in the top and click on the account two coffees address so slide eight seven here show it's gonna pop it up and then you look into Twitter or Facebook in them and you would make a post with your dress and then you would click on the share button to share that copy the link to the tweet I don't have facebook so I don't know works and you paste it into that option and you select hippie ether and choose how much easier you want and you know it a little while to get money to the blockchain I think three is probably but we want one sufficient don't need much but yeah if you already have some rapini you're good so any questions on this stuff so far all right okay next let's talk about remix so remix is an in-browser editor for solidity who sees remix before yeah so most people great it's changed a little bit the last few months there's a new UI so I'm going to review things just in case you haven't seen the latest and greatest but one of the main changes is because these features called modules on the sidebar so it's best when you get to the main page to click this environment button here and choose solidity and we'll load the compiler and the deployment modules and the file editor so we have all the all the tools we need so if you ever get we see it remix dog theory org and I'm on slide 94 if you're following along with the death okay so you have to make something we're going to create a new file we're going to call it stamp Murali Sol and actually in the file explorer that's the icon all the way over on the top and then you'll click the plus button to make a new file and you can give it the name Sol is for solidity and let's get into the code so there's a slide 98 here's a link to a gist that has some of the code here let me just show you what that looks like there are some bits of code that you can copy and paste into your salinity editor here and let me make this a little bit bigger yeah so that and copying it in two minutes and copied it into your my select theater with him stop fighting the Internet so sorry this might just be a demo one less interactive yeah so yeah you don't have a Twitter um can you know I guess I just yeah it's a tiger we'll send you some of this [Music] [Music] and we've got our contract and have a couple different variables that are set in the constructor so we'll have the number of stamps for the game it's how many you know spots there aren't collect so we're not going to do 30 enough for us there's where you learn to address that owns it and can control it and change the pictures there's a struct that we use that stores the hash passphrase so the secret code that they need to enter and we wouldn't throw one wave function so that it's fast and then we'll have a URL that moves the image of a stamp and a prompt that might give us a little hint to what that stays by one answer and then we have an array that's eternal of all these penises so is all that happy conscience is with the story spending so the first half will be doing a static constructor and that's for this is a copy it in from the gist but it's a good exercise and actually making sure that your remix and Cuyler works so if you go to the gist back here and sorry you get a full screen good and we go to reception one of the dish the constructor to do and we'll copy that in copy that remix paste under them to do here we can see that our constructor is taking some parameters unsigned integer like 8 8 bits of a number of stamps and a name and it's a public function so what we do is we assign some of these variables and the caller becomes the owner of the contract okay so in remix if we click the second icon which is sort of a celebrity icon it's like these to share rooms we'll want to make sure that audio compile is selected and this was really important because when you make changes to the code it will keep compiling it so this is a nice code to use after we've selected Auto compiled a month like 100 by the way and will move towards the third icon from the top which is the interior Lobos little arrow when we go to the side and just lets us deploy and run transactions so we'll click on our stamp rally which should be compiled and then you can click on the little drop down arrow right here on deploy and then we can enter some parameters so maybe we say we want three stamps we're going to call it steam locomotive graphic and then once we've employed it you should see this gray bar here we can do the drop down we should be able to see the name the number of stamps and our address of the owner so if you want to be able to get there and catching up okay so I go back a few slides it seems like people are still just getting the photo face with let's go back to just pasting in the tamborelli so copy it through the dish and paste it into solidity and then make sure and I've pasted in the constructor from here I've taken that and paste it in where it says to do one at destructor and this is sort of just the hello world of giving Mike on compilers checked like run here and then I'll click deploy and I'll see it down below and I can verify oh I didn't give it any parameters so yeah let me give it so I have to play spongebob yeah cool so you have people getting the constructor constructor is Mac okay so yeah any questions on that so far okay I'm gonna move apart and we're going to talk about function modifiers so here's an example of a function line of the fire it's pretty common one and basically a function modifiers are syntactic sugar that likes checks and preconditions on the function or change the way the function behaves so this one is called on the owner and it means that only the owner can call to our contract or that method basically here they were going to have a require statement and look at message sender messages on sender's a special reserved word or reserved sequence and solidity that means this is the address that's calling the contract and we can check it against the owner that we've registered in the constructor and make sure that you know who's changing the stamps we only be game manager we don't want outsiders messing with our game and then it's really important that modifiers have this underscore and a semicolon because that's that means the rest of the code in the function body will be run later so it's actually equivalent the only owner is equivalent to writing code where there's a require statement at the beginning these are two ways I guess yeah two ways of doing the same thing so it's here's here now we want to write a bonfire and then we called the ballade position it's going to do take it you annotate of underscore position and we want to check that the position in the stamp is greater than or equal to zero and less than the number of total stamps in the game so you can copy the template or just type it from the gist from the function modifier part copy this here and I would recommend looking at only owner as a reference so we'll paste that in and under to do it too and you know you might get a little red pop up that your compiler tancrède and I'll let you figure out how to make it happy again so yeah let's I'll give you about five minutes to work on that feel free to work together if you're having trouble around cool does anyone want to see your answer yes but just like required luckily expression position greater than zero yeah yeah yeah so it's totally fine to compare zero also equivalent that unsign Ian's cannot be negative so it can be like this but both are valid solutions so feel free to copy this in and then we got this part okay next we're going to talk a little bit about storage and memory so in solidity you know we've seen we just talked about on-site it's sort of simple types the more complex types such as stranger structs need to be stored differently and we need to tell the compiler a little guideline about how we store things so storage and is a key word that can be used or things that are persistent and this is great but it's more expensive to store in the blockchain because you're making this data be put into this permanent record and hosted on other people's computers so very important for state variables anything Fogle's the contract state memories for things that are not persistent there's local computations or temporary variables if you're moving the data around so here's an example where we are storing a stamp key and we can use the storage keyword the permit variable and a sign that stamp key to a permanent variable on departure versus in memory where we have a temporary variable and it's just that keyword it's all that you need so if we go to code store the player's parts on the blockchain we will copy some of this here from the gist we've got the relic card which is destructive in the worst we're in a store on the first again and we have something that links to a rally card and this lookup table between the player yeah it might be easiest to just kind of copy the code from the gist we're gonna have this function here that kind of dealt with some of the code on the other slide and actually I'm sorry this is an example I wanted to show the user having it's down and because this is just a check of data that's already on the blockchain when we were treating the user card we can use the memory key word because we don't need to store it again we're just looking it up and returning for that data to the user we the boolean value of whether or not and so a memory example would be the user hazardous down and we're trying to get the stamp image they have the stamp then we're going to also using losing memory here returning it or it's just making a temporary copy in a center function though we'll need some persistent things so yeah let's see this one will copy and I'll let you fill it how do we assign the staff to you in the question marks here to be its storage their dubious memory and so yeah your exercise would be right at cetera so let me go to the gist here and we'll copy this section three hair code to store players parts a bit of code here but we'll copy it into remix and they'll see the two right feet and there's a hint that the first line will look of this form so I'll give you a couple minutes to work on that bridge does anyone have an answer or his clubs is it remember your sorry your solution storage why right because we want to persist that they use very basic units now so when you storage and then giving you an assignment here where we assigned to be the parameter variables to the local storage object here okay so the last I think we have maybe 10 minutes left and I want to make sure that we actually get to play the game at this time so let me skip ahead a little bit I'm going to just jump into and yeah if you like this or want to keep play with it it's on github you can make a pull request and follow along you know it's a work in progress let's a little bit about web 3 so is one of the libraries available for connecting connecting to the Nerium blockchain so we'll put some JavaScript and some fun pictures on the front of your smart contract and so we'll be using metamath to side transactions so if you can go to an - pilzer duck in Hyundai IEO / watching - tamborelli my mom's like 125 and explained then we can actually see it in action care here it is again so people will look that up and your management while it's ready look like this so you might need to make sure that it's connected and click on the meta mask and make sure that it might give a pop-up about connecting and please allow it and then you let me choose an address where and then select the stamps the password is octopus all lowercase and then you click Submit should get a pop up to sign the transaction click confirm and make sure you're on repeat and you'll have to wait a moment and it should lower this down it takes a little while if you mind people are interested like the other employees on strategies in the slides actually I think that leads to it on either skin if you want to here it's academic openness to yeah oh you can't actually see that people are calling the contract and we've got the stamp and stamp collected okay a couple you know that past branches make sure it's moms bus all of our case oh okay really sure what happened to the password here okay broken or something so I'm trying to give up try to get the mountain but beauty home later and you can make your own and make your own artwork if you want to share it it's on github yeah is anyone having trouble getting the stamps to submit to each other yeah okay it usually takes about a minute but yet tried to bug your the mallet I think something broke with the opposite online chat although okay I don't know their mascots mighty today all right did she take something that's okay what was the rest of the time I mean I guess I'd like to just say in general that law team has a lot of you know we talked about creative constraints we did a nation our tivity we did a exercise and building some things in solidity and so we cover a lot of ground and sort of unifying theme is that I think there's a lot of potential for creates gonna be here even though these tools are very new and novel and sometimes always changing and so I hope you enjoyed it and I yeah if you have any questions email me and at curve read calm or you know and ask questions now thanks for attending [Applause] [Music]
Automatic transcript — names and jargon may be misspelled.