<?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 David Jaramillo Cañas on Medium]]></title>
        <description><![CDATA[Stories by David Jaramillo Cañas on Medium]]></description>
        <link>https://medium.com/@david.jaramillo.c?source=rss-eb6cc1d60e57------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gJBhJi7BuldAahtNsGq0EA.jpeg</url>
            <title>Stories by David Jaramillo Cañas on Medium</title>
            <link>https://medium.com/@david.jaramillo.c?source=rss-eb6cc1d60e57------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 05:41:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@david.jaramillo.c/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[Another way to create Tokens (Part I)]]></title>
            <link>https://medium.com/@david.jaramillo.c/another-way-to-create-tokens-part-i-fc4844e6624a?source=rss-eb6cc1d60e57------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc4844e6624a</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[token]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[David Jaramillo Cañas]]></dc:creator>
            <pubDate>Fri, 21 Apr 2017 17:48:56 GMT</pubDate>
            <atom:updated>2017-04-25T01:12:48.369Z</atom:updated>
            <content:encoded><![CDATA[<p>In a previous article (<a href="https://medium.com/@MyPaoG/explaining-the-dao-exploit-for-beginners-in-solidity-80ee84f0d470"><em>Explaining the DAO exploit for beginners in Solidity</em></a>) in which I participated in the discussion. We addressed the attack about the DAO. This attack used the fallback function. Besides, tokens were stored in a contract, specifically, in a mapping variable that stores the relationship between address and balance of the token which facilitated the withdraw of funds. This pattern is fair usual as we can see in “<a href="https://ethereum.org/token"><em>Create your cryptocurrency with ethereum.</em></a>” For this reason, I will try to give an alternative to this typical pattern. The alternative is not necessarily better than the original, but it is another way to create tokens.</p><p>This article is the first of a series in which I explain other methods to store the relationship between address and balance without the use of mapping. Moreover, it is more technical that the reference I mentioned before, but I will try to give a simple explanation about mapping, function hash, and gas. If you have knowledge about these topics, you can jump to the next paragraphs.</p><h3><strong>Mappings(solidity)</strong></h3><p>Mappings are data structures that are used to store relationship of data. For example, the tokens that an address has assigned. If you have programmed in other languages, the mappings use key/value pairs similar to Javascript objects and Python dictionaries. However, mappings in solidity don’t have every functionality implemented that a hashmap has. For instance, you can’t loop through the keys or count the keys in a mapping, but there are ways to resolve this problem. You can read the next article “<a href="https://ethereum.stackexchange.com/questions/12145/how-to-loop-through-mapping-in-solidity"><em>How to loop through mapping in solidity.</em></a>”</p><h3><strong>Gas</strong></h3><p>When you run code in the Ethereum Virtual Machine (EVM) to change the state of a smart contract in the blockchain, we must pay for the operations that the EVM execute. For more information, you can read this post “<a href="https://media.consensys.net/ethereum-gas-fuel-and-fees-3333e17fe1dc"><em>Ethereum gas fuel and fees.</em></a>” Nevertheless, it is important to mention that the block has a gas limit. The gas limit is to avoid infinite loops in EVM. The gas limit in the block is defined by the maximum amount of gas on all transactions in the whole block combined are allowed to consume[1].</p><h3><strong>Hash Functions</strong></h3><p>Hash functions are used in many protocols and applications in the context of information security. A Hash function takes an input (a message) of arbitrary length and applies a set of mathematical transformations to it to produce an output (a digest) of fixed size. The function, for this case, is a deterministic function. In the hash functions can occur collisions this means that there are two different inputs and that you can have the same output. In theory, a good hash function must have a little probability of collision. An example of this is in “<a href="https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html"><em>Announcing the first SHA1 collision.</em></a>”</p><h3>Another way to create the relationship between address and token</h3><p>When we build tokens using the usual pattern (“<a href="https://ethereum.org/token"><em>Create your cryptocurrency with ethereum</em></a>”), we need to use a mapping to store the tokens that an address has assigned. In my opinion, there are few problems with this approach:</p><ul><li>Complex migration of data — Our plans must consider the gas execution and the gas limit in the block.</li><li>Centralization of information (address -&gt;balance token) — It could be highly risky when there is a hacking.</li></ul><p>My proposal is to use a system similar to a bus card. The information of balance is on the bus card, and only some actors can modify the balance with the authorization of owner’s card. Therefore, we need to have three smart contracts:</p><ul><li><strong>SMcard (<em>Smart contract Card</em>) </strong>— It only stores the information of the balance and only interactions with Smart contracts of Authorization.</li><li><strong>SMGencard (<em>Smart contract of Generation Card</em>) </strong>— This only can generate SMcard with balance zero.</li><li><strong>SMauth (<em>Smart contract of Authorization</em>)</strong> — This only can modify the balance of a SMcard with the permission of the owner. Also, the SMauth must recognize the SMcards.</li></ul><p>The most important in this system is not to interact with fake SMcards because all information of token will be in them. We avoid the fake SMcards using the hash functions that the EVM has implemented:</p><ul><li><strong>SHA3</strong></li><li><strong>RIPEMD160</strong></li></ul><p>These hash functions have different implementation of the collision so, we avoid collision (“<a href="https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html"><em>Announcing the first SHA1 collision.</em></a>”) if we use together.<br>Now, I show the code which permits to detect the fake smart contract and a smart contract factory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c25be44b56c6a05381861e057c3faeed/href">https://medium.com/media/c25be44b56c6a05381861e057c3faeed/href</a></iframe><p>The contract “A” is easier because it only has a variable of the type address. Also, the contract “ObjectFactory” is fair simple because it only generates contract “A.” Every contract created from the function “createObject” have the same bytecode.</p><p><strong>contract “A”:</strong></p><p><em>60606040523415600b57fe5b5b60338060196000396000f30060606040525bfe00a165627a7a7230582081a524a8698d8e1d9ba96a2e0865352807f8506ffcdfe038bbc97514c461d2d00029</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec9d3bd3dc9cd441a0e1589488381e4b/href">https://medium.com/media/ec9d3bd3dc9cd441a0e1589488381e4b/href</a></iframe><p>The contract “B” is easier because it only has a variable of the type uint. The contract “ObjectFactory” is simple because it only generates contract “B.” Every contract created by the function “createObject” have the same bytecode.</p><p><strong>contract B:</strong></p><p><em>60606040523415600b57fe5b5b60338060196000396000f30060606040525bfe00a165627a7a72305820e34609955dbd9a7893510d9e6820ac10992852fb9da593f0d524587bff311f990029</em></p><p>If we compare the bytecode of contract “A” and contract “B,” we can observe no major differences except for the hash function (Sha3 and RIPEMD160) which are very different. You can see this in an example in <a href="https://jsfiddle.net/djaramillo021/j3zzux2L/">JavaScript</a> about this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5846c7131bd420428beb9b98bb17256e/href">https://medium.com/media/5846c7131bd420428beb9b98bb17256e/href</a></iframe><p>The contract “Validation” uses assembly code to get the bytecode of address (smart contract) in the blockchain. When we created a contract “Validation” and passed an address from a contract “A,” the contract Validation used the contract “A” like a standard to compare other addresses(contracts) when the function “compare” is used.</p><h3>Conclusion</h3><p>In this article, I only want to introduce the main idea and the code in solidity where I show that it is possible to create another pattern to develop tokens. This pattern can be more costs in gas, but it can be better in the process of migration. <br>In the next article, I will develop a proposal design similar to “<a href="https://ethereum.org/token"><em>Create your cryptocurrency with ethereum.</em></a>” and compare both methods in the consumption gas and the process of migration.</p><p><strong>Reviewer:</strong><br>Morgan Sliman ( <a href="https://github.com/morgansliman">https://github.com/morgansliman</a> )</p><p><strong>Footnotes:</strong></p><p>[1]<a href="https://bitcoin.stackexchange.com/questions/39132/what-is-gas-limit-in-ethereum">https://bitcoin.stackexchange.com/questions/39132/what-is-gas-limit-in-ethereum</a></p><p>[2] <a href="https://github.com/djaramillo021/protoArchitecture">https://github.com/djaramillo021/protoArchitecture</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc4844e6624a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>