 Thanks for attending my workshop. My name's Dan. Yeah, to begin. A little bit about myself. I'm a software engineer and visual artist. I'm from Montana in the United States. And I move to...thank you. Is there another Montana here? Wow. What's your last? Oh, nice. I live in Tokyo now. And I'm...we talk for engineer at HerbGrid. And this is a picture of me with a real yak. So... And yeah, HerbGrid, we're a small startup in Tokyo. We're 10 engineers now, a couple of part-time staff. And we're building a middle-of-clear layer for Ethereum. 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 pitch this talk as beginner-friendly. And it's a mixed-level audience. It's DevCon. So, I'm sure there's people in the audience that can probably code circles around me. In 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. Help them 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 you worked on, or a project that you really like, feel free to give some small golf box. I'm going to cover a lot of different creative projects in the crypto space. And, you know, hopefully, I think there's just a lot of really exciting stuff out there. So, let's get into it. Next, I want to talk about what I mean by creative constraints. I think there's a couple more seats in the front, so feel welcome to have a seat. So, in university, I study fine art. And I also study computer science and math. And my dirty secret is my art classes were harder. But I continue to study printmaking and painting in Japan. And this is a woodblock print that I'm working on. And so, in printmaking, you might think about, okay, I want an image here of this train and cherry blossoms. And I have to think about the technical parts of separating it into different blocks and getting colorful 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, and coating has a lot of creativity. So, that's one thing that I think about. The other thing is that sometimes in art, in technology, we encounter a roadblock. So, here this man is running into the door. He can't open, lock 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 new ways of thinking that can be brought about when you encounter a challenge that has to be creative to get around it. So, in the second part of the talk, I want to do a survey of games and creative projects in theory. So, first of all, these 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 of fungible? Yeah? They're all the same. All the same. Sounds pretty good. Any other definitions? The visible part of that? The visible, I think that's 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 Second Life's databases. So, now currencies in games can actually live in their own world and be traded in the open market. So, a couple of examples would be decentralized mana and the loom token. In contrast, we also have ERC721 tokens, which are non-funcible and great for collectibles. So, the illustration for this picture I took is from a shop in Shibuya, Tokyo, called Mandorake. There's also a store in Osaka, and it's these, you know, vinyl collectible figure ranges that are very popular in Japan and around the world, and they're actually quite expensive, maybe tens of thousands of yen per each, or a couple hundred US dollars, and they're all kind of a kind. And so, we're seeing some of that in the blockchain. It's like, let's make some one-of-a-kind goods. So, I have a lot of examples to share. This one is super cute. I love these little round guys there. Axie Infinity. These are based off of Axolotls. The Japanese word for these is uporupa, but that's an aside. But basically, they're generated via code, and they have different features. This one's throwing a turnip and a carrot. Another one here has a watermelon on its head. And what they're useful for is assembling small squadrons and fighting in battle. So, you basically collect these things, and then the game is making them fight. It's really adorable. You can also breed them, and so that would combine some of the code and mix them together. Here I have Clover and Baby, and sort of this stage of it growing up into a weird little bird. Another example of ERC721 is more just of a collectible, but there's this kind of fun experience when you get to create a new building. So, you paint 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 class, there are different heights. Some of them have rooftop pools. I wasn't lucky enough, but those are really neat. Cryptokitties is probably the most famous ERC721, 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 contracts. So, you know, it's kind of fun to see the jungle background, and demon horns and flamethrower, and this other orange one that kind of looks like a seal. So, this game, you know, there's just a ton of popularity, and it's pretty fun. Cryptokaiju combines these real-world vinyl figurines using NFC and blockchain. So, there's some neat mashups of the fiscal world and the digital world. And another example, not a game, but still really cool, the Austrian Postal Service issued this crypto stamp that's both a collectible, and I guess you can mail someone you cared about a really cool letter. The other nice thing about ERC721 is they can be swapped and traded in different marketplaces. There's a couple more seats at the front, so feel free to step inside. So, OpenSea is a very popular marketplace that has a lot of crypto collectibles. BlockSwap allows trading of item-to-item codecs. It's 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 ERC721. And there's plenty more that I'm not mentioning, but what's neat is it's not blocked by any particular marketplace. Okay, I'm going to step back into features of solidity that we might see in days. So payable functions, this is really integral. How do you buy your crypto kit? You send money, you send your ETH to a smart contract. Maybe you're playing a betting game. You send, you know, ETH to some betting pool. Time stamps are pretty interesting too. FOMO 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, the pool. 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 ingredient. I did a fun project with time stamps when I was doing my consensus project. So my co-workers created, as one of our first demos, a diamond-backed cryptocurrency, and there's a lot of projects that are putting assets in, you know, backing things. And I thought, well, what's valuable in Japan? And the thing that's valuable in Japan is fruit. If you go to any department store, you might find a fancy musk melon that's worth maybe $100. This is pretty normal in Japan. They're used as gifts. I think the most expensive ones went for 27,000 US dollars for just a pair. And they have nice stamps 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 then? You use the time stamp. And when the fruit rots, you can't trade it anymore. So we use the now keyword in Solidity. And you have to be a little careful with now. I know Solidity Consensus is giving a security best practices later this week. And they also have a lot of this online. But keep in mind that with the now keyword, you can sort of bunch it a little bit and not get caught. So it's better to use wider time spans when doing comparisons. It's an open source project. It's not a real ICO. It's a satire. But I made the logo. It's like the Ethereum logo is split. It's just another one that's broken in half. 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. Well, you see hash functions in the workshop at the end, the game we're building. But just a reminder, hash functions, we take a string or a bit of memory and run it through a function like Ketchak. That's the famous one in Solidity. And we, you know, get out some bytes. Summary transactions. It's not specifically taking Ethereum, but I think it's really interesting. And the Axi Infinity focus did a really cool job with this. So with Ethereum transactions, you're paying gas and you're also paying in time. And in a game, you know, that delay, people get impatient and want, they don't want to wait 15 seconds for an action to happen. So Axi Infinity has a lot of gameplay and that happens off-chain. And then you can summarize it by clicking the sync pending experience, sign the transaction and send it. And then, you know, 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 a game. It's also possible to use summarization and side-chain. So rather than just putting things on the server, you could put it on a separate blockchain. 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, a couple groups of people that are working in this space. Loom, especially, is really in the gaming space and they're all about side-chain. So they have, like, a developer SDK that helps set up side-chains. And I think, actually, Axi Infinity is working with Loom now. Omise Go was one of the first developers of the plasma Ethereum side-chain. These other companies do more general side-chain things like off-chain labs is doing sort of a privacy-preserving side-chain called arbitra. So it's a concept of burning, which would be maybe sending a token to the zero address. And, you know, maybe you could use that in a game. Maybe you could say high-stakes, crypto-kitty betting, and now we've locked up our kitties forever in zero X7. It's also possible to layer and mash up smart contracts. If they're public, anyone can interact with them. And that's just a really fascinating thing with blockchain. So does anyone know who's maybe done the crypto-zombies tutorial? Does anyone know what crypto-zombies eat? Crypto-kitties. Yeah, they eat crypto-kitties. I found one here that shaped like a pickle. 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 and it's a fantastic tutorial. It taught me solidity, so I highly recommend it. Kitty Hats is pretty fun. It's an ERC 721 on another ERC 721. It was a Google Chrome plugin, although I think it's not in the Chrome Store anymore, unfortunately, but you could have taken your crypto-kitty and given it, you know, a very dapper hat and a mustache and other accessories. And then there's Metaverses, some of them that, you know, combine different blockchain technologies. So just a central land 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 and different startups. So they just had a really big game jam and this was one of the demos of, you know, some of the video assets and things, the shark rendering thing. You can get a little character. Yeah, I definitely want to explore this one more. Okay, so the first part I talked a lot about things in solidity and the second part I'm going to move a little bit into talking about some of the challenges but with the caveat that challenges often bring us new ways of thinking and, 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 a handful that 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 from my personal life. I am a US citizen residing in Japan and I wanted to get on a token so I could play Centralland 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. They say, well you're a US citizen maybe you should do it in the United States. So I email the US side and sign up through their website and they say, well you don't have a US mailing address where you're getting your bills paid and we can't really, you don't know who you are. Where are you? So, oh no thanks. I go to another exchange and they said it's very difficult for us to verify US citizens and our government doesn't make it easy so, you know, no worries. But thankfully Coinbase, you know, after a couple failures Coinbase let me get some Ethereum. So great, I'm partially the way there. And then I turn my Ethereum or WET. This token makes Ethereum behave more like the ERC-20 spec. And so the next step is just get some mana. Okay, so I go to the relay order book and I put in a buy order for 100 mana. And nobody's selling. Maybe five days later somebody sells me. And I go to Descendoland to claim my avatar name. And because of rounding error I have 99.999 mana, that's not enough mana. Okay. Back to the order book. One mana, please. Somebody. A 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 to a game. We 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 and lowering barriers to entry. And that's, you know, a very personal thing, but there's a trade-off there. The price also changes day to day. So gas fluctuates. Here's an example from, sorry this is kind of small, but it goes from June of this year to mid-September. You can see 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 day to day. And here's another example. When I went to generate my block city this little building in Atlanta notice I'm calling the same smart contract here, 024A same smart contract three days apart same cost in Ethereum but the underlying cost in US dollars is totally different. So on the first day it's $8.97 for the price and the gas fee is $3.75 Three days later the transaction fee is $11.10 and the gas fee is only $1.24 So the overall transaction or contract file is cheaper but it's interesting how these variables move 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'd get your box your game, you'd get your four disquets your mom would install it all day and then you'd play it over and over, you'd play it as much as you want. Now games are they often have microtransactions it's no longer a flat cost. So a game like Cowflicker you've got to keep clicking on that cow and maybe you pay to turn that cow into a beef later but it's no longer a flat price you know some people like that in games some people don't It can work well in cryptocurrency though because you can pay in small chunks over time but people might run out 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 Axi Infinity solved it so there's this waiting for transactions to be mined and I think the crypto case team did a nice job having some cute animations and building suspense kind of have this ghost cat while you wait for your cat to load and that can be a little exciting like what am I going to get so it can be an opportunity Blockchain also is very at risk to security exploits FOMO 3D I mentioned before let's review the rule so when the timer ends the last player will win the pool and anyone could join the pool and extend the game by 2 minutes however this team at SecBit wrote this really awesome article and they figured out how to exploit the whole Ethereum 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 if you read more of SecBit's article if you're interested it's very interesting another consideration is how decentralized are our games Ethereum wasn't made to support high fidelity data like images or large objects that's not what it's 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 cash data where you've 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 is it for another party to come and recreate the game one example I think the Kitty Hatch project looked 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 of the circumstances but it's not really playable so this is not a game but this is an art project that I think does a really good job of putting a lot of the data on chain it's Auto Blast by a group called Larva Labs and these are ERC721 collectibles and these patterns are generated through a smart contract and it's not too hard for someone to build the image clearly the image is not stored on the smart 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 Ethereum is public so who has played Dungeons & Dragons before I love that game it's a lot of Dungeons & Dragons you'd want to think about information hiding so we have this character here and he's got the Game Master screen and he's you know if you're a Game Master you're often hiding information from people that's slowly revealing it to build a story to drive an area and maybe create some dramatic tension so you might want that in your game you know contract calls are public and people can read those people can go and read events and see the data in there even your ID is a pseudonym it's not truly anonymous so you just might consider that even games aren't real okay 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 we'll use some of the ideas that we thought about Solidity and we're going to take those and make our own games so for our purposes we're going to think about three characteristics of games so we already talked a lot about features of Solidity that might be incorporated in games and I want to dive into the detail on what the other two card categories are so we're going to do a little bit of a card game it's going to be kind of like apples to apples or cards against humanity okay so game categories what type of game are we playing I'm going to name a couple that might not be common knowledge just in case you draw the card so you know what it is so one category of game is called a god game and this is not in any specific religious sense this is more that you're an omnipresent entity that can control a world so in SimCity you have this sky view you know of this world and you can build things and you know decide how your citizens work and create these things rollercoaster tycoon it's just focused on the theme park and building rollercoasters one of my favorite games SimAnt from 1991 has anyone played it so good but you're basically an ant you manage an ant colony and you can become an ant you can become the queen and you're fighting for control of the backyard against rival ants and humans and lawn mowers another category of game that you probably will see in Osaka is a gachapon and this is a castle dispenser it dispenses a toy, it has a little bit of randomness because there's usually six different types of toys and there's even a bitcoin one I saw you can pay 300 yen to get a plastic bitcoin see if you can find it this one has the da da da dashi chainsaw and drill some like kuni oshige cats it's a famous artist in japan they're really fun and interesting but it's just a bit of random toy dispenser okay let's talk about theme or setting this type of card theme or setting is critical to a game and a lot of stories can be told without even any human presence so I think all my favorite games are from the early 90's my other this is probably my very favorite computer game but it's mist, does anyone play mist yeah there's a level channel one there's no people in it it's just this abandoned place and 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 theme and setting is very important we can draw inspiration from the world around us Osaka has lots of fun neon and giant giant puffer fish and things to see there's the world of Japanese mythology kunyoshi prints and boys fighting fish and samurai writing toads it's pretty surreal okay so I'm going to go through a couple examples of how the games played so we're going to have different types of cards and there's different colors and there's symbols on them too if the colors are hard to see the green stars in the game category we're going to draw two of those and discard one blue cards have a moon on them we're going to draw three and discard one so you have two cards left and so little features you're going to draw two and discard one a hand like this and you decide to pick your favorite okay I'm going to choose a racing game the theme is that it's post apocalyptic and it's about ducks and I'm using the burning function so I'm sending things to the zero address so maybe I make a game called perhaps to the pond warrior and you know it's some hostile world where ducks have to fight for survival or get sent to zero apps another example here let's take a role playing game and we picked trains and Japanese mascots and we're using layering of smart contacts so perhaps I decide to use BRC721 collectibles and layer them together to build a Japanese rail network featuring cute mascots and wonderful trains and try to entice people to come ride my railway okay 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 to hand out decks and cards alright and see it seems like we've come up with some really awesome ideas and there's actually another part of this talk this is sort of a salinity workshop so this has been awesome and thanks for making these great ideas some of the things I learned were like a yak princess bedding arena and a happy bar racing where the losers character is burned so there's some really wonderful ideas and you can feel free to take your cards or play more 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 a game in salinity together and maybe you can take some of those ideas and yeah this one is really cool I mean some sort of fairy tale with cursed clothing objects and treasured tons of it's like this is like D&D level so yeah we'll save this one because this game needs to happen so if that's where we'll let stuff maybe pull out our laptops and move into the next part and hopefully hopefully we can play okay great a question, raise your hand and we'll do our best to keep everyone together thank you so much thank you thank you so much for spending time the stamp rally is what we're building so the stamp rally is a game made in companies and so this one is a game that I completed you go around to every train station on the Yamanote said in Tokyo and you get a stamp and when you get all the stamps in addition to the satisfaction of spending three hours of your life doing a lot of this you get a memorandum folder that memorands the new era of Japan and the railways so it's kind of a fun game to train around and connect with the trains this is a thousand year old tradition when you go to Shinto Shrine and do these symbols you can get these really beautiful stamps it's about 300 yen per page to get this written and well this stamp is actually a holy object and something that should be sacred and not mixed with this type of stamp this is thought to be one of the origins of this modern game so because I wanted to make my co-workers laugh and do something fun I thought it would be really fun to build a stamp rally on the blockchain where instead of visiting a physical address you would enter a past race or you know in a virtual world you could enter some like gym work and you could use your ethereum address as your player ID and then if you collect all stamps you could 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 there's a button where you can click to collect the stamp and if you enter the past race correctly we will load the picture so first let's make sure that we all have some ethereum so does anyone not have testnet rick v testnet ethereum does anyone 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 metamask so yeah we'll go through this for those of you who have been doing this a long time please be patient or maybe you can help out your neighbor but you'll want to go to metamask.io and download let's see download this tool I'm on slide 8.1 by the way are people able to access the slides with laptops okay great you're welcome to keep holding it Jeff you look great but you can also probably send it down to me thanks so much so yeah we want to install the metamask metamask 2 and so we'll follow along on the slide so again food doesn't have metamask installed people with laptops okay so yeah so good people are I'm gonna move ahead but if you can follow along on the slide I'll tell you which slide I'm on so hopefully people can catch up yeah and make sure to use zeros not the letter O in the link so that you can get the slide that should both be zeros so I'm gonna briefly go through metamask and how that's set up so this basically is a tool that lets us interact with the Ethereum blockchain so we'll want to install it it's metamask.io and I'm on slide 8.1 so if you're new to metamask you'll be like yes let's get set up to create a wallet if you want to see the phrase probably you've used it before but it's easiest to just click yes let's get set up and there's a point to set a secret backup phrase and this is a really important step but for the purpose of getting through this workshop we're gonna return to this later where you might use your account forever so it's important there's a link on this slide it's slide 8.3 but it's really important to use your backup phrase you know in a centralized ecosystem you can call your bank I forgot my passport that doesn't exist I forgot my password it doesn't exist here okay and if you have a fresh account it should look like this okay so the next step would be to get some ranking test networking and can anyone tell me what the difference between the test network and the mainnet is there's no value there's so many things yeah I guess there's a lot of things to say whether it's a different algorithm or things but one of the purposes is you know it just gives us a way to try things out before making our team line so that's the really short version because I'm sure there's a lot more depth there and use a faucet if you have a twitter or facebook account if you don't have one of those ask your neighbor to send you some we're going to go on the rink of the testnet that's one of the testnets up there and so this link here at faucet.ringfee.io they're public and the tutorials on github too so sorry about the wifi but it is possible to sort of follow along this material after so I'm going to keep proceeding how you get rink of the test ether here easy to click in that pass on the little box and make sure you're on the rink of the network you can select that at the top and click on the account to copy the address so slide 87 here shows how to copy that and then you log into twitter or facebook and you would make a post with your address 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 how it works better on twitter and then you paste it into that faucet and you select give me ether and choose how much ether you want and you know in a little while we'll get mined to the blockchain and you'll see your ether I think three is probably good okay one's sufficient don't need much but yeah if you already have some rink of the ether you're good so any questions on this stuff so far alright okay next let's talk about remix so remix is an in browser editor for solidity who's used remix before most people it's changed a little bit in 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 it has 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 it will load the compiler and the deployment modules and the file editor so you have all the tools you need so if you go to the dev we have let's see it's remix.etherium.org and I'm on slide 94 if you're following along with the dev okay so we're going to create a new file we're going to call it stamprally.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 so you make a new file and you can give it the name sol is for solidity and then let's get into the code so there's a on slide 98 there's a link to a gist that has some of the code here let me just show you what that looks like there's some gist code that you can copy and paste into your solidity editor here and let me make this a little bit bigger so I have that and I've copied it into I think this I've copied it into my solidity editor with me I'm still fighting the internet I'm so sorry this might just be a demo unless interactive you don't have a twitter can you I can send you some Ty here will send you some who's address awesome if there's a qr that you can scan or if there's a qr on telegram or something so basically over here I'm just going to talk a little bit about as much as I hope people deal with the internet so we have our music solidity versus live and we've got our stamp rally contract and it has a couple different variables that are set in the constructor so we'll have the number of stamps in the game it's how many spots there are to collect so we're not going to do 30 it's not a marathon we're going to have a name for our stamp rally and we're going to have an 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 put it through a one-way function so that it's masked like what is it and then we'll have a URL that blows the image of the stamp and we prompt that might give us a little hint to what that's doing and then we have an array that's internal of all these keys so it'll be of the size of all the hash passphrases for the story-spending so the first step we'll be doing is adding the constructor and that's more of just copy it in from the disk but it's a good exercise in actually making sure that your remix in Kyler works so if you go to the gist back here and I'm sorry get a full screen go to section one of the gist of the constructor and we'll copy that in copy that into remix paste it under the to-do here we can see that our constructor is taking some grounders like the unsigned integer of 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 next, if we click the second icon which is sort of the solidity icon it's like these two chevrons we'll want to make sure that auto-pumpile is selected and this was really important because when you make changes to the code it will keep compiling it after we've selected auto-pumpile I'm on slide 100 by the way then we'll move towards the third icon from the top which is the Ethereum logo with a little arrow coming out of the side and this lets us deploy and run transactions so we'll click on our stamp rally which should be compiled and then we 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 rally and then once we've deployed it we should see this gray bar here and we can do the drop down and we should be able to see the name the number of stamps and our address is the owner so do you want to be able to get there catching up okay should I go back a few slides? it seems like people are still just getting the code pasted with let's go back to just pasting in the stamp rally copy it from the disk and paste it into Solidity and then make sure we have auto-compiler our auto-compiler let me show here what it looks like and I've pasted it in the constructor from here I've taken that and pasted it in where it says 2-1 add constructor and this is sort of just the hello world of getting my auto-compiler checked and I can 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 and I have to click yeah cool, so yeah, people getting the constructor constructor in there okay so yeah any questions on that so far? and we're going to talk about function modifiers so here's an example of a function modifier it's a pretty common one basically function modifiers are syntactic sugar that lets check some free conditions on a function or change the way the function behaves so this one is called only owner and it means that only the owner can call a smart contract basically here we're going to have a require statement and look at message.sender it's a special reserve word or reserve sequence in 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 who is changing the stamps should be only the 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 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 of two ways of doing the same thing so it's your turn now we want to write a modifier and it's going to be called valid position it's going to take a unit 8 of underscore position and we want to check that the position in the stamp is greater than or equal to 0 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 you can copy this here and I would recommend looking at only owner as a reference so we'll paste that in another to do too and you might get a little red and I'll pop up that you're the compiler is angry and I'll let you figure out how to make it happy again so I'll give you about 5 minutes to work on that feel free to work together if you're having trouble with your internet and I'll come around does anyone want to see another answer? yeah yeah so the function body is just like require, run, run, delete expression, position greater than or equal to 0 and the position less than 10 yeah great number of stamps I made mine a little simpler because it's an unsigned in so it's totally fine to compare to 0 it's also equivalent that unsigned ins cannot be negative so it can be like this but both are valid solutions so feel free to copy this in I know we've got this part running cool a little bit about storage and memory so in Solidity we've seen just talked about unsigned ins the simple types, the more complex types such as strings or structs need to be stored differently and we need to tell the compiler a little guideline about how we store things so storage is a keyword that can be used for things that are persistent and this is great but it's more expensive to store in the blockchain than to be put into this permanent record and hosted on other huge computers so very important for state variables anything local to the contract state memory is for things that are not persistent for just local computations or temporary variables if you're moving data around so here's an example where we are storing a stamp key and we can use the storage keyword the permanent variable and assign that stamp key to a permanent variable on the blockchain versus in memory where we have a temporary variable and just that keyword is all that you need so if we go to code to store the player's cards on the blockchain we'll copy some of this here from the gist we've got the rally card which is a struct with a number of stamps then we're going to store all the cards in the game then we have something that links to a rally card and this lookup table between the player and it it might be easiest to just kind of copy the code from the gist we're going to have this function here that kind of dealt with some of the code on the other slide and oh actually this is an example I wanted to show of where the user had a stamp and because this is just a check of data that's already on the blockchain when we retrieve the user card we can use the memory keyword because we don't need to store it again we're just looking it up and returning some of that data to the user returning yeah the boolean value of whether or not they have the stamp and so a memory example would be if the user has the stamp and we're trying to get the stamp image if they have the stamp then we're going to also using memory here returning the URL it's just making a temporary copy in a center function though it needs a persistent thing so this one will copy and I'll let you fill in the blank on this code how do we assign the stamp key in the question marks here do we use storage or do we use memory and so yeah your exercise will be right in the center so let me go to the gist here and we'll copy this section three here code to store player's cards a bit of code here but we'll copy it into remix and you'll see the two write me 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 does anyone have an answer or is it close remember your storage storage storage why right because we want to persist that the user is collecting the stamp so we'll use storage and then we do an assignment here where we assign 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 this time so let me skip ahead a little bit I'm going to just jump into if you like this or want to keep playing with it it's on github you can make a pull request you can follow along it's a work in progress let's talk a little bit about web3 so web3.js is one of the libraries available for connecting connecting to the ethereum blockchain so we'll put some javascript on pictures on the front of your smart contract and so we'll be using metamask to sign transactions so if you could go to and-kilzer.github.io slash blockchain-stamp rally I'm on slide 125 and there's a link then we can actually see it in action here here it is again so people will load that up and have your metamask while it's ready look like this you might need to make sure that it's connected and click on metamask 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 I have it and then just click the stamp the password is octopus all lowercase and then you click submit you should get a pop-up to sign the transaction click confirm and yeah make sure you're on repeat and you'll have to wait a moment and it should load the stamp it takes a little while if you mind let me end the deployed contract it's in the slides actually I think I've leaked to it on ether scan if you want to you can see that people are calling the contract and we've got some events here collect stamp stamp collected a couple in-mail and passphrases make sure it's on octopus all lowercase oh okay I'm not really sure what happened to the password here maybe I broke it or something but try to get the bug try to get the mallet bug BUG couple on ones that I can tell you this one's the Toyota make your own artwork if you want to share it it's on github yeah is anyone having trouble getting the stamps to submit submit it confirms it confirms that there is an issue with the job yes it usually takes about a minute but yeah try the bug in the mallet I think something broke with the octopus yeah so we've got my book in the chat but I don't know oh okay I don't know alright didn't confirm it well with the rest of the time I guess I'd like to just say in general that blockchain has a lot of we talked about creative constraints we did an aviation activity we did an exercise in building some things in solidity and so we covered a lot of ground and the sort of unifying theme is that I think there's a lot of potential for creativity here even though these tools are very new and novel and sometimes always changing and so I hope you enjoyed it and yeah if you have any questions email me at Ann at CurveGrid.com or you know ask questions now thanks for attending