<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by BeautifoolData on Medium]]></title>
        <description><![CDATA[Stories by BeautifoolData on Medium]]></description>
        <link>https://medium.com/@beautifooldata?source=rss-a951333666b1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0xW8_YxV4iMfwOkl-dL8WQ.png</url>
            <title>Stories by BeautifoolData on Medium</title>
            <link>https://medium.com/@beautifooldata?source=rss-a951333666b1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 07:45:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@beautifooldata/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Build a Minimum Viable Generative Art NFT Pipeline]]></title>
            <link>https://python.plainenglish.io/a-minimum-viable-generative-art-nft-pipeline-that-you-can-build-proof-of-concept-for-a-platform-292a12f433ef?source=rss-a951333666b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/292a12f433ef</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[generative-art]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[BeautifoolData]]></dc:creator>
            <pubDate>Mon, 06 Dec 2021 20:16:05 GMT</pubDate>
            <atom:updated>2021-12-16T10:59:49.176Z</atom:updated>
            <content:encoded><![CDATA[<h4>The proof of concept for a Platform — A step-by-step guide to creating a generative art NFT pipeline.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0EUlzfmJBG40RtTZHU43zA.png" /></figure><h3><strong><em>Get up to speed</em></strong></h3><p>Here’s a great article on Medium if you have the time, a <a href="https://medium.com/coinmonks/nfts-101-why-nfts-are-a-generational-innovation-4626ae803e3b">111-minute read on what an NFT is</a>. Check out Wikipedia for a primer on <a href="https://en.wikipedia.org/wiki/Generative_art">generative art</a>.<br>For the sake of this article, I’ll assume you know a bit about NFTs, and you are thinking about making your own. We can say they are unique digital objects that represent proof of ownership of something. Generative art is art created by some amount of autonomous process.</p><p>NFTs are a great way to assign ownership to algorithmic art output.</p><h3>Current g<strong><em>enerative art platforms, and why you should build your own</em></strong></h3><p>Here are 4 platforms that are set to dominate the generative art space:</p><blockquote><a href="https://artblocks.io/">ArtBlocks</a> — the number one platform for artists to create on-demand generative content stored on Ethereum<br><a href="https://www.doodlelabs.io/">DoodleLabs</a> — onboarding brands and real world artists, bridging the gap between the physical world and the NFT space<br><a href="https://www.fxhash.xyz/">fx(hash)</a> — an open platform to create generative NFTs on tezos<br><a href="https://gen.art/">gen.art</a> — membership based monthly art drops operating as a quasi-DAO with a central governance token</blockquote><p>If you are an up-and-coming artist without a large following, it can be hard to get on to these popular, established platforms. At one point, ArtBlocks had months of artists on the backlog. They’ve closed their application process at the moment, so you will not be able to qualify for a Factory drop any time soon. Once you launch your platform, you release it on your schedule.</p><p>Another perk of doing it yourself is that you have full control over the details. You will be the featured artist at any point. I decided to set up free reserved mints tied to each of 420 <a href="https://www.fopunks.com/">FourierPunks</a>, a previous collection of mine. When you have control over the platform, you can get creative with distribution!</p><h3><strong><em>On to the details, what did I try?</em></strong></h3><p>Below is an overview of the steps I took to create this pipeline, usable at <a href="https://genvibes.io/">https://genvibes.io</a> while mints remain. I won’t claim that everything below is the right way to do things, but I’ve found that it works. I would love to hear feedback in the comments or on <a href="https://twitter.com/BeautifoolData">Twitter</a> if you have any suggestions or questions!</p><p><strong><em>Step 1. Write your generative art code in a scripting language of choice</em></strong></p><p>I’ve seen a lot of great output from generative artists on <a href="https://twitter.com/search?q=p5js&amp;src=typed_query&amp;f=image">Twitter</a> using p5js, so that is what I used for this project. In theory, you can use whatever scripting language you like. I’d say, the fewer dependencies, the better. Also, it would be optimal to produce the smallest size script possible in bytes. The reason being the script will end up in your contract, ideally.</p><p>So, write an awesome art creation script that relies on randomness bound by the same rules and produces varying but unified outputs, where each is beautiful and unique.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MoGHmabMUcSVaVVJFNVPFg.png" /><figcaption>ERC721 Wizard from OpenZepplin</figcaption></figure><p><strong><em>Step 2. Create your solidity contract</em></strong></p><p>The contract is what ties together all the important aspects of ownership and provenance via a token. For most projects, I fire up the online <a href="https://remix.ethereum.org/">Remix</a> IDE and bootstrap a contract using the <a href="https://docs.openzeppelin.com/contracts/4.x/wizard">OpenZepplin wizard</a> for ERC721 contract libraries.</p><p>There are a few functions that I added at this point to prepare for the pipeline. I’ll use snippets from the <a href="https://etherscan.io/address/0xaAFEf5aF4906FC7901aAFfC82dDB9dB45f3983Ed">Generative Vibes contract</a> as examples. We’ll start with the mint function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*uz7ae1e1pJYOtArwvXgl6Q.png" /></figure><p>This mint function requires payment and limits the total number of mints. It keeps track of the token ID using the OpenZepplin Counter object. For many other NFT projects, the token ID would increment and get sent to the minter. But for this pipeline, I wanted to include a mapping of token ID to a random hash generated upon mint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*jLdtXLtIAsWWgGAM3mk4Zw.png" /><figcaption>Generate the seed for randomness</figcaption></figure><p>The code for the random number generation uses the 20 rightmost digits of the keccak256 hash of attributes about the block, the token id, and the minter. This value is used to seed the code from step 1 and determines the art output received. Make sure to test your seeds! I noticed that p5js started creating similar output when seeds were close to each other, or when they exceeded a certain value. Test your seeds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*onMQWL2VFNqDGyclH-viNA.png" /><figcaption>Stored values to make this more on-chain</figcaption></figure><p>A few state variables are used to get this to a higher level of on-chainyness.</p><ul><li>tokenHash maps tokenId to its random number</li><li>p5jsversion stores the version of the script’s only dependency</li><li>generationCodeHash is the keccak256 hash of the JavaScript code</li><li>_baseURIextended is the metadata endpoint</li><li>generationCode is a mapping of an index to a string, intended to store the generation in chunks on the contract</li></ul><p>The goal is to set up the contract to have a final state where the contents of the contract alone can recreate the art. I recommended fewer dependencies earlier because they’re more costly to get on chain. The minified version of p5js is nearly 800kb and that would amount to about 512,000,000 gas. Given current gas costs, it could be more than 50 ETH. In the community, it seems like p5js is generally accepted as ‘obtainable from many sources and is unlikely to get lost’, so storing the version number should be sufficient for a very long time.</p><p>As stated, it’s pricey to store things on chain. So when deploying the contract, generationCode was included as a destination for the pieces of code. If someone wants to pull down the code, there is a get method to retrieve the strings by index. The script’s hash was hardcoded in during deployment for a later proof of “this is the code used to create your artworks.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*O7bRJex4ckqeOL8EhJJ0Ig.png" /><figcaption>Reward supporters with free mints</figcaption></figure><p>The last few functions I decided to include allowed me to reward owners of a previous project. There is a separate mint function that allows a user to submit a FourierPunk ID, and if they verifiably own that token, their mint is free. I thought this would be a fun way to reward supporters from my previous project.</p><p><strong><em>Step 3. Create your minting website</em></strong></p><p>Given how savvy people are getting, you may not need one of these! A Twitter presence or Discord with clear instructions on how to mint from the <a href="https://etherscan.io/address/0xaAFEf5aF4906FC7901aAFfC82dDB9dB45f3983Ed#writeContract">contract on Etherscan</a> could suffice.</p><p>But, here’s what I used: simple HTML, CSS, and vanilla JavaScript. Three buttons for minting, and a few links to socials. I used the <a href="https://docs.ethers.io/v5/">ethers.js</a> library to interact with all things web3 — minting, checking for ownership, getting some counts, and listening for events. The site also has a <a href="https://api.genvibes.io/token?id=0">metadata API</a> that returns an <a href="https://docs.opensea.io/docs/metadata-standards">OpenSea friendly</a> JSON.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*XdddJ49UIGwsNJ3h7O_64A.png" /></figure><p>If a user comes to the site and they own some Generative Vibes, their token IDs will show at the bottom of the page. These links head to a view.html page which passes the ID as a parameter in the URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*ChHSY4pIOYZKL9ShKC2kTw.png" /><figcaption>view.html renders the art using the minted token’s generated random number</figcaption></figure><p>The view page is what runs the JavaScript on the client-side. The page first imports our specific version of p5js from a CDN then injects the art generation script. The additional in-line JavaScript retrieves the seed from our API. This was a spot where I was mulling over what to do. I could have used web3 to call the contract and get the random number directly. To make the pipeline easier, I decided on the REST call rather than the web3 reliance.</p><p><strong><em>Step 4. Get your pipeline in place</em></strong></p><p>While I was conceptualizing this project, everything up to this point was pretty clear. I had been tinkering around in p5js finding ways to make pleasing outputs, and I already had an understanding of what the contract and website would be like because of experience in past projects. The questions that kept coming up for me were, “How do I go from mint to hosted image that script generated? What kind of infrastructure do I need? How do I make it resilient and speedy? Is there a risk of the code rendering differently based on different environments? Do I need to sit myself down and learn Kubernetes/Docker and host this? What is this all going to cost?”</p><p>Analysis paralysis. Until. 🎇💡 🎇 “<em>Just do it all locally.</em>” A simple solution, maybe foolish? Didn’t matter, got me moving again. So I got myself in front of my favorite IDE, Jupyter, and commented in a pipeline. The path became clearer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*wU01Gd_ZleCPqoyGNrj6-w.png" /><figcaption>At this volume, there’s no issue doing this from my own machine 💡</figcaption></figure><p>Here comes the pipeline code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ICmitjwS9WhyY_4Ce3ag0g.png" /><figcaption>Pipeline #1 — web3</figcaption></figure><p>First, check the total supply of the contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VyW5skJlyz-Q7ydOPed-yA.png" /><figcaption>Pipeline #2 — the metadata check</figcaption></figure><p>Second, iterate through each token and check if they have metadata associated. If not, add the token ID to a queue. For this pipeline, missing metadata means that the token is newly minted and the art is not rendered and hosted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-k03hLOIoT1NHyDg_UeA3g.png" /><figcaption>Pipeline #3a — supporting functions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wpxh3_KjJIQ_3fqkF52uFw.png" /><figcaption>Pipeline #3b — supporting function</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*maR--Ff9Ze4SJISqjTmdfw.png" /><figcaption>Pipeline final — the listening loop</figcaption></figure><p>The way this is coded — horrendous. Mid code imports, redundancies, sub-par optimizations. 😱 But does it work? So far, yes. Moving past that…</p><p>Starting with the last image, we can see that the queue we built up in the previous step is now iterated through. Each token id is passed into the pipeline function. The first portion of metadata is pushed to an AWS DynamoDB to feed the API. At this point, when you go to <a href="https://api.genvibes.io/token?id=0">https://api.genvibes.io/token?id=</a>{tid} , you will get a token ID and its random number back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/1*qf5KQ4UcGef5mw0vXPX6hw.png" /><figcaption>Metadata from the generated p5js art</figcaption></figure><p>The next part saves the png and the attributes of that token’s art. I had things working well, so I didn’t want to make many more script changes. For this part, I used Selenium to fire up a browser and load the token’s art which simulates when someone navigates to it. The metadata values are returned from a function in the p5js script, which is placed in a &lt;div&gt; that can be scraped by BeautifulSoup. The image is saved to my desktop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FzCjlT2pHAJMXcZW5aLsFg.png" /><figcaption>OpenSea friendly metadata</figcaption></figure><p>openseaify() then constructs the metadata in a way that fits the OpenSea metadata standards. Everything is ready except the image, which needs to be hosted somewhere. I use some endpoints from the <a href="https://www.pinata.cloud/">Pinata</a> pinning service to upload the saved png to IPFS. This returns the IPFS hash which can be stored in the JSON and is usable by OpenSea. Once the metadata is finalized, we update the record in DynamoDB.</p><p><strong><em>Step 5. Run it!</em></strong></p><p>With all the components created, put everything where they need to go! Here is a review of the architecture that I used:</p><p>✅ AWS Amplify for website<br>✅ AWS DynamoDB for metadata storage<br>✅ AWS API Gateway for the REST endpoint<br>✅ Dedicated machine for rendering pipeline</p><p>Then it is off to Twitter and Discord to promote 👈 (<em>the hard part</em>)</p><h3><strong><em>Room for improvement</em></strong></h3><p>There’s a glaring fault with my current setup. The rendering pipeline needs to keep running until the project mint is finished. At this point, there have been about 20 mints in a few days, and with a cap of over 1000 max supply, it looks like it could be a while. I will be looking into getting the pipeline onto a cloud server.</p><p>The next issue is the time it would take to render a large queue. Luckily, this script creates its output in a few seconds. Even if the remaining tokens get minted in the next block, it would complete in a few hours. Not a terrible spot to be in. If I were trying to improve this, I would look into a proper queuing technology like Kafka, and allow this to scale wide. There&#39;s nothing in the process right now that would restrict that.</p><p>Finally, as a variation, I’ve seen other platforms spawn multiple projects from the same contract using patterned token IDs, whereas my example here is for a single collection. I haven’t thought about the pros and cons of doing such a thing.</p><p>If you can think through those issues above and put together some good art, you have a pretty proper platform! That’s all I have for you from this project. Did you find any parts useful? Any suggestions on how to do things better? Let me know!</p><blockquote><strong><em>If you enjoyed this article, please reach out on </em></strong><a href="https://twitter.com/BeautifoolData"><strong><em>Twitter</em></strong></a><strong><em> and check out </em></strong><a href="https://genvibes.io/"><strong><em>Generative Vibes</em></strong></a></blockquote><p>Please enjoy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*lAy7vTcU5Sbm0sSXVpRTRA.gif" /><figcaption>Generative Vibes minted so far…</figcaption></figure><p><em>More content at </em><a href="http://plainenglish.io/"><em>plainenglish.io</em></a><em>. Sign up for our </em><a href="http://newsletter.plainenglish.io/"><em>free weekly newsletter here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=292a12f433ef" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/a-minimum-viable-generative-art-nft-pipeline-that-you-can-build-proof-of-concept-for-a-platform-292a12f433ef">Build a Minimum Viable Generative Art NFT Pipeline</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Contract development of Buddy Buddy Tags — fun, completely on-chain, generative NFTs for…]]></title>
            <link>https://medium.com/@beautifooldata/contract-development-of-buddy-buddy-tags-fun-completely-on-chain-generative-nfts-for-be9766bb680d?source=rss-a951333666b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/be9766bb680d</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[BeautifoolData]]></dc:creator>
            <pubDate>Sat, 25 Sep 2021 15:27:14 GMT</pubDate>
            <atom:updated>2023-01-30T15:10:51.111Z</atom:updated>
            <content:encoded><![CDATA[<h3>Develop fully on-chain, generative Ethereum NFTs using Solidity: Buddy Buddy Tags🤝</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wfjGmDIpJBf2gSZAeMAECQ.png" /><figcaption>view all buddy buddy tags on <a href="https://opensea.io/collection/buddybuddytags">opensea</a></figcaption></figure><p><a href="https://www.buddybuddytag.com/">buddy buddy tag</a> NFTs are a brand new project put together to experiment with completely on-chain generative development. you get one for yourself, for your friend, forever😹. as of this point, there are 13 minted tags, with 7 of them confirmed!</p><p>what does that mean? well, buddy buddy tags are on-chain, generative NFTs that require a minter to submit a buddy’s address when minting. the minter receives a randomized set of emojis along with his wallet address and his buddies. think of it like a fortune cookie, you don’t know what you’ll draw, and the interpretation is up to the minter and his buddy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hCoVp43Twp4IUYp8ELrFVA.png" /><figcaption>buddy buddy tag #2 — 0xd9e3… tagged 0x89d6…(BeautifoolData, i set up an alias!) and received this NFT immediately.</figcaption></figure><p>if the buddy heads to the <a href="https://www.buddybuddytag.com/mint.html">website</a> and confirms the tag using the token id, the NFT gets snazzed up with a colorful border. as a bonus, by confirming the tagged buddy gets added to the allow list and can then tag their own set of buddies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QQE3xAGztD7LqhqHpz7yGA.png" /><figcaption>once a tag is confirmed, the colorful border is added and the tagged user is added to the allow list for minting</figcaption></figure><p>this article will be a review of the creation of <a href="https://etherscan.io/address/0xC321Aa2Cb7a0336aa829eA153B4eA422F5d806c4#code">0xC321Aa2Cb7a0336aa829eA153B4eA422F5d806c4</a>, the buddy buddy tags contract.</p><p>i hope that newer ethereum contract devs find this useful. experienced solidity writers may <strong>not </strong>find this interesting, but i would love to hear any feedback or suggestions!</p><p>as you could guess, this is a <a href="https://etherscan.io/address/0xff9c1b15b16263c61d017ee9f65c50e4ae0113d7">loot</a> derivative with special features, so the contract framework starts there. for a great write-up on loot, check out the <a href="https://medium.com/u/98fd895a20f8">Phemex</a> <a href="https://medium.com/@phemex.com/how-loot-is-revolutionizing-nfts-dee2f2aa8830">medium post</a>. on line 1314 we have the start of the meat of the contract. everything before this is boilerplate erc721 contract stuff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/0*UvMpnlH02l8ObcsU.png" /></figure><p>here are the variables and purposes:</p><p>launched — prevent anyone from interacting before i am ready <br>emoji_list — the list of emojis that will be randomly pulled for the NFT<br>allow_list — addresses that can mint <br>buddy_tagged — addresses tagged by token ids aliases — pretty strings for addresses <br>alias_unique — check to see if string is taken <br>confirmations — address to address confirmation check <br>CONSTANT values are self explanatory</p><p>first, i wanted to enforce an allow list. this was done in the can_addr_mint function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/0*hD9B-5Uol9r6erYg.png" /></figure><p>it checks an inputted address against three lists — the contracts internal allow_list, the owners of acclimated <a href="https://opensea.io/collection/acclimatedmooncats">mooncats</a>, and the owners of <a href="https://opensea.io/collection/fourierpunks">fourierpunks</a>. simple! <em>(if you want to mint but are not on the allow list, reach out to me on </em><a href="https://twitter.com/BeautifoolData"><em>twitter</em></a><em> and tell me you’ve read this section. i’ll tag you as a buddy, and when you confirm you’ll be able to mint)</em></p><p>next, i needed a mint function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/0*QUXWvop6XmCbxDoS.png" /></figure><p>to make it slightly more interesting than the typical click-and-mints, i wanted a way to enforce some social aspect. so, the minting function requires someone else’s address as input! the first few requires make some standard checks.</p><ol><li>contract must be launched</li><li>you can’t tag yourself</li><li>you have to pay the right amount of eth</li><li>theres a supply limit to tags</li><li>you must be allowed to mint</li></ol><p>once those conditions are met, the usual _safeMint is called, and the buddy_tagged data is updated</p><p>so what does a mint do? it creates an NFT and transfers it to you, the minter. but what does that NFT look like? thats what i needed to deal with next. thanks to loot, i had a good base for a way to make something thats completely on chain. the display of the token comes from the tokenURI function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*arcTVxqCRrvF-8P9.png" /></figure><p>this function overall will be hefty to explain because there are some functions in here that were created while tuning the output. i’ll try to give a brief overview of everything in here first, then go into more detail of those later.</p><p>first, if the token is not minted as checked by the totalSupply, it returns an error. an easy way to prevent lazy contract URI sniffing.</p><p>the parts string contains segments of the svg. these are concatenated at the end. harmony is randomly drawn for the type of color palette, and four colors are drawn. then the 17 segments of the SVG are built out. the SVG is two squares atop each other, the one behind has a pattern activated once confirmed, giving the colorful border. this is the check for segment [9]. the current NFT owner always shows at the top of it, as shown in [11]. the randomly drawn emojis appear in [13]. the tagged buddy is filled in at [15].</p><p>concatenation of all the string parts happens by a few abi.encodePackeds. then this is base64 encoded, and put into a metadata json object which is also base64 encoded. genius! had no idea opensea would be able to natively read this. note that in this space, you can write more data that you can make conform to the opensea metadata standards and have that show as attributes in their UI.</p><p>ok, now to fill the detail in some of those functions. lets go in order</p><p>getHarmony, getColor, and getTokenColor work together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KLH23kuGXxJOK1I-.png" /></figure><p>the first really just pulls a random number 0–4. as you can see, those determine the relation between the colors that will be drawn. i took some very basic color wheel relations — complementary, monochrome, analagous, triadic, tetradic. these are easily incorporated into SVGs since they can be set with HSL(). getTokenColor is used to get the initial HSL values, and the other colors are relative to that.</p><p>getAlias makes a quick check into the contract data to see if the address has saved value. if not, it shows the 0x address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/0*K8jxxH2Mq5uQ4HYO.png" /></figure><p>really quick, the aliases are set through a payable function set_alias</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-PmNH8fHg3gw6BCN.png" /></figure><p>makes a few standard checks as we’ve seen so far, as well as tests for validity and uniqueness.</p><p>back to the functions from before, getEmojis is the function that randomly draws the 1/2/3 emojis for the NFT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JU6wg78bj9IktwFF.png" /></figure><p>random numbers are all over the place here. so, emojis. they’re unicode characters. theres a large list of them on the unicode website. the more space you use on a contract, the most gas it costs to launch. for this reason, i launched with an empty emoji_list and updated the values via transactions later. in order to save a bit of gas, i only used emojis that fell in to the format “&amp;#Fxxx” where xxx is three letters or numbers. this way, i could upload a long string made of concatenated 3-char emoji codings. so that’s what happens in pullEmoji. we pull a random number, mod it by the emoji_list string divided by 3 to get the Nth emoji. then we look back in the string to get the three characters. it works, probably could be better, but i was happy with it.</p><p>the rest of getEmojis is the rarity. 1 / 200 times you get a single emoji. 4 / 200 times you get a double emoji. emojis also pull with replacement, so it should be possible to get a triplet, but i doubt it. its also possible that clones will come out. we’ll see.</p><p>how was the emoji list updated?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/0*Jn-DokTKT_JW1b5o.png" /></figure><p>add_e! before the contract launched, i left a function to update the string. if i messed up, i left something to clear out the list. luckily, i didn’t have to use reset_e. i attribute that to “good, non-automated methodical testing”.</p><p>everything up to here had be done before launch. what happens when we launch?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/0*m5yfLFdemKw4Ho55.png" /></figure><p>it flips the boolean and sets the LAUNCH_BLOCK.</p><p>at this point i realize i’ve been referencing a random function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/0*-xLkTEExc3cEuhES.png" /></figure><p>it concatenates a string and the LAUNCH_BLOCK, hashes it, and casts it as a numeric. it was important to me to have this LAUNCH_BLOCK as an extra source of randomness so that i couldn’t know what emojis/colors would come out.</p><p>oof, i also forgot to mention confirmations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/0*j3cd7RNulowQxK7e.png" /></figure><p>to “prove” the minter is a buddy of the person they tagged, i added this. it makes sure that the caller is indeed tagged in the token they pass. if so, it will update the confirmations mappings. as incentive to confirm, i also add the confirmer to the allow list. now they can mint! how fun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/0*XyjH7UuhKW2fb3MF.png" /></figure><p>sort_addresses was included in there to save some space. i think it saves space, you only have to store two addresses once this way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/0*u61Y4G7RsECS8r1q.png" /></figure><p>that function is used in check_if_confirmed as well. i look back at this function often since launching. i ask myself, what was i thinking. why is this internal. this would be such a useful external function. poor design decision here. fortunately, theres a way to back into whether a pair of addresses is confirmed. you can check the tokenURI data!</p><p>the final function is withdraw.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/0*R9AHN2GZyfMFtzV_.png" /></figure><p>in this contract, 25% goes to a donation, the rest goes to my wallet. im not sure why more contracts dont do this, bake it right in the contract if youre donating.</p><p>lastly, probably the most important thing of all when writing your own custom contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*yU4EXKhR_DeNrwPi.png" /></figure><p>ascii art</p><p>thats all! any questions or comments, let me know on <a href="https://twitter.com/BeautifoolData">twitter @BeautifoolData</a>! thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be9766bb680d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>