<?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[House Of Warlords - Medium]]></title>
        <description><![CDATA[On-chain properties. Ultrasound deflation. Composability tech. Tokenomics. Staking. 1000+ hand-drawn traits. - Medium]]></description>
        <link>https://medium.com/house-of-warlords?source=rss----e9bbf11d9dc9---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>House Of Warlords - Medium</title>
            <link>https://medium.com/house-of-warlords?source=rss----e9bbf11d9dc9---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 20:16:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/house-of-warlords" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[House of Warlords PFP 2.0: Loot inspired on-chain properties]]></title>
            <link>https://medium.com/house-of-warlords/house-of-warlords-pfp-2-0-loot-inspired-on-chain-properties-51c9a9280615?source=rss----e9bbf11d9dc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/51c9a9280615</guid>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[pfp]]></category>
            <category><![CDATA[tattoo-artist]]></category>
            <category><![CDATA[on-chain-data]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Optimist Pr1me]]></dc:creator>
            <pubDate>Mon, 29 Nov 2021 03:28:13 GMT</pubDate>
            <atom:updated>2021-11-29T03:28:13.229Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*OjPDKFVVhsM0DhQyvadxVQ.png" /></figure><p>First of all, I’m super proud to be part of <a href="https://houseofwarlords.com/">House of Warlords</a> team! We successfully deployed HOWL smart contract last Friday. It was truly an amazing effort by a team of innovators who genuinely wants to push the industry forward.</p><p>You can find the smart contract code <a href="https://etherscan.io/address/0x8d2071a02608f337baae8da64f93b37abd6bde39#code">here</a>. In this post and the next several posts, we will be talking about how we do things in our attempt to improve several aspects that most of today’s PFP projects are lacking.</p><h3>Improvement #1: On-chain Properties</h3><p>Why is this important? On-chain properties are probably the most important things to have on an NFT, they are what you REALLY OWN in your NFT.</p><p>Guess what? I’m willing to bet that most of your favorite NFT projects don’t even have their properties on-chain. Let’s check it out.</p><p><em>Disclaimer: This is not an attack on 0N1-Force or any other projects out there. We love you all and we just want to talk about what we think it’s important to have in an NFT project.</em></p><p>Let’s take a look <a href="https://opensea.io/assets/0x3bf2922f4520a8ba0c2efc3d2a1539678dad5e9d/717">K4M-1 #03</a> (last sold for 188 ETH to none other than <a href="https://twitter.com/LoganPaul/status/1429897214596304908">Logan Paul</a>). It says Logan Paul own this picture and these properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4vBkLFvK2QAcKa4mvgRjuw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*67naScMhzLMXlSYNfFnZ2w.png" /></figure><p>Ok, awesome, let’s see if you really own these. If you go to their contract <a href="https://etherscan.io/address/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#readContract">here</a> and look for method tokenURI (see below), enter “717” then click query:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n16iVrdCbFYHDwns_8QBsg.png" /></figure><p>You’d get an IPFS link:</p><pre>ipfs://QmXgSuLPGuxxRuAana7JdoWmaS25oAcXv3x2pYMN9kVfg3/717</pre><p>and if you copy-pasted those in your browser you’d get:</p><pre>{&quot;name&quot;:&quot;K4M-1 #03&quot;,&quot;attributes&quot;:[{&quot;trait_type&quot;:&quot;Type&quot;,&quot;value&quot;:&quot;K4M-1&quot;},{&quot;trait_type&quot;:&quot;Background&quot;,&quot;value&quot;:&quot;Technogod (Citrine)&quot;},{&quot;trait_type&quot;:&quot;Wear&quot;,&quot;value&quot;:&quot;03-Bomber Jacket&quot;},{&quot;trait_type&quot;:&quot;Helmet&quot;,&quot;value&quot;:&quot;03-Divine&quot;},{&quot;trait_type&quot;:&quot;Domain&quot;,&quot;value&quot;:&quot;Sun&quot;},{&quot;trait_type&quot;:&quot;Style&quot;,&quot;value&quot;:10,&quot;max_value&quot;:10},{&quot;trait_type&quot;:&quot;Strength&quot;,&quot;value&quot;:10,&quot;max_value&quot;:10},{&quot;trait_type&quot;:&quot;Spirit&quot;,&quot;value&quot;:10,&quot;max_value&quot;:10}],&quot;image&quot;:&quot;ipfs://QmcoavNZq2jyZGe2Zi4nanQqzU9hRPxunHAo8pgYZ5fSep/0717.png&quot;}</pre><p>Oh hey, it’s the properties and it also includes the image URL, which is also on IPFS! Unfortunately, all this information lives off-chain.</p><p><strong>What’s wrong with having these properties off-chain?</strong> Great question!</p><p>Well, first of all, if the contract owner decided that they want to change the baseURL (which they can do through setBaseURI method <a href="https://etherscan.io/address/0x3bf2922f4520a8ba0c2efc3d2a1539678dad5e9d#writeContract">here</a>), they could potentially change the rarity of any 0N1 token properties. And second, if no IPFS nodes pinned the IPFS files, these files could potentially get deleted from the IPFS network, then what’s left of your token is just your on-chain token ID, which in this case is number 2087. That&#39;s it!</p><p>Now of course 0N1 team is an amazing world-class team and I trust they will do everything to protect their IP and do all the right things, but it doesn’t change the fact that all the above are possibilities.</p><p>You might be like… ok, got it but it’s unlikely to happen with legit projects, so why do we care? I think the question you should ask is not exactly why do we care, but why do we want them to be on-chain?</p><p><strong>Why do we want properties to be on-chain?</strong></p><p>I think it’s always easy to go by example just like how we used 0N1 as an example of off-chain properties. Lets now use Loot as an example of on-chain properties</p><p>Let’s take a look at the most expensive loot ever sold on OpenSea. <a href="https://opensea.io/assets/0xff9c1b15b16263c61d017ee9f65c50e4ae0113d7/748">Bag #748</a></p><p>If you follow the same steps as we did above you’d get:</p><pre>data:application/json;base64,eyJuYW1lIjogIkJhZyAjNzQ4IiwgImRlc2NyaXB0aW9uIjogIkxvb3QgaXMgcmFuZG9taXplZCBhZHZlbnR1cmVyIGdlYXIgZ2VuZXJhdGVkIGFuZCBzdG9yZWQgb24gY2hhaW4uIFN0YXRzLCBpbWFnZXMsIGFuZCBvdGhlciBmdW5jdGlvbmFsaXR5IGFyZSBpbnRlbnRpb25hbGx5IG9taXR0ZWQgZm9yIG90aGVycyB0byBpbnRlcnByZXQuIEZlZWwgZnJlZSB0byB1c2UgTG9vdCBpbiBhbnkgd2F5IHlvdSB3YW50LiIsICJpbWFnZSI6ICJkYXRhOmltYWdlL3N2Zyt4bWw7YmFzZTY0LFBITjJaeUI0Yld4dWN6MGlhSFIwY0RvdkwzZDNkeTUzTXk1dmNtY3ZNakF3TUM5emRtY2lJSEJ5WlhObGNuWmxRWE53WldOMFVtRjBhVzg5SW5oTmFXNVpUV2x1SUcxbFpYUWlJSFpwWlhkQ2IzZzlJakFnTUNBek5UQWdNelV3SWo0OGMzUjViR1UrTG1KaGMyVWdleUJtYVd4c09pQjNhR2wwWlRzZ1ptOXVkQzFtWVcxcGJIazZJSE5sY21sbU95Qm1iMjUwTFhOcGVtVTZJREUwY0hnN0lIMDhMM04wZVd4bFBqeHlaV04wSUhkcFpIUm9QU0l4TURBbElpQm9aV2xuYUhROUlqRXdNQ1VpSUdacGJHdzlJbUpzWVdOcklpQXZQangwWlhoMElIZzlJakV3SWlCNVBTSXlNQ0lnWTJ4aGMzTTlJbUpoYzJVaVBsTm9iM0owSUZOM2IzSmtQQzkwWlhoMFBqeDBaWGgwSUhnOUlqRXdJaUI1UFNJME1DSWdZMnhoYzNNOUltSmhjMlVpUGtScGRtbHVaU0JTYjJKbElHOW1JSFJvWlNCR2IzZzhMM1JsZUhRK1BIUmxlSFFnZUQwaU1UQWlJSGs5SWpZd0lpQmpiR0Z6Y3owaVltRnpaU0krU0c5dlpEd3ZkR1Y0ZEQ0OGRHVjRkQ0I0UFNJeE1DSWdlVDBpT0RBaUlHTnNZWE56UFNKaVlYTmxJajVRYkdGMFpXUWdRbVZzZER3dmRHVjRkRDQ4ZEdWNGRDQjRQU0l4TUNJZ2VUMGlNVEF3SWlCamJHRnpjejBpWW1GelpTSStSR2wyYVc1bElGTnNhWEJ3WlhKelBDOTBaWGgwUGp4MFpYaDBJSGc5SWpFd0lpQjVQU0l4TWpBaUlHTnNZWE56UFNKaVlYTmxJajVEYUdGcGJpQkhiRzkyWlhNOEwzUmxlSFErUEhSbGVIUWdlRDBpTVRBaUlIazlJakUwTUNJZ1kyeGhjM005SW1KaGMyVWlQazVsWTJ0c1lXTmxQQzkwWlhoMFBqeDBaWGgwSUhnOUlqRXdJaUI1UFNJeE5qQWlJR05zWVhOelBTSmlZWE5sSWo1VWFYUmhibWwxYlNCU2FXNW5QQzkwWlhoMFBqd3ZjM1puUGc9PSJ9</pre><p>This is actually a base64 encoded JSON, which we can decode it into:</p><pre>{“name”: “Bag #748”, “description”: “Loot is randomized adventurer gear generated and stored on chain. Stats, images, and other functionality are intentionally omitted for others to interpret. Feel free to use Loot in any way you want.”, “image”: “data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaW5ZTWluIG1lZXQiIHZpZXdCb3g9IjAgMCAzNTAgMzUwIj48c3R5bGU+LmJhc2UgeyBmaWxsOiB3aGl0ZTsgZm9udC1mYW1pbHk6IHNlcmlmOyBmb250LXNpemU6IDE0cHg7IH08L3N0eWxlPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9ImJsYWNrIiAvPjx0ZXh0IHg9IjEwIiB5PSIyMCIgY2xhc3M9ImJhc2UiPlNob3J0IFN3b3JkPC90ZXh0Pjx0ZXh0IHg9IjEwIiB5PSI0MCIgY2xhc3M9ImJhc2UiPkRpdmluZSBSb2JlIG9mIHRoZSBGb3g8L3RleHQ+PHRleHQgeD0iMTAiIHk9IjYwIiBjbGFzcz0iYmFzZSI+SG9vZDwvdGV4dD48dGV4dCB4PSIxMCIgeT0iODAiIGNsYXNzPSJiYXNlIj5QbGF0ZWQgQmVsdDwvdGV4dD48dGV4dCB4PSIxMCIgeT0iMTAwIiBjbGFzcz0iYmFzZSI+RGl2aW5lIFNsaXBwZXJzPC90ZXh0Pjx0ZXh0IHg9IjEwIiB5PSIxMjAiIGNsYXNzPSJiYXNlIj5DaGFpbiBHbG92ZXM8L3RleHQ+PHRleHQgeD0iMTAiIHk9IjE0MCIgY2xhc3M9ImJhc2UiPk5lY2tsYWNlPC90ZXh0Pjx0ZXh0IHg9IjEwIiB5PSIxNjAiIGNsYXNzPSJiYXNlIj5UaXRhbml1bSBSaW5nPC90ZXh0Pjwvc3ZnPg==”}</pre><p>First of all, this is amazing. The metadata of Loot Bag #748 is actually on-chain and the image itself is actually a base64 encoded SVG string, which will render this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qlizHUa2PqYFnf9ttEKaqA.jpeg" /><figcaption>Loot Bag #748</figcaption></figure><p>Fucking brilliant! But wait a minute, where are the properties? How come they are not part of the metadata? Well, take a look at these contract methods:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcf3YUGz7q7MMcv0y3XTtQ.png" /><figcaption>Loot methods to get each property value</figcaption></figure><p>If you try to enter 748 on getChest method, you’d get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*UQh__UUZhLklzZ24f81I4w.png" /></figure><p>Holy shit! Yes, whoever owns that token ID actually owns the text “Divine Robe of Fox”.</p><p>But you might be like… WTF… why do i want to own this text?</p><p>Well, the answer is, the things that can be built on top of this NFT.</p><p>Check out this project: <a href="https://www.lootmart.xyz/">https://www.lootmart.xyz/</a> where any Loot holder can unbundle their bag into individual items. Unfortunately, I couldn’t find Divine Robe of the Fox . It&#39;s probably because the owner of Bag #748 hasn’t unbundled his items, but I did find <a href="https://opensea.io/assets/0x9b51a88cffe9b50e043661ddd7f492cc3888fcbf/34359738369">Divine Robe of Protection</a>.</p><p>The idea here is blockchain is open and permission-less. Having the properties on-chain means any smart contracts out there can call those methods and verify whether:<br>1. Someone owned a certain NFT<br>2. Someone owned certain properties<br>And build more functionalities and values on top of other projects. This is beautiful because then the community can keep building the value chain together. You should check <a href="https://www.lootproject.com/">https://www.lootproject.com/</a> as they already have an amazing community and ecosystem that are excited to build together and I hope I get to live the day a full game is created by the community.</p><h3>HOWL: an On-chain Properties PFP 2.0</h3><p>So now that we understand the inspiration behind HOWL on-chain properties. How did we do it?</p><p>Lets first ask this question:</p><blockquote>If on-chain properties are great to have to unlock collaboration by the community, then why 90% PFP out there don’t have it?</blockquote><p>Great question! The answer is simple, 2 things:</p><ol><li>Most projects out there are just copy-paste</li><li>Projects will have to pay an incredible amount of gas to deploy the smart contract, and most devs out there don’t even bother putting the effort to try to optimize their smart contract, let alone pull their hair to solve on-chain properties gas challenge. <em>i.e. nobody wants to pay 20 ETH to deploy a smart contract</em></li></ol><p>Let’s talk about why it’s expensive, take a look at Loot contract:</p><pre>contract Loot is ERC721Enumerable, ReentrancyGuard, Ownable {</pre><pre>string[] private weapons = [<br>        &quot;Warhammer&quot;,<br>        &quot;Quarterstaff&quot;,<br>        &quot;Maul&quot;,<br>        &quot;Mace&quot;,<br>        &quot;Club&quot;,<br>        &quot;Katana&quot;,<br>        &quot;Falchion&quot;,<br>        &quot;Scimitar&quot;,<br>        &quot;Long Sword&quot;,<br>        &quot;Short Sword&quot;,<br>        &quot;Ghost Wand&quot;,<br>        &quot;Grave Wand&quot;,<br>        &quot;Bone Wand&quot;,<br>        &quot;Wand&quot;,<br>        &quot;Grimoire&quot;,<br>        &quot;Chronicle&quot;,<br>        &quot;Tome&quot;,<br>        &quot;Book&quot;<br>    ];<br>    <br>    string[] private chestArmor = [<br>        &quot;Divine Robe&quot;,<br>        &quot;Silk Robe&quot;,<br>        &quot;Linen Robe&quot;,<br>        &quot;Robe&quot;,<br>        &quot;Shirt&quot;,<br>        &quot;Demon Husk&quot;,<br>        &quot;Dragonskin Armor&quot;,<br>        &quot;Studded Leather Armor&quot;,<br>        &quot;Hard Leather Armor&quot;,<br>        &quot;Leather Armor&quot;,<br>        &quot;Holy Chestplate&quot;,<br>        &quot;Ornate Chestplate&quot;,<br>        &quot;Plate Mail&quot;,<br>        &quot;Chain Mail&quot;,<br>        &quot;Ring Mail&quot;<br>    ];<br>    <br>    string[] private headArmor = [<br>        &quot;Ancient Helm&quot;,<br>        &quot;Ornate Helm&quot;,<br>        &quot;Great Helm&quot;,<br>        &quot;Full Helm&quot;,<br>        &quot;Helm&quot;,<br>        &quot;Demon Crown&quot;,<br>        &quot;Dragon&#39;s Crown&quot;,<br>        &quot;War Cap&quot;,<br>        &quot;Leather Cap&quot;,<br>        &quot;Cap&quot;,<br>        &quot;Crown&quot;,<br>        &quot;Divine Hood&quot;,<br>        &quot;Silk Hood&quot;,<br>        &quot;Linen Hood&quot;,<br>        &quot;Hood&quot;<br>    ];<br>    <br>    string[] private waistArmor = [<br>        &quot;Ornate Belt&quot;,<br>        &quot;War Belt&quot;,<br>        &quot;Plated Belt&quot;,<br>        &quot;Mesh Belt&quot;,<br>        &quot;Heavy Belt&quot;,<br>        &quot;Demonhide Belt&quot;,<br>        &quot;Dragonskin Belt&quot;,<br>        &quot;Studded Leather Belt&quot;,<br>        &quot;Hard Leather Belt&quot;,<br>        &quot;Leather Belt&quot;,<br>        &quot;Brightsilk Sash&quot;,<br>        &quot;Silk Sash&quot;,<br>        &quot;Wool Sash&quot;,<br>        &quot;Linen Sash&quot;,<br>        &quot;Sash&quot;<br>    ];<br>    <br>    string[] private footArmor = [<br>        &quot;Holy Greaves&quot;,<br>        &quot;Ornate Greaves&quot;,<br>        &quot;Greaves&quot;,<br>        &quot;Chain Boots&quot;,<br>        &quot;Heavy Boots&quot;,<br>        &quot;Demonhide Boots&quot;,<br>        &quot;Dragonskin Boots&quot;,<br>        &quot;Studded Leather Boots&quot;,<br>        &quot;Hard Leather Boots&quot;,<br>        &quot;Leather Boots&quot;,<br>        &quot;Divine Slippers&quot;,<br>        &quot;Silk Slippers&quot;,<br>        &quot;Wool Shoes&quot;,<br>        &quot;Linen Shoes&quot;,<br>        &quot;Shoes&quot;<br>    ];<br>    <br>    string[] private handArmor = [<br>        &quot;Holy Gauntlets&quot;,<br>        &quot;Ornate Gauntlets&quot;,<br>        &quot;Gauntlets&quot;,<br>        &quot;Chain Gloves&quot;,<br>        &quot;Heavy Gloves&quot;,<br>        &quot;Demon&#39;s Hands&quot;,<br>        &quot;Dragonskin Gloves&quot;,<br>        &quot;Studded Leather Gloves&quot;,<br>        &quot;Hard Leather Gloves&quot;,<br>        &quot;Leather Gloves&quot;,<br>        &quot;Divine Gloves&quot;,<br>        &quot;Silk Gloves&quot;,<br>        &quot;Wool Gloves&quot;,<br>        &quot;Linen Gloves&quot;,<br>        &quot;Gloves&quot;<br>    ];<br>    <br>    string[] private necklaces = [<br>        &quot;Necklace&quot;,<br>        &quot;Amulet&quot;,<br>        &quot;Pendant&quot;<br>    ];<br>    <br>    string[] private rings = [<br>        &quot;Gold Ring&quot;,<br>        &quot;Silver Ring&quot;,<br>        &quot;Bronze Ring&quot;,<br>        &quot;Platinum Ring&quot;,<br>        &quot;Titanium Ring&quot;<br>    ];<br>    <br>    string[] private suffixes = [<br>        &quot;of Power&quot;,<br>        &quot;of Giants&quot;,<br>        &quot;of Titans&quot;,<br>        &quot;of Skill&quot;,<br>        &quot;of Perfection&quot;,<br>        &quot;of Brilliance&quot;,<br>        &quot;of Enlightenment&quot;,<br>        &quot;of Protection&quot;,<br>        &quot;of Anger&quot;,<br>        &quot;of Rage&quot;,<br>        &quot;of Fury&quot;,<br>        &quot;of Vitriol&quot;,<br>        &quot;of the Fox&quot;,<br>        &quot;of Detection&quot;,<br>        &quot;of Reflection&quot;,<br>        &quot;of the Twins&quot;<br>    ];<br>    <br>    string[] private namePrefixes = [<br>        &quot;Agony&quot;, &quot;Apocalypse&quot;, &quot;Armageddon&quot;, &quot;Beast&quot;, &quot;Behemoth&quot;, &quot;Blight&quot;, &quot;Blood&quot;, &quot;Bramble&quot;, <br>        &quot;Brimstone&quot;, &quot;Brood&quot;, &quot;Carrion&quot;, &quot;Cataclysm&quot;, &quot;Chimeric&quot;, &quot;Corpse&quot;, &quot;Corruption&quot;, &quot;Damnation&quot;, <br>        &quot;Death&quot;, &quot;Demon&quot;, &quot;Dire&quot;, &quot;Dragon&quot;, &quot;Dread&quot;, &quot;Doom&quot;, &quot;Dusk&quot;, &quot;Eagle&quot;, &quot;Empyrean&quot;, &quot;Fate&quot;, &quot;Foe&quot;, <br>        &quot;Gale&quot;, &quot;Ghoul&quot;, &quot;Gloom&quot;, &quot;Glyph&quot;, &quot;Golem&quot;, &quot;Grim&quot;, &quot;Hate&quot;, &quot;Havoc&quot;, &quot;Honour&quot;, &quot;Horror&quot;, &quot;Hypnotic&quot;, <br>        &quot;Kraken&quot;, &quot;Loath&quot;, &quot;Maelstrom&quot;, &quot;Mind&quot;, &quot;Miracle&quot;, &quot;Morbid&quot;, &quot;Oblivion&quot;, &quot;Onslaught&quot;, &quot;Pain&quot;, <br>        &quot;Pandemonium&quot;, &quot;Phoenix&quot;, &quot;Plague&quot;, &quot;Rage&quot;, &quot;Rapture&quot;, &quot;Rune&quot;, &quot;Skull&quot;, &quot;Sol&quot;, &quot;Soul&quot;, &quot;Sorrow&quot;, <br>        &quot;Spirit&quot;, &quot;Storm&quot;, &quot;Tempest&quot;, &quot;Torment&quot;, &quot;Vengeance&quot;, &quot;Victory&quot;, &quot;Viper&quot;, &quot;Vortex&quot;, &quot;Woe&quot;, &quot;Wrath&quot;,<br>        &quot;Light&#39;s&quot;, &quot;Shimmering&quot;  <br>    ];<br>    <br>    string[] private nameSuffixes = [<br>        &quot;Bane&quot;,<br>        &quot;Root&quot;,<br>        &quot;Bite&quot;,<br>        &quot;Song&quot;,<br>        &quot;Roar&quot;,<br>        &quot;Grasp&quot;,<br>        &quot;Instrument&quot;,<br>        &quot;Glow&quot;,<br>        &quot;Bender&quot;,<br>        &quot;Shadow&quot;,<br>        &quot;Whisper&quot;,<br>        &quot;Shout&quot;,<br>        &quot;Growl&quot;,<br>        &quot;Tear&quot;,<br>        &quot;Peak&quot;,<br>        &quot;Form&quot;,<br>        &quot;Sun&quot;,<br>        &quot;Moon&quot;<br>    ];</pre><p>They stored those in the smart contract and I must say they did it in a very very smart and creative way. It’s basically a combination of prefix + base property name + suffix, and they are able to save a lot of gas by deterministically assigning the properties to a token ID. While this is great, but at the same time Loot exposed the industry to another challenge on generating properties on chain (you can read it here: <a href="https://medium.com/@iamthetorn/stop-forking-loot-its-kind-of-broken-f1a1c986784d">https://medium.com/@iamthetorn/stop-forking-loot-its-kind-of-broken-f1a1c986784d</a>). I will talk about how we try to come up with a way to generate properties on-chain fairly and securely on one of the upcoming posts of this PFP 2.0 narrative series, for now, let’s focus on how we manage to put our properties on-chain and able to save a lot of gas.</p><p>First of all, I’d like to mention, if it’s not because of our amazing dev <strong>0xface1e55</strong> who constantly pushing himself to be creative, we won’t be able to save a crazy amount of gas knowing that we have a big plan and ideas for HOWL metaverse. Kudos!</p><p>If you look at our <a href="https://houseofwarlords.com/">website</a>. We have 1000+ unique traits, there’s no way we can afford to deploy such a massive smart contract.</p><p>So how did we do it?</p><p>For reference, here’s our <a href="https://etherscan.io/address/0x8d2071a02608f337bAAe8da64f93b37aBD6BdE39">contract</a>. You can take a look at our full code there as we try to dissect what we did.</p><p>First, we can’t really afford to load all of our property names on-chain. So we opted to map our property names into numbers, which we already uploaded the provenance hash into our smart contract to make sure that it’s fair (i.e. we would never change them) — we will talk about these more on one of the upcoming posts.</p><p>Our properties are actually encoded into a dna that is generated during mint and in principal it&#39;s just a uint256 .</p><pre>mapping(uint256 =&gt; uint256) private _tokenIdToWarlord;</pre><p>And here’s our mint method:</p><pre>function _mintWarlord(<br>    address _address,<br>    uint256 _tokenId,<br>    uint256 _gen<br>) private {<br>    uint256 dna = uint256(<br>        keccak256(abi.encodePacked(_address, _tokenId, _getSeed()))<br>    );</pre><pre>    // When warlords are generated for the first time<br>    // the last 9 bits of their DNA will be used to store the generation number (8 bit)<br>    // and a flag that indicates whether the dna is in its encoded<br>    // or decoded state (1 bit).</pre><pre>    // Generation number will help to properly decode properties based on<br>    // property ranges that are unknown during minting.</pre><pre>    // ((dna &gt;&gt; 9) &lt;&lt; 9) clears the last 9 bits.<br>    // _gen * 2 moves generation information one bit to the left and sets the last bit to 0.<br>    dna = ((dna &gt;&gt; 9) &lt;&lt; 9) | (uint8(_gen) * 2);<br>    _tokenIdToWarlord[_tokenId] = dna;<br>    _safeMint(_address, _tokenId);<br>}</pre><p>As you can see, dna is generated from your address, tokenID and a random seed number from _getSeed() method.</p><p>Here’s an example of a simple DNA: 696969696969</p><p>And if we translate that into binary:</p><pre>...0000000000000000000001010001001000110101000011001011011001001</pre><p>If you read the _mintWarlord method above we said that we cleared up the first 9 bits so we can set the generation number (bit #2-9) and set the decoded flag (bit #1). The decoded flag is to indicate whether thedna has been decoded (1)or not (0).</p><p>So this is what it looks like now:</p><pre>...0000000000000000000001010001001000110101000011001011[00000000][0]</pre><p>The first section (bit #1 = [0]) from the right is the decoded flag</p><p>The second section (bit #2–9 = [00000000]) is the generation number, which is generation 0.</p><p>Now, take a look at getWarlord method to determine the properties based on the value extracted from thedna .</p><pre>function getWarlord(uint256 _tokenId) public view returns (Warlord memory) {<br>    uint256 dna = _tokenIdToWarlord[_tokenId];<br>    require(_isDnaRevealed(dna), &quot;HOWL: warlord is not revealed yet&quot;);</pre><pre>Warlord memory w;<br>    w.face = _getWarlordProperty(dna, 0);<br>    w.headGear = _getWarlordProperty(dna, 1);<br>    w.clothes = _getWarlordProperty(dna, 2);<br>    w.shoulderGuard = _getWarlordProperty(dna, 3);<br>    w.armGuards = _getWarlordProperty(dna, 4);<br>    w.sideWeapon = _getWarlordProperty(dna, 5);<br>    w.backWeapon = _getWarlordProperty(dna, 6);<br>    w.background = _getWarlordProperty(dna, 7);<br>    w.killCount = _getWarlordProperty(dna, 8);</pre><pre>return w;<br>}</pre><pre>function _getWarlordProperty(uint256 _dna, uint256 _propertyId)<br>    private<br>    view<br>    returns (uint16)<br>{<br>    // Property right offset in bits.<br>    uint256 bitShift = _propertyId * 16;</pre><pre>    // Last bit shows whether the dna was already decoded.<br>    // If it was we can safely return the stored value after bitshifting and applying a mask.<br>    // Decoded values don&#39;t have a generation number, so only need to shift by one bit to account for the flag.<br>    if (_dna &amp; 1 == 1) {<br>        return uint16(((_dna &gt;&gt; 1) &gt;&gt; bitShift) &amp; 0xFFFF);<br>    }</pre><pre>    // Every time warlords commit seppuku their DNA will be decoded.<br>    // If we got here it means that it wasn&#39;t decoded and we can safely assume that their kill counter is 0.<br>    if (_propertyId == 8) {<br>        return 0;<br>    }</pre><pre>    // Minted generation number is stored inside of 8 bits after the encoded/decoded flag.<br>    uint256 gen = (_dna &gt;&gt; 1) &amp; 0xFF;</pre><pre>    // Rarity and range values to decode the property (specific to generation)<br>    uint16[2] storage _rarity = generationRarities[gen];<br>    uint16[4] storage _range = generationRanges[gen][_propertyId];</pre><pre>    // Extracting the encoded (raw) property (also shifting by 9bits first to account for generation metadata and a flag).<br>    // This property is just a raw value, it will get decoded with _rarity and _range information from above.<br>    uint256 encodedProp = (((_dna &gt;&gt; 9) &gt;&gt; bitShift) &amp; 0xFFFF);</pre><pre>if (<br>        (_propertyId == 3 || _propertyId == 4 || _propertyId == 5) &amp;&amp;<br>        // 60% chance that sideWeapon/armGuards/shoulderGuard will appear<br>        uint256(keccak256(abi.encodePacked(encodedProp, _range))) % 100 &gt; 60<br>    ) {<br>        // Unlucky<br>        return 0;<br>    }</pre><pre>    // A value that will dictate from which pool of properties we should pull (common, uncommon, rare)<br>    uint256 rarityDecider = (uint256(<br>        keccak256(abi.encodePacked(_propertyId, _dna, _range))<br>    ) % 100) + 1;</pre><pre>    uint256 rangeStart;<br>    uint256 rangeEnd;</pre><pre>    // There is an opportunity to optimize for SLOAD operations here by byte packing all<br>    // rarity/range information and loading it in getWarlord before this function<br>    // is called to minimize state access.<br>    if (rarityDecider &lt;= _rarity[0]) {<br>        // common<br>        rangeStart = _range[0];<br>        rangeEnd = _range[1];<br>    } else if (rarityDecider &lt;= _rarity[1] + _rarity[0]) {<br>        // uncommon<br>        rangeStart = _range[1];<br>        rangeEnd = _range[2];<br>    } else {<br>        // rare<br>        rangeStart = _range[2];<br>        rangeEnd = _range[3];<br>    }</pre><pre>    // Returns a decoded property that will fall within one of the rarity buckets.<br>    return uint16((encodedProp % (rangeEnd - rangeStart)) + rangeStart);<br>}</pre><p>What _getWarlordProperty(uint256 _dna, uint256 _propertyId) does is basically to extract a section of the dna binary based on the propertyId (index).</p><p>Let’s go through this together:</p><p>Say we are running this w.face = _getWarlordProperty(dna, 0);</p><p>We will extract 16 bits from the dnabased on the property index:uint256 bitShift = _propertyId * 16; .</p><p>With this code:</p><pre>uint256 encodedProp = (((_dna &gt;&gt; 9) &gt;&gt; bitShift) &amp; 0xFFFF);</pre><p>It looks like this:</p><pre>...000000000000000000000101000100100011[0101000011001011][00000001][0]</pre><p>That’s how it looks like now and we are extracting that 3rd section out</p><p>Before we go further lets take a look at these:</p><pre>// Rarity and range values to decode the property (specific to generation)</pre><pre>uint16[2] storage _rarity = generationRarities[gen];</pre><pre>uint16[4] storage _range = generationRanges[gen][_propertyId];</pre><p>generationRarities and generationRanges are uploaded through setGenerationRanges and setGenerationRarities methods. And we don’t plan to do that until we close minting so that nobody can take a peek at what they have :). Once those are set, we can set the decoded flag to true and everyone will be able to see their warlords! Anyway, we’re not here to talk abut that, we can save that for one of next upcoming posts</p><p>Anyway, let’s go back to that binary value we extracted 0101000011001011 which is 20683 in base10 as encodedProperty.</p><p>Next, based on _dna we determine if you are eligible for a common or uncommon or rare through this code:</p><pre>uint256 rarityDecider = (uint256(<br>    keccak256(abi.encodePacked(_propertyId, _dna, _range))<br>) % 100) + 1;</pre><p>which will return a number and from that number, we will be able to extract the number ranges of the rarity bucket. For example if rare bucket falls under property value range from 20 (rangeStart) to 34 (rangeEnd), then next step is for this code to return the property value:</p><pre>return uint16((encodedProp % (rangeEnd - rangeStart)) + rangeStart);</pre><p>It should return between 20 and 34. And what lies beyond those numbers? Those shall be revealed when we reveal in the next upcoming weeks!</p><h3>Conclusion</h3><p>By using large uint256 number, HOWL team was able to come up with a structure to determine properties represented in numbers that will be mapped to property names off-chain. But at the same time, for accountability, we provided a provenance hash that we already uploaded in this <a href="https://etherscan.io/tx/0x645c415cffb9fb08e1fb820c67688b744eee7e65e945c7a50b62d0c9f30267ad">transaction</a> before we mint anything.</p><p>In the next several posts we will cover other innovations that the HOWL team put a lot of effort to try to solve some of the industry challenges. Such as:</p><ul><li>Fair Distribution</li><li>On-chain Pre-reveal/Reveal Mechanics</li><li>Multiple generations on-chain properties</li><li>On-chain property updates through other authorized smart contracts (equip items on your warlord or future extension such as enable your warlords to store items in inventory)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51c9a9280615" width="1" height="1" alt=""><hr><p><a href="https://medium.com/house-of-warlords/house-of-warlords-pfp-2-0-loot-inspired-on-chain-properties-51c9a9280615">House of Warlords PFP 2.0: Loot inspired on-chain properties</a> was originally published in <a href="https://medium.com/house-of-warlords">House Of Warlords</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>