<?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 Kumar Anirudha on Medium]]></title>
        <description><![CDATA[Stories by Kumar Anirudha on Medium]]></description>
        <link>https://medium.com/@anistark?source=rss-8801cbe17598------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*HsJPiGGOEr8fmjbQ.jpg</url>
            <title>Stories by Kumar Anirudha on Medium</title>
            <link>https://medium.com/@anistark?source=rss-8801cbe17598------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 07 Jun 2026 12:55:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anistark/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[Building a Cross-Chain Bridge]]></title>
            <link>https://medium.com/@anistark/building-a-cross-chain-bridge-d92c4417972f?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/d92c4417972f</guid>
            <category><![CDATA[evm-bridge]]></category>
            <category><![CDATA[abstraction]]></category>
            <category><![CDATA[interoperability]]></category>
            <category><![CDATA[cross-chain-bridge]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Tue, 11 Feb 2025 05:05:51 GMT</pubDate>
            <atom:updated>2025-02-11T05:05:51.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NyIB88We3vXgaUgetsdxhQ.png" /></figure><blockquote><em>A </em><strong><em>cross-chain bridge</em></strong><em> is a protocol that allows assets, data, or smart contract states to be transferred between two or more decentralised networks. It enables interoperability between different blockchains, ensuring seamless movement of tokens, NFTs, and other digital assets across ecosystems.</em></blockquote><p>So, how about we learn how to build a <strong>cross-chain bridge</strong> that allows NFTs to move between two <strong>EVM-compatible chains</strong> (e.g., Ethereum &amp; Base, Arbitrum, Optimism &amp; Polygon). Unlike traditional bridges, which use an <strong>off-chain relayer</strong>, we will implement an <strong>on-chain gateway</strong> using <a href="https://layerzero.network/">LayerZero</a>, making the process <strong>fully decentralised and trustless</strong>.</p><p><a href="https://blog.anirudha.dev/decentralising-bridges"><em>If you want to read more about decentralised bridges, check out my previously posted article.</em></a></p><p>NFTs and assets are often confined to their originating blockchain, limiting their interoperability and liquidity. A <strong>cross-chain bridge</strong> enables users to transfer NFTs between different chains, enhancing:</p><ul><li><strong>Liquidity</strong> — NFTs can be traded across multiple ecosystems.</li><li><strong>Utility</strong> — Users can access different dApps on multiple chains.</li><li><strong>Scalability</strong> — Avoid congestion on expensive chains like Ethereum.</li></ul><p>The base chain, where an NFT collection originates, plays a crucial role in determining the overall value and functionality of the NFTs.</p><ol><li><strong>Security and Trust</strong>: The base chain provides the foundational security for the NFT collection. A well-established chain like Ethereum offers robust security features, which can enhance the trustworthiness of the NFTs. While an L2 like Base can offer lower gas fee. There’s several factors that you can think of while deciding the base chain for your NFT collection.</li><li><strong>Network Effects</strong>: The popularity and user base of the base chain can significantly impact the visibility and adoption of the NFT collection. A chain with a large community can drive more engagement and transactions.</li><li><strong>Ecosystem and Tools</strong>: The base chain often dictates the available development tools and ecosystem support. A rich ecosystem with various dApps and services can add more utility to the NFTs, allowing them to be used in diverse applications.</li><li><strong>Transaction Costs</strong>: The cost of transactions on the base chain can affect the affordability and frequency of NFT trades. Chains with lower fees can encourage more trading activity, while high fees might deter users.</li><li><strong>Interoperability</strong>: The base chain’s compatibility with other chains can determine how easily NFTs can be transferred across different networks. A chain that supports cross-chain protocols can enhance the liquidity and utility of the NFTs. It’s very important that you do not choose a chain which doesn’t allow access to outside network at all.</li><li><strong>Innovation and Upgrades</strong>: The pace of innovation and the ability to implement upgrades on the base chain can influence the long-term viability and features of the NFT collection. Chains that are actively developed and improved can offer more advanced capabilities over time. Never go for a chain, which has stangant development or takes too long to iterate.</li></ol><p>However, we can not expect all the users to remain on any single network. So, we need to prepare for the seemless moving around of assets cross-chain, thereby improving interoperability.</p><p>And of course, there are several approaches to achieve bridging, depending on how you structure your product. Let’s go ahead with a classic approach this time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8a9-zEgow0EZi77S.png" /></figure><h3>How It Works</h3><ol><li><strong>Lock the NFT</strong> on <strong>Chain A</strong> (BridgeA contract).</li><li><strong>Send a cross-chain message</strong> using LayerZero to <strong>Chain B</strong>.</li><li><strong>BridgeB contract receives the message</strong> and <strong>mints a wrapped NFT</strong> on Chain B.</li><li>To <strong>return the NFT</strong>, the wrapped NFT is <strong>burned</strong> on Chain B, and a <strong>message is sent back</strong> to unlock the original NFT.</li></ol><h3>🏛 On-Chain Relayer (Our Approach)</h3><p>✅ Fully decentralised, no external trust required.<br>✅ All logic is enforced via smart contracts.<br>✅ Works with protocols like LayerZero or Axelar.</p><h3>⚡ Off-Chain Relayer</h3><p>❌ Requires external nodes/validators to confirm transactions.<br>❌ Can introduce centralisation and trust assumptions.<br>❌ Relayers may become a point of failure.</p><p>Our <strong>on-chain approach</strong> ensures security and trustlessness by leveraging smart contracts for message passing. We’re using EVM chains for this example so the contracts preferrably written in solidity.</p><h3>NFT Contract</h3><p>First, deploy an <strong>ERC-721 NFT</strong> contract on <strong>both chains</strong>:</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.19;<br><br>import &quot;@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol&quot;;<br>import &quot;@openzeppelin/contracts/access/Ownable.sol&quot;;<br>contract MyNFT is ERC721URIStorage, Ownable {<br>    uint256 public nextTokenId;<br>    <br>    constructor() ERC721(&quot;MyNFT&quot;, &quot;MNFT&quot;) {}<br>    <br>    function mint(string memory tokenURI) external onlyOwner {<br>        _safeMint(msg.sender, nextTokenId);<br>        _setTokenURI(nextTokenId, tokenURI);<br>        nextTokenId++;<br>    }<br>}</pre><h3>Bridge Contract (Chain A) — Lock NFT &amp; Send Message</h3><p>Create BridgeA.sol on <strong>Chain A</strong>:</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.19;<br>import &quot;@openzeppelin/contracts/token/ERC721/ERC721.sol&quot;;<br>import &quot;@layerzerolabs/solidity-examples/contracts/lzApp/NonblockingLzApp.sol&quot;;<br><br>contract BridgeA is NonblockingLzApp {<br>    ERC721 public nft;<br>    address public admin;<br>    event NFTLocked(address indexed user, uint256 tokenId);<br>    constructor(address _nft, address _lzEndpoint) NonblockingLzApp(_lzEndpoint) {<br>        admin = msg.sender;<br>        nft = ERC721(_nft);<br>    }<br>    function lockNFT(uint256 tokenId, uint16 destChainId, bytes memory receiver) external payable {<br>        require(nft.ownerOf(tokenId) == msg.sender, &quot;Not NFT owner&quot;);<br>        nft.transferFrom(msg.sender, address(this), tokenId);<br>        bytes memory payload = abi.encode(msg.sender, tokenId);<br>        _lzSend(destChainId, payload, payable(msg.sender), address(0), bytes(&quot;&quot;), msg.value);<br>        emit NFTLocked(msg.sender, tokenId);<br>    }<br>    function _nonblockingLzReceive(uint16, bytes memory, uint64, bytes memory payload) internal override {}<br>}</pre><h3>Bridge Contract (Chain B) — Receive &amp; Mint Wrapped NFT</h3><p>Create BridgeB.sol on <strong>Chain B</strong>:</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.19;<br><br>import &quot;@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol&quot;;<br>import &quot;@layerzerolabs/solidity-examples/contracts/lzApp/NonblockingLzApp.sol&quot;;<br><br>contract BridgeB is ERC721URIStorage, NonblockingLzApp {<br>    address public admin;<br>    uint256 public nextTokenId;<br>    event NFTMinted(address indexed user, uint256 tokenId);<br>    constructor(address _lzEndpoint) ERC721(&quot;WrappedNFT&quot;, &quot;WNFT&quot;) NonblockingLzApp(_lzEndpoint) {<br>        admin = msg.sender;<br>    }<br>    function _nonblockingLzReceive(uint16, bytes memory, uint64, bytes memory payload) internal override {<br>        (address user, uint256 tokenId) = abi.decode(payload, (address, uint256));<br>        _safeMint(user, nextTokenId);<br>        _setTokenURI(nextTokenId, &quot;https://metadata-url&quot;);<br>        emit NFTMinted(user, nextTokenId);<br>        nextTokenId++;<br>    }<br>}</pre><h3>Unlocking NFTs (Return to Chain A)</h3><p>Modify BridgeB.sol to <strong>burn the wrapped NFT and send it back</strong>:</p><pre>function burnNFT(uint256 tokenId, uint16 destChainId) external payable {<br>    require(ownerOf(tokenId) == msg.sender, &quot;Not NFT owner&quot;);<br>    _burn(tokenId);<br>    bytes memory payload = abi.encode(msg.sender, tokenId);<br>    _lzSend(destChainId, payload, payable(msg.sender), address(0), bytes(&quot;&quot;), msg.value);<br>}</pre><p>Modify BridgeA.sol to <strong>release the original NFT</strong>:</p><pre>function _nonblockingLzReceive(uint16, bytes memory, uint64, bytes memory payload) internal override {<br>    (address user, uint256 tokenId) = abi.decode(payload, (address, uint256));<br>    nft.transferFrom(address(this), user, tokenId);<br>}</pre><h3>Let’s test our Bridge:</h3><ol><li><strong>Deploy contracts</strong> on two testnets (say, Base Sepolia &amp; Polygon Amoy).</li><li><strong>Mint an NFT</strong> on Chain A.</li><li><strong>Lock &amp; transfer the NFT</strong> using the bridge.</li><li><strong>Verify minting of wrapped NFT</strong> on Chain B.</li><li><strong>Burn wrapped NFT</strong> to return to Chain A.</li></ol><h3>Future Improvements that can be made:</h3><h4>Multi-Chain Support</h4><p>To enhance the functionality and reach of our bridge, we can consider adding support for additional EVM-compatible chains. This would involve integrating with popular networks like Binance Smart Chain, Avalanche, and Fantom, which would allow users to transfer NFTs across a wider range of platforms. Furthermore, expanding beyond EVM-compatible chains to include other blockchain ecosystems, such as Solana, Cosmos, and Polkadot, could significantly broaden the bridge’s capabilities. This expansion would require developing interoperability solutions to handle the unique characteristics and consensus mechanisms of these different blockchains. By doing so, we would enable seamless NFT transfers across a diverse array of blockchain networks, providing users with greater flexibility and access to a wider audience. This strategic enhancement could position our bridge as a leading solution in the rapidly evolving multi-chain NFT landscape.</p><h4>Cross-Chain Fees</h4><p>Implementing gas abstraction can significantly enhance the user experience by making transactions more seamless and user-friendly. Gas abstraction involves creating a system where users do not need to worry about paying gas fees directly in cryptocurrency. Instead, the system can handle these fees on behalf of the users, possibly by integrating a third-party service or using a relayer network. This approach can simplify the transaction process, especially for users who are not familiar with blockchain technology or do not hold the native cryptocurrency required for gas fees. By abstracting gas fees, developers can create a more intuitive and accessible platform, encouraging broader adoption and reducing barriers for entry into the blockchain ecosystem. Additionally, this can be particularly beneficial in scenarios involving cross-chain interactions, where users might otherwise need to manage multiple cryptocurrencies for gas fees on different chains.</p><h4>Decentralised Governance</h4><p>Decentralised Autonomous Organisations (DAOs) can play a crucial role in managing and governing bridge policies. By introducing DAO-controlled bridge policies, we can ensure that the decision-making process is transparent, democratic, and community-driven. This means that all stakeholders, including developers, users, and investors, can participate in proposing, discussing, and voting on changes to the bridge’s operational rules and guidelines. Such a system can enhance trust and accountability, as decisions are made collectively rather than by a centralised authority. Additionally, DAO governance can adapt more quickly to the evolving needs of the community and the market, allowing for more responsive and flexible policy adjustments. By leveraging the power of DAOs, we can create a more resilient and adaptable bridge infrastructure that aligns with the interests and values of its users.</p><blockquote><em>Note that this was for learning purposes only. The real contracts will have to consider several security issues and vulnerabilities which we’ve assumed here, as part of the happy path. But it’s a start and would love to see at least some of you try it out and build more decentralised bridges. The bridges ecosystem is both quickly evolving and stagnant at the same time. Cross-chain messaging protocols have certainly pulled in a pin off the race for building decent decentralised bridges, but we’ve quite a few improvement yet to be made to achieve true trustless systems.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lOXLbNz-EFVd0ZoN.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d92c4417972f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Synthetic Asset Tokens]]></title>
            <link>https://medium.com/@anistark/synthetic-asset-tokens-4d54443b904b?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d54443b904b</guid>
            <category><![CDATA[token]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[synthetic-asset]]></category>
            <category><![CDATA[nft]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Mon, 27 Jan 2025 04:56:47 GMT</pubDate>
            <atom:updated>2025-01-27T04:56:47.353Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DodDxKdRTb89a76GCssBrg.jpeg" /></figure><p>Imagine having access to the value of an asset, say, Tesla stock, without ever owning it. That’s essentially what synthetic asset tokens (or just “synthetics”) do. These are blockchain-based tokens that mimic the value of real-world assets, such as stocks, commodities, or even fiat currencies. Think of them as financial doppelgängers: they look, act, and feel like the original, but they exist entirely in the digital realm.</p><p>In the traditional financial market, synthetic assets are not new. Derivatives like futures and options have been around for decades, allowing traders to bet on the price of an asset without ever owning it. Synthetic tokens simply bring this concept to the blockchain, leveraging smart contracts to handle everything transparently and automatically.</p><p>Derivatives exist in web3 as well already. However, there’s still lot of scepticism around it. Derivatives like futures, options, and perpetual swaps already exist and are widely used. Both derivatives and synthetic tokens are tied to an underlying asset, such as Bitcoin, Ethereum, or traditional stocks like Tesla. The performance of these assets directly affects the value of the derivative or synthetic token. Just as derivatives allow traders to speculate or hedge risks, synthetic asset tokens let users gain exposure to the price of assets without actually owning them.</p><p>Crypto derivatives have gained significant traction, especially in speculative trading. Futures and perpetual swaps on exchanges like Binance, Bybit, and dYdX dominate trading volumes. They offer high liquidity and enable speculation on crypto prices. Traders and institutions use derivatives to manage risk, especially in highly volatile markets. Many jurisdictions have banned or restricted derivatives trading due to concerns over high leverage and investor risk (e.g., Binance halting derivatives in several countries). The extreme price swings in crypto make derivatives riskier than their traditional counterparts, leading to liquidations for unprepared traders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*BG99hDxhMTSjotIc.png" /></figure><p>Traditional finance views synthetics as tools for hedging and speculation. Want to protect yourself from the wild price swings of oil without owning physical barrels? A synthetic derivative could be your best friend. Similarly, traders use them to speculate on price movements, essentially making money out of thin air, if they play their cards right.</p><p>In the tokenized asset market, synthetic tokens serve a similar purpose, but with a blockchain twist. They’re used for:</p><ol><li><strong>Global Accessibility</strong>: You don’t need a brokerage account to own a synthetic version of Apple stock. Just a crypto wallet will do.</li><li><strong>Fractional Ownership</strong>: Want exposure to gold but can’t afford a whole ounce? Synthetic tokens can be fractioned down to tiny denominations.</li><li><strong>Decentralized Finance (DeFi)</strong>: Platforms like Synthetix allow users to mint synthetic tokens using their crypto as collateral.</li></ol><p>Like any financial innovation, synthetic asset tokens come with their own set of advantages and challenges.</p><h4>Pros</h4><ul><li><strong>Accessibility</strong>: Traditional markets often have barriers, like location, regulations, or account requirements. Synthetic tokens tear those walls down.</li><li><strong>Efficiency</strong>: Transactions happen on the blockchain, which means they’re often faster and cheaper than traditional methods.</li><li><strong>Liquidity Boost</strong>: Synthetic tokens can unlock liquidity by bringing otherwise illiquid assets into a tradable, digital format.</li></ul><h4>Cons</h4><ul><li><strong>Complexity</strong>: They’re not beginner-friendly. Understanding how synthetics work requires some financial and blockchain literacy.</li><li><strong>Regulation</strong>: Governments haven’t fully figured out how to regulate synthetic tokens, which could lead to legal uncertainties. Hell, some governements are yet to figure to crypto itself.</li><li><strong>Counterparty Risk</strong>: In DeFi, your synthetics depend on smart contracts and oracles. If something goes wrong there, your assets could be at risk.</li></ul><p>Here’s where things get exciting. Synthetic asset tokens can significantly improve liquidity in the crypto and NFT markets by unlocking idle assets, diversification and bridging markets. Imagine converting an NFT, typically illiquid, into a synthetic token that can be freely traded. This opens up an entirely new avenue for liquidity in the NFT space. Traders could gain exposure to other markets (stocks, gold, real estate) without leaving the crypto ecosystem. Synthetic tokens could serve as a bridge between traditional and crypto markets. For example, a synthetic token pegged to the S&amp;P 500 index could attract traditional investors into the blockchain world.<br>In essence, synthetics have the potential to make markets more fluid, more inclusive, and more interconnected.</p><p>A few platforms and projects are already leveraging synthetic asset tokens:</p><ul><li><strong>Synthetix</strong>: Synthetix is one of the leading platforms for synthetic assets. It allows users to mint Synths tokens representing real-world assets like sUSD (synthetic USD), sBTC (synthetic Bitcoin), and even synthetic stocks. Synthetix uses Chainlink oracles to ensure accurate pricing.</li><li><strong>Mirror Protocol</strong>: Built on Terra, Mirror Protocol enabled synthetic versions of stocks like mAAPL (synthetic Apple stock) and mGOOGL (synthetic Google stock). It gained popularity for allowing users outside the U.S. to trade synthetic U.S. stocks. However, Terra’s collapse affected its adoption.</li><li><strong>NFTy</strong> <em>(👀)</em>: Imagine a platform where synthetic tokens represent a basket of the top 500 NFT collections. It creates a new layer of liquidity and market exposure for NFT enthusiasts.</li></ul><p>Let’s skip to look into code for a bit.</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract SyntheticAssetToken {<br>    string public name = &quot;SyntheticAssetToken&quot;;<br>    string public symbol = &quot;SAT&quot;;<br>    uint8 public decimals = 18;<br>    uint256 public totalSupply;<br>    mapping(address =&gt; uint256) public balanceOf;<br>    mapping(address =&gt; mapping(address =&gt; uint256)) public allowance;<br>    uint256 public collateralRatio = 200; // 200% collateral required<br>    uint256 public collateralLocked;<br>    mapping(address =&gt; uint256) public collateral;<br>    address public owner;<br>    constructor() {<br>        owner = msg.sender;<br>    }<br>    modifier onlyOwner() {<br>        require(msg.sender == owner, &quot;Only the owner can perform this action&quot;);<br>        _;<br>    }<br>    // Events<br>    event Transfer(address indexed from, address indexed to, uint256 value);<br>    event Approval(address indexed owner, address indexed spender, uint256 value);<br>    event Mint(address indexed user, uint256 amount, uint256 collateral);<br>    event Burn(address indexed user, uint256 amount, uint256 collateralReturned);<br>    // Transfer tokens<br>    function transfer(address to, uint256 value) public returns (bool) {<br>        require(balanceOf[msg.sender] &gt;= value, &quot;Insufficient balance&quot;);<br>        balanceOf[msg.sender] -= value;<br>        balanceOf[to] += value;<br>        emit Transfer(msg.sender, to, value);<br>        return true;<br>    }<br>    // Approve an allowance for another address<br>    function approve(address spender, uint256 value) public returns (bool) {<br>        allowance[msg.sender][spender] = value;<br>        emit Approval(msg.sender, spender, value);<br>        return true;<br>    }<br>    // Transfer tokens on behalf of another address<br>    function transferFrom(address from, address to, uint256 value) public returns (bool) {<br>        require(balanceOf[from] &gt;= value, &quot;Insufficient balance&quot;);<br>        require(allowance[from][msg.sender] &gt;= value, &quot;Allowance exceeded&quot;);<br>        balanceOf[from] -= value;<br>        balanceOf[to] += value;<br>        allowance[from][msg.sender] -= value;<br>        emit Transfer(from, to, value);<br>        return true;<br>    }<br>    // Mint synthetic tokens by locking ETH as collateral<br>    function mint(uint256 amount) public payable {<br>        uint256 requiredCollateral = (amount * collateralRatio) / 100;<br>        require(msg.value &gt;= requiredCollateral, &quot;Insufficient collateral&quot;);<br>        collateral[msg.sender] += msg.value;<br>        balanceOf[msg.sender] += amount;<br>        totalSupply += amount;<br>        collateralLocked += msg.value;<br>        emit Mint(msg.sender, amount, msg.value);<br>    }<br>    // Burn synthetic tokens and withdraw collateral<br>    function burn(uint256 amount) public {<br>        require(balanceOf[msg.sender] &gt;= amount, &quot;Insufficient token balance&quot;);<br>        uint256 collateralToReturn = (amount * collateralRatio) / 100;<br>        require(collateral[msg.sender] &gt;= collateralToReturn, &quot;Insufficient collateral locked&quot;);<br>        balanceOf[msg.sender] -= amount;<br>        totalSupply -= amount;<br>        collateral[msg.sender] -= collateralToReturn;<br>        collateralLocked -= collateralToReturn;<br>        payable(msg.sender).transfer(collateralToReturn);<br>        emit Burn(msg.sender, amount, collateralToReturn);<br>    }<br>    // Fallback function to handle ETH sent directly to the contract<br>    fallback() external payable {}<br>    receive() external payable {}<br>}</pre><p>Users lock ETH as collateral, and the contract mints synthetic tokens (SAT) for them. The required collateral is 200% of the token&#39;s value (adjustable by modifying collateralRatio). Users can burn their synthetic tokens to reclaim the collateral they locked. The contract also supports ERC-20 functions like transfer, approve, and transferFrom.</p><blockquote><em>Please note that this smart contract is for understanding need only and not to be used in real production use-case. It needs to have further price oracles, liquidation and governance models included for that, not to mention security.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ILIutlCZMLZxOJ5U.jpg" /></figure><p>As exciting as synthetic asset tokens are, they come with significant security concerns. Since these tokens are entirely reliant on blockchain technology and smart contracts, their safety depends on the robustness of the underlying code and ecosystem.</p><h3>Smart Contract Vulnerabilities</h3><p>Smart contracts are immutable once deployed, meaning any bug in the code can be catastrophic. Hackers can exploit vulnerabilities to drain collateral, mint unauthorized tokens, or manipulate token behavior.</p><p><strong>Example</strong>: The 2020 <em>bZx protocol</em> exploit resulted in losses of millions due to flaws in its smart contract logic.</p><h4>Price Oracle Manipulation</h4><p>Synthetic tokens rely on price oracles to mirror the value of real-world assets. If an oracle is compromised or manipulated, the synthetic token’s value could diverge drastically, leading to losses for users.</p><p><strong>Example</strong>: In 2022, several DeFi platforms experienced oracle attacks where attackers manipulated prices to profit from undercollateralized positions.</p><h4>Collateral Risks</h4><p>Synthetic tokens require collateral backing to maintain trust and stability. If collateral values drop suddenly (e.g., during a market crash), the synthetic asset system could become undercollateralized, leading to insolvency and loss of funds.</p><h4>Rug Pulls and Governance Exploits</h4><p>In decentralized systems, malicious actors could take over governance (via token voting) and implement changes that siphon funds or destroy the ecosystem.</p><h4>Regulatory Compliance Risks</h4><p>Since synthetic tokens mimic traditional assets, they often blur the line between DeFi and traditional finance. Regulatory bodies like the SEC in the U.S. or the RBI in India could impose restrictions or fines on platforms operating without compliance.</p><p>Governance is essential to ensure the stability, transparency, and adaptability of synthetic asset platforms. Without proper governance, these systems can devolve into chaos, whether through technical issues, regulatory non-compliance, or community mismanagement.</p><ol><li><strong>Updating Parameters</strong>: Adjusting collateral ratios, fees, and system rules in response to market conditions.</li><li><strong>Security Audits</strong>: Funding regular audits to identify and patch vulnerabilities.</li><li><strong>Price Oracle Management</strong>: Ensuring that oracles used for price feeds are reliable, decentralized, and tamper-proof.</li><li><strong>Emergency Response</strong>: Providing mechanisms to pause or roll back operations during unexpected attacks or exploits.</li><li><strong>Regulatory Compliance</strong>: Proactively adapting to legal requirements, such as Know Your Customer (KYC) and Anti-Money Laundering (AML) measures.</li></ol><p>We can infact learn a lot from traditional financial governance as they’ve gone through similar states involving synthetic assets or derivatives.</p><ol><li><strong>SEC’s Role</strong>: In traditional finance, the U.S. SEC (Securities and Exchange Commission) enforces regulations that protect investors, ensure market fairness, and penalize fraud. Synthetic token platforms could learn from the SEC’s stringent oversight of derivatives and securities markets to build trust.</li><li><strong>RBI’s Approach</strong>: The Reserve Bank of India oversees monetary policy and ensures that banks maintain sufficient reserves. Similarly, synthetic token platforms need to enforce collateralization rules to prevent insolvency.</li></ol><p>Many synthetic token projects already implement decentralized governance models, where token holders vote on key decisions. However, these systems need to balance decentralization with expertise; relying solely on token holders without checks can lead to uninformed or malicious decisions.</p><p>In decentralized synthetic asset markets, reputation will be a key differentiator. Fund managers with strong track records will likely attract more users, liquidity providers, and partnerships. However, reputation isn’t just a personal asset; it elevates the entire market by fostering trust and reducing skepticism about decentralized finance.</p><p>As the synthetic asset ecosystem grows, we will be introducing decentralized reputation scoring systems in NFTy, think “on-chain LinkedIn for fund managers”. Reputation could become a tradable asset in itself, shaping the future of decentralized markets just as much as the assets being tokenized. We can cover more on building reputation later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*qJg6519jheik9sC5.png" /></figure><p>Synthetic asset tokens are still in their early days, and the use cases we’re seeing are just the tip of the iceberg. What could the future hold?</p><ul><li><strong>Tokenized Real Estate</strong>: Imagine investing in synthetic tokens representing global real estate markets, all from your phone.</li><li><strong>Synthetic ESG Assets</strong>: Tokens tied to sustainability indices or carbon credits could attract socially conscious investors.</li><li><strong>Custom Market Creation</strong>: Want a token that tracks the value of “most streamed artists on Spotify”? With synthetics, you can create it.</li></ul><p>What we can say for sure is that Synthetic asset tokens are more than just a trend. They’re a fundamental shift in how we think about ownership, liquidity, and financial accessibility. The big question isn’t just <em>what can we do with synthetics now?</em> but rather <em>what haven’t we thought of them yet?</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d54443b904b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How does Chain Abstraction work?]]></title>
            <link>https://medium.com/@anistark/how-does-chain-abstraction-work-f12069cc232e?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/f12069cc232e</guid>
            <category><![CDATA[chain-abstraction]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[interoperabiliity]]></category>
            <category><![CDATA[bridge]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Tue, 21 Jan 2025 08:42:03 GMT</pubDate>
            <atom:updated>2025-01-21T08:42:03.359Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dK7VKX-oZ0cNQB6pWP99HA.jpeg" /></figure><blockquote><em>If you’re looking to learn about the basics about Chain Abstraction, then read </em><a href="https://blog.anirudha.dev/chain-abstraction"><em>this article</em></a><em> instead.</em></blockquote><p>Technically speaking, chain abstraction means abstracting away the differences between blockchain networks to provide a seamless experience. The goal is to:</p><ol><li><strong>Simplify User Interaction:</strong> Make it easy for users to interact with apps without worrying about which chain they’re on.</li><li><strong>Enable Interoperability:</strong> Allow assets, data, and actions to move freely between chains.</li><li><strong>Reduce Complexity for Developers:</strong> Provide unified tools and APIs to build cross-chain applications.</li></ol><p>To achieve chain abstraction, several tools and mechanisms come into play.</p><h3>Cross-Chain Bridges</h3><p>Bridges connect different blockchains, enabling the transfer of assets and data between them. Think of them as digital highways. For example, if you want to move your tokens from Ethereum to Binance Smart Chain, a bridge handles the heavy lifting.</p><ul><li>You lock your tokens on the source chain (e.g., Ethereum).</li><li>The bridge mints an equivalent amount of tokens on the destination chain (e.g., Binance Smart Chain).</li><li>When you want to reverse the process, the tokens on the destination chain are burned, and the original tokens are unlocked.</li></ul><h3>Swaps and Liquidity Protocols</h3><p>Swapping tokens across chains often requires decentralized exchanges (DEXs) or protocols like <a href="https://app.uniswap.org/">Uniswap</a> and <a href="https://www.sushi.com/ethereum/swap">SushiSwap</a>. Some advanced protocols like <a href="https://thorchain.org/">Thorchain</a> take it a step further by supporting native cross-chain swaps without wrapping tokens.</p><ul><li>Liquidity pools on different chains allow you to trade one token for another.</li><li>Cross-chain swap protocols use bridges under the hood to move assets while maintaining a smooth experience.</li></ul><h3>Interoperability Protocols</h3><p>Protocols like <a href="https://polkadot.com/">Polkadot</a> and <a href="https://cosmos.network/">Cosmos</a> focus on making blockchains inherently interoperable. They create ecosystems where chains can share data and assets natively.</p><ul><li><strong>Relay Chains:</strong> Central hubs that coordinate communication between connected blockchains.</li><li><strong>IBC (Inter-Blockchain Communication):</strong> A protocol standard used in Cosmos to let chains talk to each other securely. All contracts follow the <a href="https://github.com/cosmos/ibc">Interchain Standards (ICS)</a> for the Cosmos network &amp; interchain ecosystem.</li></ul><h3>Universal Wallets</h3><p>Tools like <a href="https://particle.network/">Particle Network</a> enable universal account wallets that work across multiple chains. Instead of manually switching between networks, these wallets auto-detect and handle transactions on the right chain.</p><ul><li>Chain detection and configuration happen automatically.</li><li>Transactions are routed to the correct blockchain without user intervention.</li></ul><h3>RPC Aggregators</h3><p>Remote Procedure Call (RPC) endpoints are gateways to blockchains. Aggregators like Alchemy and Infura provide a unified interface to interact with multiple blockchains, abstracting away the need to set up individual endpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9ThGSR3yv4Xn2pBk.png" /></figure><p>Chain abstraction is the backbone of many user-friendly crypto applications. Lets see a few examples:</p><p>Imagine you’re using a decentralized finance app to swap Ethereum (ETH) for Binance Coin (BNB). Here’s what it looks like from your perspective:</p><ol><li>You open the app and select ETH as the token to swap.</li><li>You choose BNB as the token to receive.</li><li>You click “Swap” and confirm the transaction.</li></ol><p>From your perspective, it’s a one-click process. Behind the scenes, multiple tools work together to make it seamless.</p><ol><li>The app detects that ETH is on Ethereum and BNB is on Binance Smart Chain.</li><li>A cross-chain bridge locks your ETH on Ethereum and creates a wrapped version on Binance Smart Chain.</li><li>The app uses a liquidity pool to exchange the wrapped ETH for BNB.</li><li>Finally, the app transfers BNB to your wallet on Binance Smart Chain.</li></ol><p>Here’s a simple Solidity contract for locking tokens on Ethereum and emitting an event to notify a bridge:</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract TokenLock {<br>    event TokenLocked(address indexed user, uint256 amount, string destinationChain);<br>    mapping(address =&gt; uint256) public lockedBalances;<br>    function lockTokens(uint256 amount, string memory destinationChain) external {<br>        require(amount &gt; 0, &quot;Amount must be greater than 0&quot;);<br>        // Simulate token lock (e.g., ERC20 transfer to contract)<br>        lockedBalances[msg.sender] += amount;<br>        // Emit event for bridge to pick up<br>        emit TokenLocked(msg.sender, amount, destinationChain);<br>    }<br>}</pre><p>This contract locks tokens on Ethereum and emits an event. A bridge service listens to the event and handles minting on the destination chain.</p><p>Lets take another example. Imagine you own an NFT on Ethereum but want to sell it on a Solana-based marketplace. Chain abstraction allows this by bridging the NFT to Solana while ensuring its metadata and ownership history remain intact.</p><ol><li>The NFT is locked on Ethereum, and a wrapped version is created on Solana.</li><li>The marketplace interacts with the Solana version, displaying it as if it were native to Solana.</li><li>When the NFT is sold, the buyer can choose to keep it on Solana or transfer it back to Ethereum.</li></ol><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>import &quot;@openzeppelin/contracts/token/ERC721/IERC721.sol&quot;;<br>contract NFTBridge {<br>    event NFTLocked(address indexed user, uint256 tokenId, string destinationChain);<br>    IERC721 public nftContract;<br>    constructor(address _nftContract) {<br>        nftContract = IERC721(_nftContract);<br>    }<br>    function lockNFT(uint256 tokenId, string memory destinationChain) external {<br>        require(nftContract.ownerOf(tokenId) == msg.sender, &quot;Not the owner&quot;);<br>        // Transfer the NFT to the bridge contract<br>        nftContract.transferFrom(msg.sender, address(this), tokenId);<br>        // Emit event for bridge service<br>        emit NFTLocked(msg.sender, tokenId, destinationChain);<br>    }<br>}</pre><p>In this example, the contract locks an NFT and emits an event. The bridge then handles minting the wrapped NFT on the target chain.</p><p>How about EVM to Cosmos perhaps?</p><p>Here’s an example illustrating how a smart contract on Ethereum can interact with a Cosmos chain using IBC:</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract EVMToCosmosBridge {<br>    event TokenSentToCosmos(address indexed sender, uint256 amount, string cosmosAddress);<br>    mapping(address =&gt; uint256) public balances;<br>    function sendToCosmos(uint256 amount, string memory cosmosAddress) external {<br>        require(amount &gt; 0, &quot;Amount must be greater than 0&quot;);<br>        // Simulate token lock (e.g., ERC20 transfer to contract)<br>        balances[msg.sender] += amount;<br>        // Emit event for Cosmos chain to pick up<br>        emit TokenSentToCosmos(msg.sender, amount, cosmosAddress);<br>    }<br>}</pre><p>This contract locks tokens on Ethereum and emits an event for an IBC-compatible relayer to transfer the equivalent tokens to a Cosmos chain.</p><p>On the Cosmos side, a module listens for IBC events and handles incoming tokens:</p><pre>package tokenbridge<br><br>import (<br>    &quot;github.com/cosmos/cosmos-sdk/types&quot;<br>    &quot;github.com/cosmos/ibc-go/modules/core/04-channel/types&quot;<br>)<br>func HandleTokenTransfer(ctx sdk.Context, msg types.MsgRecvPacket) error {<br>    // Decode the packet<br>    var data TokenTransferPacketData<br>    if err := json.Unmarshal(msg.Packet.Data, &amp;data); err != nil {<br>        return err<br>    }<br>    // Mint the tokens for the recipient<br>    recipient := sdk.AccAddress(data.Recipient)<br>    amount := sdk.NewCoin(data.Denom, sdk.NewInt(data.Amount))<br>    if err := MintTokens(ctx, recipient, amount); err != nil {<br>        return err<br>    }<br>    return nil<br>}<br>func MintTokens(ctx sdk.Context, recipient sdk.AccAddress, amount sdk.Coin) error {<br>    // Use the bank module to mint and send tokens<br>    bankKeeper := GetBankKeeper()<br>    return bankKeeper.MintCoins(ctx, ModuleName, sdk.NewCoins(amount))<br>}</pre><p>This Cosmos module listens for incoming IBC packets, decodes the token transfer details, and mints tokens to the recipient’s address. It complements the Ethereum-side contract to complete the abstraction.</p><p>Now, since blockchains are inherently siloed networks, they ideally wouldn’t know to even listen each other. That’s where the bridges and other tools come in. Even with bridges, potential limitations still exists. If the cross-chain bridge experiences congestion, your transaction might be delayed. Additionally, if there’s insufficient liquidity in the liquidity pool for the target token, you might get unfavorable rates or the swap could fail entirely. Lastly, any issues with the smart contracts underlying the bridge or pool could result in transaction errors or delays.<br>Despite these risks, robust protocols and fallback mechanisms are constantly evolving to mitigate such problems. Scalability can also become a bottleneck as the number of connected chains increases, requiring more resources to maintain performance. Security is another concern, as cross-chain communication introduces additional attack surfaces, such as vulnerabilities in the relay chains or the Inter-Blockchain Communication (IBC) protocol. Addressing these issues is critical for achieving robust and secure interoperability.</p><p><em>There’s a long way to go to achieve true chain abstraction, but we’re on the way already…</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f12069cc232e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chain Abstraction]]></title>
            <link>https://medium.com/@anistark/chain-abstraction-88405d11c083?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/88405d11c083</guid>
            <category><![CDATA[chain-abstraction]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[interoperability]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Wed, 15 Jan 2025 16:16:55 GMT</pubDate>
            <atom:updated>2025-01-15T16:16:55.758Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PlYqcaXiwuaPP_lGXJH22w.jpeg" /></figure><p>Say you want to make an online payment, and instead of just clicking a button, you have to figure out whether the store accepts Visa, Mastercard, or PayPal. Now multiply that headache by 100x, and you’ve got the current state of blockchains. This is where <strong>chain abstraction</strong> steps in — the fintech equivalent of a universal payment processor but for blockchains. It makes the Web3 world less about mind-numbing details and more about getting stuff done.</p><p>Let’s dive into what chain abstraction is, why it’s the hero we need, and how you can build cool things around it.</p><h3>What Is Chain Abstraction Anyway?</h3><p>Imagine using Venmo, Apple Pay, or Google Pay without worrying about how they talk to your bank or credit card. That’s chain abstraction for blockchains. It’s all about hiding the complex, nerdy stuff like gas fees, token standards, and wallet types so users and developers can focus on what matters: <em>buying that damn mocha</em>.</p><p>It makes interacting with blockchains feel less like coding in the Matrix and more like using Spotify. In short, it’s the magic trick that lets blockchains talk to each other and work together seamlessly.</p><h3>Why Do We Even Need This?</h3><p>Blockchains are amazing, but let’s be real: they’re a pain to use. Each chain has its quirks, its rules, and its own language. For instance:</p><ul><li><strong>Ethereum</strong> makes you worry about gas fees.</li><li><strong>Solana</strong> dazzles you with speed but has its own wallet ecosystem.</li><li><strong>Binance Smart Chain</strong> screams, “Hey, we’re cheap!” but you still have to bridge assets manually.</li></ul><p>Imagine if every payment app required you to know the bank’s internal workings. You’d delete them in a heartbeat. That’s why we need chain abstraction to fix these headaches:</p><p><strong>Simplified User Experience</strong><br>You don’t care which blockchain an app is on. You just want to use it without Googling, “How to send tokens from Polygon to Arbitrum.”</p><p><strong>More Collaboration, Less Competition</strong><br>Developers can focus on innovation instead of building the same tools for every blockchain.</p><p><strong>Onboarding for the Masses</strong><br>Your grandma won’t care about gas fees or token bridges, but she might use Web3 if it’s as easy as buying something on Amazon.</p><p>Think of chain abstraction as turning a messy fintech system into a unified, user-friendly experience:</p><ul><li><strong>No More Wallet Chaos</strong>: Whether it’s MetaMask, Phantom, or Keplr, users can use one interface to access all their assets.</li><li><strong>Universal Gas Fees</strong>: Users pay with whatever tokens they have, instead of scrambling to swap for ETH, SOL, or MATIC.</li><li><strong>Cross-Chain Transactions Made Easy</strong>: Think of it as a blockchain version of Wise for international transfers, but instant and decentralized.</li></ul><p>Several blockchain superheroes are already working on this:</p><p><strong>LayerZero</strong>: The omnichain messaging protocol. Think WhatsApp but for blockchains.</p><p><strong>Cosmos (IBC)</strong>: The OG of chain abstraction, letting blockchains chat like old friends.</p><p><strong>Axelar Network</strong>: Focused on secure cross-chain communication. Think of it as a blockchain VPN.</p><p><strong>Polkadot</strong>: Parachains make interoperability look easy, kinda like how Apple devices magically sync.</p><p><strong>Superfluid</strong>: Abstracts token standards for seamless asset streaming across different chains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jd6WhR2mOPBw4Wpc.png" /></figure><h3>How Does It Work?</h3><p>Chain abstraction operates like the middleware in your favorite fintech app.</p><ul><li><strong>Middleware Layers</strong>: Like Stripe for payments, middleware abstracts the complexity of multi-chain interactions.</li><li><strong>Universal Wallets</strong>: These wallets hide the “What chain are you on?” question.</li><li><strong>Gas Fee Abstraction</strong>: Imagine paying transaction fees in whatever token you like. No more “insufficient ETH” pop-ups.</li></ul><h3>So, How to Build on Chain Abstraction</h3><p>If you’re a builder looking to jump in, here’s your cheat sheet:</p><h4>Understand the Ecosystem</h4><p>Spend time with protocols like LayerZero, Cosmos, and Axelar. They’re like the Lego sets for chain abstraction.</p><h4>Keep Security in Mind</h4><p>Cross-chain means more doors to lock. Study cryptographic techniques and get comfy with audits.</p><h4>Use Dev-Friendly Tools</h4><p>Tools like Axelar SDK or Ethereum’s EIP-4337 are your best friends. Don’t reinvent the wheel.</p><h4>Think Like a Fintech Startup</h4><p>Build for scalability and usability. If your app isn’t grandma-friendly, try again.</p><h3>Some Cool Ideas to Build</h3><p>Here are some project ideas to flex your developer muscles:</p><ol><li><strong>Cross-Chain DeFi Superapp</strong><br>Think Revolut, but for DeFi. Let users swap, lend, and stake across chains in one interface.</li><li><strong>Gasless Transactions dApp</strong><br>Let users pay fees in their favorite token or abstract gas fees entirely.</li><li><strong>Blockchain Expedia</strong><br>Aggregate dApps across chains so users can search for services like booking flights or investing, without worrying about chains.</li></ol><blockquote><em>Chain abstraction is like the UPI (Unified Payments Interface) of the blockchain world. It’s making blockchains talk to each other, play well together, and be user-friendly for everyone. If Web3 is ever going to rival fintech giants like PayPal or Stripe, this is the way forward.</em></blockquote><p>Developers, this is your moment. Start building tools that make blockchains boring in the best way where the tech just works, and users don’t even notice the chains under the hood. At DripVerse, this is going to be the next frontier to build on. Keep an eye out folks…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88405d11c083" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On-Chain Shared State]]></title>
            <link>https://medium.com/@anistark/on-chain-shared-state-9f2bdf6ff81a?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f2bdf6ff81a</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[shared-state]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[onchain]]></category>
            <category><![CDATA[eip]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Thu, 23 May 2024 20:55:42 GMT</pubDate>
            <atom:updated>2024-05-23T20:55:42.536Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zC1JSf4VYLfuFW6AfyzpjQ.png" /></figure><p>Communication is a key in any ecosystem. Now with more cross-chain communication getting sorted using bridges, it’s high time to sort on-chain communications as well. Particularly, referencing of composable smart contract functionalities within the same chain.</p><h3>On-Chain Immutability</h3><p>Blockchains in general are isolated networks. Smart contracts are even further isolated in the network given that they record data that are immutable. Any update to their state records a new transaction cumulatively records the updated state. This is known and also creates a historical trail for later review and audit. There’s no problem is this process expect it’s not possible to update the smart contract code itself.</p><p><em>I’ve always believe learning by example is best.</em> Let’s take a look at the usage of ownerOf from IERC721 interface and how it&#39;s used to check token ownership for any NFT.</p><p>First we import via openzepplin package or you can write your own packaged contract import &quot;@openzeppelin/contracts/token/ERC721/ERC721.sol&quot; . Or if you really want to write your own ERC721 contract, start with importing the interface IERC721 to your contract: import &quot;./IERC721.sol&quot; .</p><p>The IERC721.sol contains the function definition:</p><pre>function ownerOf(uint256 tokenId) external view returns (address owner);</pre><p>And in ERC721.sol you can find the first override for it as such:</p><pre>function ownerOf(uint256 tokenId) public view virtual override returns (address) {<br>        address owner = _ownerOf(tokenId);<br>        require(owner != address(0), &quot;ERC721: invalid token ID&quot;);<br>        return owner;<br>}</pre><p>The function in itself is pretty straightforward. It takes tokenId as input and returns the owner address.</p><p>To understand this further, it’s all stored in a mapping:</p><pre>mapping(uint256 =&gt; address) private _owners;</pre><p>Anyway, regardless of the implementation, this is industry standard at the moment. If in case you’d want to add some conditions or enhance this function in your own contract, you’d need to override this further.</p><h3>Overriden</h3><p>Say we want to check for temporary ownership, like a rental ownership, which is time bound. We can not edit the original mapping of course. There’s 2 ways:</p><ol><li>We add a separate mapping only for the mapping of tokenId and owner to a timestamp.</li><li>We ignore _owners mapping and write our own mapping replacing it. We&#39;ll go with this option cause adding and reading from multiple memory storages will be costlier than having a rogue mapping lying around.</li></ol><p>Let’s call our new mapping as _ownership:</p><pre>struct Owner { <br>   address account;<br>   uint256 expiry;<br>}<br>mapping(uint256 =&gt; Owner) private _ownership;</pre><p>Now, we can map the ownership in this accordingly. But we also need to override our ownerOf function:</p><pre>function ownerOf(uint256 tokenId) public view virtual override returns (address, expiry) {<br>        Owner _owner = _ownership(tokenId);<br>        require(_owner.account != address(0), &quot;ERC721: invalid token ID&quot;);<br>        require(_owner.expiry &gt; block.timestamp, &quot;Ownership Expired. No current owner found.&quot;);<br>        return _owner.account;<br>}</pre><p>Here, we’re doing a few things. First, we’re checking if the owner account exists and expiry is anytime beyond current block timestamp.</p><p>Great, now our existing function ownerOf can serve as the modified version of the existing owner check. So, all the clients can now call this new function of contract and get timestamp enabled ownership check.</p><p>However, here’s where things get interesting…</p><h3>Imported Smart Contracts</h3><p>The problem in above way is that we would need to burn all tokens from old smart contract and re-mint in new one in order for them to enable expiry in ownership. Which would lead to losing all history of the said tokens. So, how do we deal with this?</p><p>Solidity supports importing another smart contract and referring to the functions of it as we established above. We usually use it to extend functionality. For example, we want to add a function to our previous contract which checks ownerOf and rewards a certain amount to them. So, we first need to define it:</p><pre>import &quot;@openzeppelin/contracts/token/ERC20/IERC20.sol&quot;;<br>// other code bits<br><br>IERC20 token;<br>// ...<br><br>token = IERC20(token_address);</pre><p>Now, in above, token represents our token from previous contract which is imported based on token_address. So, we should be able to do something like token.ownerOf(tokenId) to get the owner of tokenId as shown above. Once we get it, let&#39;s say we want to do something like owner_address.send(value) where value is in base token of the chain. This is the most commonly used way to use an external contract. But what would happen if you&#39;re to extend an existing function of original contract?</p><p>Let’s take our previous example. We want to add expiry to ownerOf. So, we write a new smart contract and a new function to check ownership. Cause we can&#39;t override a function of a different contract. We&#39;ve a new function which can have same name even. But for the sake of sanity, let&#39;s use a different name, newOwner() and it looks something like:</p><pre>contract RentContract {<br>    struct Owner { <br>       address account;<br>       uint256 expiry;<br>    }<br>    mapping(uint256 =&gt; Owner) private _ownership;<br><br>    function newOwner(uint256 tokenId, address _to, uint256 _expiry) external virtual {<br>        _ownership[tokenId].account = _to;<br>        _ownership[tokenId].expiry = _expiry;<br>    }<br>    // ...<br>}</pre><p>So, what’s happening here is overloading (<em>not really since we’re using a different name for the function. But from a standard perspective, let’s assume it’s the same</em>) which means we’ve defined a second function and mapping to do the exact same thing which is already been done in previous contract where it’s been imported from. This obviously is a waste of memory on-chain but let’s leave that concern for later. So, now, we’ve a second contract, RentContract which has temporary ownership function which we can use. However, what about the client apps which is already pointed to the old contract? The token ownership does not show any changes regardless to whoever else it&#39;s rented out via the RentContract .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sWsxVZqRxXaLWkEU" /></figure><h3>Shared State</h3><p>Here’s where the concept of Shared State comes in. Here’s to proposing a shared state system which allows to update the state of original contract if the same state is being dealt with on an extended contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MqhOz1xqDTEm87mu" /></figure><p>So, once this new system is in place, we should be able to reflect the updated state back to our original state thereby retaining backwards compatibility as well as history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1162GJlx4eYb-5mm" /></figure><p>This is the next evolution in smart contract standards which will help with better backwards compatible DApps and protocols.</p><p><em>LFG</em></p><p><a href="https://blog.anirudha.dev/on-chain-shared-state\">Originally posted here.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f2bdf6ff81a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is NFT?]]></title>
            <link>https://medium.com/@anistark/what-is-nft-fff2ee08fbd3?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/fff2ee08fbd3</guid>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[marketplaces]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[web3]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Mon, 27 Sep 2021 09:01:20 GMT</pubDate>
            <atom:updated>2021-09-27T09:01:20.315Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1BuHFzqau5hJ_EOHhMy4YQ.png" /></figure><p>NFT or Non-Fungible Token, is the latest in the long line of jargon that you might be hearing a lot about recently. So, why should you care and what is it even? Let’s try to understand the origin and thereby the hype around it.</p><p>A digital token is just another piece of a smart contract code that’s running somewhere on a particular blockchain. When cryptocurrency came out and everybody started issuing their tokens, we saw a meteoric rise to Digital Tokens or CryptoCurrencies in the form of ICOs (Initial Coin Offerings) that every other project was really into at the time. Most used CryptoCurrencies came on the more popular decentralised networks like Ethereum, in the form of ERC-20s. This gave a widespread knowledge around what cryptocurrencies are and ERC-20 became a common term to be used in analogous to digital tokens wherever specified. However, several improvements on specific use-cases kept happening over time. These improvements are usually referred to as <a href="https://eips.ethereum.org/erc">EIPs(Ethereum Improvement Proposals)</a>.</p><p>One of the most sought after use-cases was ERC-721 or deeds or as more commonly known as Non-Fungible Tokens. NFTs can represent ownership over digital or physical assets. It’s obviously not a new concept. It’s been around since 2014.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*5vKJKlEn6_DK62aM" /></figure><ul><li>Physical property — houses, unique artwork</li><li>Virtual collectables — unique pictures of kittens, collectable cards</li><li>“Negative value” assets — loans, burdens, and other responsibilities In general, all houses are distinct and no two kittens are alike. NFTs are distinguishable and you must track the ownership of each one separately.</li></ul><p>This by itself doesn’t really mean much but when you really think about it, we already have an extremely large scale demand for such unique items. From collectible cards, items, and luxury antiques, our lives revolve around uniqueness. The more unique an item, the more valuable it becomes. It’s the very core of how our economics work and how every valuable item is identified. Now, with ERC-721, we got a way to represent it online and have a very simple way to buy and sell such assets. Of course, it comes with its own set of problems like enormous gas fees which one has to pay for networks like Ethereum. Makes it almost impossible to acquire one or more of these very special NFTs for normal people. The NFT market value tripled in 2020, reaching more than $250 million. During the first quarter of 2021, NFT sales exceeded $2 billion. Plagiarism is another big concern where a true digital identity solution can very well fix it. We’ll take all the issues and possible solutions in perhaps a separate post of its own. I feel it deserves a more in-depth analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/0*9hhP89FY2upsYkbn" /></figure><h3>Marketplaces</h3><h4><a href="https://opensea.io/">OpenSea</a></h4><p>As one of the most commonly referred NFT marketplaces, OpenSea has established it’s dominance in the space. You can practically buy or sell any type of NFT here. The process is as simplified as it can be.</p><h4><a href="https://www.binance.com/en/nft/home">Binance NFT</a></h4><p>Binance NFT Marketplace brings together artists, creators, and crypto enthusiasts on a single platform to create and trade top NFTs. The platform features 3 product lines:</p><ul><li>Events: Buy premium and exclusive NFTs created by global leading artists</li><li>Marketplace: Mint, purchase, and bid on NFTs from creators around the world</li><li>Mystery Box: Stand a chance to win rare NFTs in a box full of surprises</li></ul><h4><a href="https://crypto.com/nft/marketplace">Crypto.com NFT</a></h4><h4><a href="https://rarible.com/">Rarible</a></h4><h4><a href="https://foundation.app/">Foundation</a></h4><h4><a href="https://superrare.com/">SuperRare</a></h4><h4><a href="https://wax.atomicmarket.io/">Atomic Market</a></h4><h4><a href="https://myth.market/">Myth Market</a></h4><h4><a href="https://www.bakeryswap.org/#/home">BakerySwap</a></h4><h4><a href="https://axieinfinity.com/">Axie Marketplace</a></h4><h4><a href="https://knownorigin.io/">KnownOrigin</a></h4><h4><a href="https://makersplace.com/">MakersPlace</a></h4><h4><a href="https://solanart.io/">Solana Art</a></h4><h4><a href="https://nbatopshot.com/">NBA Top Shot</a></h4><h4><a href="https://async.art/">Async Art</a></h4><h4><a href="https://portion.io/">Portion</a></h4><h4><a href="https://enjin.io/products/marketplace">Enjin Marketplace</a></h4><h4><a href="https://www.bakeryswap.org/#/home">BakerySwap</a></h4><p>Even traditional art giants like <a href="https://www.christies.com/">Christies</a> are setting up shop around it can step into the modern age.</p><h3>Variations</h3><p>Over time, some variations of ERC-721 have emerged as well.</p><ul><li>ERC-1155 which offers semi-fungibility and works over a class of assets instead of particular assets.</li><li>FLOW blockchain provides proof-of-stake consensus. Mostly used by NBA Top Shot.</li><li>Tezos also works on a proof-of-stake based NFT.</li><li>Solana has also started supporting NFTs.</li></ul><h3>Create your own NFT</h3><p>A simpler way is to start using one or the platform above mentioned and get started with it. If you want to create your own marketplace or product as such, there’s always a way to do so.</p><ol><li>Select a DLT network on which you’d like to issue the NFTs on. Preferably one with less transaction fee.</li><li>Write an NFT smart contract or equivalent in that particular network. Here’s a good getting started point are in <a href="https://docs.openzeppelin.com/contracts/2.x/api/token/erc721">OpenZepplin Docs</a>.</li><li>Make sure there’s an easy interface because mind you, most of your users are really just everyday Joes who just want to purchase as an investment strategy.</li></ol><h3>So, what all can you use NFTs for?</h3><ul><li>Art</li><li>GIFs</li><li>Videos and sports highlights</li><li>Collectibles</li><li>Virtual avatars and video game skins</li><li>Designer sneakers</li><li>Music</li><li>Tweets</li><li>Github Commits</li></ul><p>Of course, be wary of where you’re buying these NFTs from. Are they authorised sources or someone broker marketplace who’s just selling via some other marketplace? Are they really the owner or authorised seller of the items. Are they backed by a reputable organisation or foundation? Which blockchain or DLT platform are they using and how much transaction fee is that purchase going to cost you? Also, make sure you’re aware of your country or state’s legalities and taxation procedures. NFTs are also subject to capital gain tax such as any stock you might own.</p><p><em>Originally Published at </em><a href="https://blog.anirudha.dev/what-is-nft"><em>https://blog.anirudha.dev/what-is-nft</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fff2ee08fbd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[To Go with Golang]]></title>
            <link>https://medium.com/@anistark/to-go-with-golang-4ea871c7dbbd?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ea871c7dbbd</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[getting-started]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Sat, 30 Jan 2021 11:08:12 GMT</pubDate>
            <atom:updated>2021-01-30T11:08:12.119Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DnnkReGamr7ps_2HlGT_FQ.png" /></figure><blockquote><em>Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.</em></blockquote><p>At least that’s how the website describes itself. The first time I tried golang was about 3 years ago as a hobby project. However lack of an implementation need and a busy work schedule made my side project obsolete. Of course, you would know what that feels like. Familiar territory. So, when the opportunity rose to write a new service in golang, I absolutely jumped at it.</p><p>I’m supposed to build a small web service accepting http connection and storing some data on mongodb. Returns a certain set of result, and so on. Basic CRUD stuff. If you’re not interested in #webdev, I believe this is your stop. If you’re interested however, read on to know about what I used and why. The entire dev cycle from dev to deploy phase.</p><p>First of all, why I opted for golang anyway? The service I’m supposed to write needs a highly concurrent persistent api service. It needs to be fast and also easily scalable. We could have gone with python fastapi, but at this stage I just wanted to learn golang.</p><h3>Setting up Golang</h3><p>If you’ve finally decided to go ahead with this, let’s do this. Easiest way probably is to just <a href="https://golang.org/doc/install">download from the official website</a> and get going. <a href="https://medium.com/golang-learn/quick-go-setup-guide-on-mac-os-x-956b327222b8">Here</a>’s another article which very nicely explains the setup process. This is ideally for mac OS. In case you’re looking for other OSes, please follow respective guides.</p><p>Be sure to setup your GOPATH very properly as this will remain as your common ground for any defined packages installed in your system.</p><p>Once done, make sure your console recognises the GOPATH. echo $GOPATH</p><h3>HTTP Service</h3><p>I went with <a href="https://github.com/valyala/fasthttp">fasthttp</a>, which provides high performance, zero memory allocations in hot paths and Up to 10x faster than net/http for a large throughput service. Go provides out of the box http support but for a beginner, it felt much easier to go with a framework, thereby ended up using fiber.</p><h3>API</h3><p><a href="https://github.com/gofiber/fiber">Fiber</a> is an Express inspired web framework built on top of Fasthttp, the fastest HTTP engine for Go. Make sure to use Fiber v2. Fiber V2 has a lot of breaking changes to Fiber v1. I had to spend an extra hour just upgrading these <a href="https://github.com/gofiber/fiber/issues/736">breaking changes</a> cause I started with v1.</p><p>A simple fiber service can be started using just this:</p><pre>package main</pre><pre>import &quot;github.com/gofiber/fiber/v2&quot;</pre><pre>func main() {<br>    app := fiber.New()</pre><pre>    app.Get(&quot;/&quot;, func(c *fiber.Ctx) error {<br>        return c.SendString(&quot;Hello, World 👋!&quot;)<br>    })</pre><pre>    app.Listen(&quot;:3000&quot;)<br>}</pre><p>You now have a live server running at your <a href="http://localhost:3000/">http://localhost:3000</a>.</p><h3>Connect to a DataBase</h3><p>Next, we need our web service to talk to our web-service. There are quite a few ODM(Object Document Mapper) out there. But given my initial requirement was pretty straightforward, I went the default <a href="https://github.com/mongodb/mongo-go-driver">mongodb golang driver</a>. It’s pretty straightforward to connect an mongodb client:</p><pre>client, err := mongo.Connect(ctx, options.Client().ApplyURI(&quot;mongodb://localhost:27017&quot;))</pre><p>So, now we got an active db connection going. Ideally, that’s all we would need to create the smallest possible POC(Proof Of Concept) of any web-service you can think of. Obviously, do go through the proper documentation as there are many pitfalls at every stage. Might as well address a few of those on a separate post.</p><p>However, to make a production level POC, we need a few more stuff. So, let’s discover a few add-ons to our service:</p><h3>Logging</h3><p>Logging is one of the most important aspects in any programming. To see what’s working and where has been the crux of any development really. We sometimes debug using our logs. Specially in production. The easiest and in-built way of printing/logging can be done using <a href="https://golang.org/pkg/fmt/">fmt</a> or <a href="https://golang.org/pkg/log/">log</a> packages. A small example:</p><pre>fmt.Print(&quot;Printing with fmt&quot;)</pre><pre>buf    bytes.Buffer<br>logger = log.New(&amp;buf, &quot;logger: &quot;, log.Lshortfile)<br>logger.Printf(&quot;Logging with log&quot;)</pre><p>The use log is highly encouraged as compared to fmt. Log is thread safe where as fmt is not. A Logger can be used simultaneously from multiple goroutines; it guarantees to serialize access to the Writer.</p><pre>log.Fatalf(&quot;Fatal err happened:&quot;, err)</pre><p>You can also add fatal logs if in case you would want to flag certain types of logs which might be critical to the application.</p><p>Some added advantages of using Fiber is it’s logging module. If you’re on v1, you would need to install the <a href="https://github.com/gofiber/logger">logger package</a> separately, but in v2 it has been made available within v2 itself: &quot;github.com/gofiber/fiber/v2/middleware/logger&quot;.</p><p>If you need to log each request as and when it comes in, you can add something like this:</p><pre>app.Use(requestid.New())</pre><pre>​app​.​Use​(​logger​.​New​(logger.​Config​{<br>	// For more options, see the Config section<br>  Format​: &quot;${pid} ${locals:requestid} ${status} - ${method} ${path}​\n​&quot;​,<br>}))</pre><p>Now, each route visited will come up on your console.</p><h3>Hot Reloading</h3><p>Golang is a compiled language, which means unlike Python or NodeJS which are interpreted languages, we need to build it everytime we would want to run it. Ideally we build the project as such: go build . And then we run it like: ./app-name.</p><p>However, we can still run the dev version as: go run main.go Or if there’s more than one file: go run *.go</p><p>But while development process, we often make changes and would want to check the output without having to restart the go server manually. You can obviously write your own small shell script to detect any file changes on the entire directory and restart go run everytime. If you’re using docker, you can also write the entire go build . and ./app-name process inside the container.</p><p>Needed a more robust way, which is provided by this package called fresh. <a href="https://github.com/gravityblast/fresh">Fresh</a> is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. You can also customise the log color that comes with the default fresh setup. It requires a default runner.conf file. If you want to go with the default options, you don’t even need this file on your project root.</p><pre>root:              .<br>tmp_path:          ./tmp<br>build_name:        runner-build<br>build_log:         runner-build-errors.log<br>valid_ext:         .go, .tpl, .tmpl, .html<br>no_rebuild_ext:    .tpl, .tmpl, .html<br>ignored:           assets, tmp<br>build_delay:       600<br>colors:            1<br>log_color_main:    cyan<br>log_color_build:   yellow<br>log_color_runner:  green<br>log_color_watcher: magenta<br>log_color_app:     blue</pre><p>Now we’ve a complete dev setup done and dusted.</p><h3>Routing</h3><p>I’m obsessed with structured code. Everything can be written in a single file and ran but a structured codebase, makes it all the more easier to document, read and later manage it. Thereby, routing is a crucial part of adopting a new framework. Fiber comes with inbuilt route grouping</p><pre>func main() {<br>    app := fiber.New()</pre><pre>    api := app.Group(&quot;/api&quot;, middleware) // /api</pre><pre>    v1 := api.Group(&quot;/v1&quot;, middleware)   // /api/v1<br>    v1.Get(&quot;/list&quot;, handler)             // /api/v1/list<br>    v1.Get(&quot;/user&quot;, handler)             // /api/v1/user</pre><pre>    v2 := api.Group(&quot;/v2&quot;, middleware)   // /api/v2<br>    v2.Get(&quot;/list&quot;, handler)             // /api/v2/list<br>    v2.Get(&quot;/user&quot;, handler)             // /api/v2/user</pre><pre>    app.Listen(&quot;:3000&quot;)<br>}</pre><p>This can help you in writing a more structured app as such you might need to authenticate only a particular group or log a particular route and so on.</p><h3>Deployment</h3><p>Probably best to go with a containerised deployment. We have deployed on <a href="https://cloud.google.com/kubernetes-engine">Kubernetes — Google Kubernetes Engine (GKE)</a> which only needs an additional Dockerfile.</p><p>It’s better to go with a multi-stage docker setup:</p><pre>FROM golang:1.12-alpine AS build_base</pre><pre>RUN apk add --no-cache git</pre><pre># Set the Current Working Directory inside the container<br>WORKDIR /tmp/go-sample-app</pre><pre># We want to populate the module cache based on the go.{mod,sum} files.<br>COPY go.mod .<br>COPY go.sum .</pre><pre>RUN go mod download</pre><pre>COPY . .</pre><pre># Unit tests<br>RUN CGO_ENABLED=0 go test -v</pre><pre># Build the Go app<br>RUN go build -o ./out/go-sample-app .</pre><pre># Start fresh from a smaller image<br>FROM alpine:3.9<br>RUN apk add ca-certificates</pre><pre>COPY --from=build_base /tmp/go-sample-app/out/go-sample-app /app/go-sample-app</pre><pre># This container exposes port 8080 to the outside world<br>EXPOSE 8080</pre><pre># Run the binary program produced by `go install`<br>CMD [&quot;/app/go-sample-app&quot;]</pre><p>A complete guide on dockerising your golang app can be found <a href="https://codefresh.io/docs/docs/learn-by-example/golang/golang-hello-world/">here</a> and <a href="https://www.docker.com/blog/containerize-your-go-developer-environment-part-1/">here</a>.</p><p>With this we’ve now a deployed version of our golang app. Connect that GKE ip to your preferred DNS provider and share the link. Feel free to leave a link of you first golang app in the comments. Would love to see what everyone is working on.</p><p>If you have a different view on some of the stack used or talked here, feel free to add your thoughts. We’re all learning and would love to see the more popular frameworks and best practices in use.</p><p>Cheers and until next time…</p><p><em>(Originally published </em><a href="https://blog.anirudha.dev/post/to-go-with-golang/"><em>here</em></a><em>)<br>Hope it was helpful and do let me know what else you would love reading more about.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ea871c7dbbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with Blockchain Development]]></title>
            <link>https://medium.com/blockchainedindia/getting-started-with-blockchain-development-5664aa3f2cf9?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/5664aa3f2cf9</guid>
            <category><![CDATA[getting-started]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[guidebook]]></category>
            <category><![CDATA[dlt]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Sat, 04 Jul 2020 11:33:59 GMT</pubDate>
            <atom:updated>2020-07-04T11:33:59.650Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*LvSeIS6S6_MR5b9ARjiGTA@2x.png" /></figure><p>About time you’ve heard about Blockchain and want to a dig into the development phases of it. <em>Respect that.</em> Though on your first few google searches you’ve probably got about a million of tutorials, articles and resources and now you’re just about on the verge of giving up on it and moving on. <em>Can’t blame you.</em> But before you gave up forever, you somehow seem to have stumbled across just about one more article and believe it or not, you’ve chosen wisely.</p><p>Clearly blockchain technology has lots to offer and way too many pathways to get started with. We’re going to take the journey from every possible way and hopefully, one of these would pick you right up from where you stand today.<br><em>Word of the wise, if you’re new to development in general and have no clue as to what blockchain is, we recommend to read a few introductory articles before coming back here.</em></p><blockquote>Blockchain is a decentralised network and a distributed database.</blockquote><p>It started off as being public only, with Bitcoin and Ethereum bringing up the names to the masses. Eventually, private blockchains like Hyperledger also gained traction given enterprises heavily adopting it throughout their processes. Now, there’s all sorts of classifications based on data structure or how consensus is formed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*j6DZ2kmypPkEJs-wGmepMg.png" /><figcaption>Here’s a brief overview on the classification based on the architecture of the blockchain.</figcaption></figure><p>So, where to get started from? Well, that largely depends on your area of interest really. Here’s a few areas to get started with:</p><h3>Smart Contract Development</h3><p>If you’re a programmer, this is one of the easiest to get started with. Smart Contracts are just pieces of codes that run on the blockchain. In that way, we can classify a Hello World program also as smart contract. Of course, it’s neither smart not a contract in this case.</p><blockquote>“A smart contract is a set of promises, specified in digital form, including protocols within which the parties perform on these promises.”</blockquote><blockquote>— Nick Szabo</blockquote><p>Every blockchain has it’s own language or syntax to write smart contract on. Ethereum uses Solidity, Hyperledger uses Chaincode, Cardano uses Plutus, Aion uses Java and so on.</p><p>Here’s an example smart contract in Solidity. This is a simple smart contract designed to store a certain value, in this case, storedData.</p><pre>pragma solidity ^0.4.0;</pre><pre>contract SimpleStorage {<br>    uint storedData;<br>    function set(uint x) public {<br>        storedData = x;<br>    }<br>    function get() public constant returns (uint) {<br>        return storedData;<br>    }<br>}</pre><p>There are two functions, set() and get(). get() will get whatever value is stored and set() takes a parameter x and stores it in the blockchain.<br>Pretty straightforward, right?</p><p>Here’s a more complex one:</p><pre>pragma solidity ^0.4.19;</pre><pre>contract Escrow {</pre><pre>    address public buyer;<br>    address public seller;<br>    address public arbiter;<br>    address owner;</pre><pre>    function Escrow(address _seller, address _arbiter) {<br>        buyer = msg.sender;<br>        seller = _seller;<br>        arbiter = _arbiter;<br>    }</pre><pre>    modifier onlyOwner {<br>        require(msg.sender == owner);<br>        _;<br>    }</pre><pre>    function payoutToSeller() {<br>        if(msg.sender == buyer || msg.sender == arbiter) {<br>            seller.transfer(this.balance);<br>        }<br>    }</pre><pre>    function refundToBuyer() {<br>        if(msg.sender == seller || msg.sender == arbiter) {<br>            buyer.transfer(this.balance);<br>        }<br>    }</pre><pre>    function getBalance() constant returns (uint) {<br>        return this.balance;<br>    }</pre><pre>    function setSeller(address _seller) public {<br>        seller = _seller;<br>    }</pre><pre>    function setArbiter(address _arbiter) public {<br>        arbiter = _arbiter;<br>    }</pre><pre>    function getSeller() public constant returns (address) {<br>        return seller;<br>    }</pre><pre>    function getArbiter() public constant returns (address) {<br>        return arbiter;<br>    }</pre><pre>}</pre><p>This is an Escrow smart contract as the name suggests. We’ve defined a buyer, seller and an arbiter. The arbiter usually is the smart contract address itself, because the entire point of blockchain is to remove middlemen (or so they said). Learn more about <a href="https://blog.acycliclabs.com/posts/why-are-smart-contracts-so-important.html">smart contracts in this article</a>.</p><p>Ideally, we use smart contracts to write conditional statements which might help solve interoperability issues or accountability related stuff. But of course, if you just want to write a summation smart contract, that’s cool too.</p><h3>Consensus Algorithm</h3><p>So, once you know how to input and output data to blockchain, the next thing is to get the data transaction approved on chain.</p><blockquote>A consensus mechanism is a fault-tolerant mechanism that is used in computer and blockchain systems to achieve the necessary agreement on a single data value or a single state of the network among distributed processes or multi-agent systems.</blockquote><p>Consensus is important to maintain the decentralised nature of the network. Before data can be written to the distributed database, a given number of nodes/entities has to agree over the validity of the transaction. If majority agrees, the data is recorded, otherwise discarded.</p><p>There are several consensus mechanisms out there. Some of the popular ones are POW, POS, POA, etc. So, if you’re into deep algorithms and research, this is an extremely exciting work. Read more about various c<a href="https://blog.acycliclabs.com/posts/consensus-mechanisms-in-blockchain.html">onsensus mechanisms in blockchain here</a>.<br>If you see a new way to validate a transaction or data, by which you can achieve synchronicity and data sanity, that can be a possible consensus mechanism. Once you’ve formularised what it does, start working on how it does it. The mathematical algorithm basically. To define the proof that you just created. These sometimes takes years to formalise. Post it on popular cryptographic forums and seek contribution help from fellow mathematicians.</p><h3>Library Development</h3><p>If you are pretty advanced with programming languages and want to integrate your native language with smart contracts, then library development is the right place to get started with.</p><p>Since the smart contracts are usually in the blockchain’s native language, it’s very difficult for day-to-day work to transpile every single piece of code explicity and write a mirror code to execute the same. Most popular blockchains provide support for common languages like python, javascript, golang, etc.</p><p>Ethereum has <a href="https://github.com/ethereum/web3.js">web3.js</a> and <a href="https://github.com/ethereum/web3.py">web3.py</a> to help javascript and python developers easily interact with blockchain. You can start writing in your native language as well, for which the Ethereum Foundation might not have written already. Of course, if your library is good enough, they might ending up adding it to their official repo.</p><h3>Protocols Development</h3><p>Protocols form the base layer on top of which decentralised network work. There is vast range of protocols and we need to define our scope of work to which protocols we might be referring to.</p><p>Coming from traditional programming background, you must be aware of web protocols such as HTTP (Hypertext Transfer Protocol) or TCP/IP (Transmission Control Protocol/Internet Protocol). The idea with these protocols were to provide a governance layer or setup “some rules” over how and what type of data is transmitted. Similarly we can write our own protocols for the decentralised network about the way of transactions, the form data, mode of transmission, the duration of open channels and so on. Given the use-case, protocols can form the very base layer on top of which modern decentralised applications are built.</p><p>To develop protocols, you can start with writing simple stuff like and gradually write more complex logic. Some example protocols to get started with are listed here.<br>Develop a protocol for:</p><ol><li>End-to-end encrypted communication.</li><li>Interoperability amongst various blockchains.</li><li>Token exchange.</li><li>Track a product life-cycle.</li><li>Maintain user access</li></ol><p>..the list goes on. But now you have a general idea of where to get started with. Read more here about <a href="https://www.worth.com/understanding-protocol-wars-and-what-they-mean-for-blockchain/">protocols</a>.</p><h3>Network</h3><p>So, you’re coming from OS and Networking background. Since blockchain is a basic level decentralised network, it might be a great place to start.</p><p>You might recall some basic level network topologies such as star, mesh, ring, tree, bus, etc. Well, decentralised networks are not much different as far as network architecture goes on. Various blockchains have experimented with different forms of it at various levels to achieve desired results. The key idea is to have a secure connection amongst the nodes with least possible latency. A complete loss-less connection is still far fetched idea so you’ve a lot of places to contribute here.<br>Side chains sometimes form completely different topologies to achieve results at faster processing. Mostly though connects through a p2p network so there’s no brokers in between.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*r_z0P195PUcPiz7RkaCjkw.jpeg" /></figure><p>A good place to start with network development would be to read the whitepapers of various blockchains and figure out what everyone’s doing and probably you will able to plug in your thoughts in one or more of them to come up with something original. Do not be afraid to experiment.<br>IIT Kanpur, IIT Chennai, IISC Bengaluru have research centres working actively on this area where you can also join as research fellowship programs and complete your thesis. Our community platforms are also a good way to work with others researching around the same.</p><h3>Infrastructure</h3><p>You like infrastructure development. You’ve probably worked on micro-services and monoliths and now looking to find your place in blockchain ecosystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*SbjqBHnpwbbhpub4XNcd5Q.png" /></figure><p>Unlike traditional architecture, the infrastructure of decentralised system has nothing to do with the dapps at all. All your infra knowledge will be put together to work on node clusters to setup a robust scalable model of the decentralised network. Think about how you can run nodes from the largest of VMs or docker or kuberenetes setup to the smallest of microchips as an Arduino Uno or Raspberry Pi 2. Ideally, a blockchain database becomes way to large for a small Raspberry Pi to handle. But hey, that’s where your knowledge comes in. Think about how to make it work. IOTA is one the DLTs which nodes can run on Raspberry Pi. So, maybe figure out a way to design a lightweight node to make to run on Raspberry Pi? Who knows, you might crack it.</p><p>Another interesting arena in this regard is to play around with data storage infrastructures. Data storage is still over-blotted for a blockchain being linked list and all. Maybe experiment on how you can keep the same structural integrity and yet make it more scalable.</p><h3>Token Development/Crypto-Economics</h3><p>Tokens are a crucial part of public blockchains. So, if you’re planning to develop your application to run on a public blockchain, you might also would want to develop your own token.</p><p>You can obviously use the native token of the blockchain itself, such as Ethers if you’re using Ethereum blockchain, Lumens if you’re on Stellar blockchain and so on. But with your own token, you can control the output, exchange mechanisms, trade routes, use-cases, minting or creating new tokens rate, and several other factors. Ethereum offers a wide range of token standards to develop your tokens on. Most popular amongst which is ERC20.</p><p>This also involves a good understanding of smart contracts, but more focus would be on financial side. Here’s a sample ERC20 smart contract that you can study to get started with.</p><pre>// SPDX-License-Identifier: MIT</pre><pre>pragma solidity ^0.6.0;</pre><pre>import &quot;../../GSN/Context.sol&quot;;<br>import &quot;./IERC20.sol&quot;;<br>import &quot;../../math/SafeMath.sol&quot;;<br>import &quot;../../utils/Address.sol&quot;;</pre><pre>/**<br> * @dev Implementation of the {IERC20} interface.<br> *<br> * This implementation is agnostic to the way tokens are created. This means<br> * that a supply mechanism has to be added in a derived contract using {_mint}.<br> * For a generic mechanism see {ERC20PresetMinterPauser}.<br> *<br> * TIP: For a detailed writeup see our guide<br> * <a href="https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How">https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How</a><br> * to implement supply mechanisms].<br> *<br> * We have followed general OpenZeppelin guidelines: functions revert instead<br> * of returning `false` on failure. This behavior is nonetheless conventional<br> * and does not conflict with the expectations of ERC20 applications.<br> *<br> * Additionally, an {Approval} event is emitted on calls to {transferFrom}.<br> * This allows applications to reconstruct the allowance for all accounts just<br> * by listening to said events. Other implementations of the EIP may not emit<br> * these events, as it isn&#39;t required by the specification.<br> *<br> * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}<br> * functions have been added to mitigate the well-known issues around setting<br> * allowances. See {IERC20-approve}.<br> */<br>contract ERC20 is Context, IERC20 {<br>    using SafeMath for uint256;<br>    using Address for address;</pre><pre>    mapping (address =&gt; uint256) private _balances;</pre><pre>    mapping (address =&gt; mapping (address =&gt; uint256)) private _allowances;</pre><pre>    uint256 private _totalSupply;</pre><pre>    string private _name;<br>    string private _symbol;<br>    uint8 private _decimals;</pre><pre>    /**<br>     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with<br>     * a default value of 18.<br>     *<br>     * To select a different value for {decimals}, use {_setupDecimals}.<br>     *<br>     * All three of these values are immutable: they can only be set once during<br>     * construction.<br>     */<br>    constructor (string memory name, string memory symbol) public {<br>        _name = name;<br>        _symbol = symbol;<br>        _decimals = 18;<br>    }</pre><pre>    /**<br>     * @dev Returns the name of the token.<br>     */<br>    function name() public view returns (string memory) {<br>        return _name;<br>    }</pre><pre>    /**<br>     * @dev Returns the symbol of the token, usually a shorter version of the<br>     * name.<br>     */<br>    function symbol() public view returns (string memory) {<br>        return _symbol;<br>    }</pre><pre>    /**<br>     * @dev Returns the number of decimals used to get its user representation.<br>     * For example, if `decimals` equals `2`, a balance of `505` tokens should<br>     * be displayed to a user as `5,05` (`505 / 10 ** 2`).<br>     *<br>     * Tokens usually opt for a value of 18, imitating the relationship between<br>     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is<br>     * called.<br>     *<br>     * NOTE: This information is only used for _display_ purposes: it in<br>     * no way affects any of the arithmetic of the contract, including<br>     * {IERC20-balanceOf} and {IERC20-transfer}.<br>     */<br>    function decimals() public view returns (uint8) {<br>        return _decimals;<br>    }</pre><pre>    /**<br>     * @dev See {IERC20-totalSupply}.<br>     */<br>    function totalSupply() public view override returns (uint256) {<br>        return _totalSupply;<br>    }</pre><pre>    /**<br>     * @dev See {IERC20-balanceOf}.<br>     */<br>    function balanceOf(address account) public view override returns (uint256) {<br>        return _balances[account];<br>    }</pre><pre>    /**<br>     * @dev See {IERC20-transfer}.<br>     *<br>     * Requirements:<br>     *<br>     * - `recipient` cannot be the zero address.<br>     * - the caller must have a balance of at least `amount`.<br>     */<br>    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {<br>        _transfer(_msgSender(), recipient, amount);<br>        return true;<br>    }</pre><pre>    /**<br>     * @dev See {IERC20-allowance}.<br>     */<br>    function allowance(address owner, address spender) public view virtual override returns (uint256) {<br>        return _allowances[owner][spender];<br>    }</pre><pre>    /**<br>     * @dev See {IERC20-approve}.<br>     *<br>     * Requirements:<br>     *<br>     * - `spender` cannot be the zero address.<br>     */<br>    function approve(address spender, uint256 amount) public virtual override returns (bool) {<br>        _approve(_msgSender(), spender, amount);<br>        return true;<br>    }</pre><pre>    /**<br>     * @dev See {IERC20-transferFrom}.<br>     *<br>     * Emits an {Approval} event indicating the updated allowance. This is not<br>     * required by the EIP. See the note at the beginning of {ERC20};<br>     *<br>     * Requirements:<br>     * - `sender` and `recipient` cannot be the zero address.<br>     * - `sender` must have a balance of at least `amount`.<br>     * - the caller must have allowance for ``sender``&#39;s tokens of at least<br>     * `amount`.<br>     */<br>    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {<br>        _transfer(sender, recipient, amount);<br>        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, &quot;ERC20: transfer amount exceeds allowance&quot;));<br>        return true;<br>    }</pre><pre>    /**<br>     * @dev Atomically increases the allowance granted to `spender` by the caller.<br>     *<br>     * This is an alternative to {approve} that can be used as a mitigation for<br>     * problems described in {IERC20-approve}.<br>     *<br>     * Emits an {Approval} event indicating the updated allowance.<br>     *<br>     * Requirements:<br>     *<br>     * - `spender` cannot be the zero address.<br>     */<br>    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {<br>        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));<br>        return true;<br>    }</pre><pre>    /**<br>     * @dev Atomically decreases the allowance granted to `spender` by the caller.<br>     *<br>     * This is an alternative to {approve} that can be used as a mitigation for<br>     * problems described in {IERC20-approve}.<br>     *<br>     * Emits an {Approval} event indicating the updated allowance.<br>     *<br>     * Requirements:<br>     *<br>     * - `spender` cannot be the zero address.<br>     * - `spender` must have allowance for the caller of at least<br>     * `subtractedValue`.<br>     */<br>    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {<br>        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, &quot;ERC20: decreased allowance below zero&quot;));<br>        return true;<br>    }</pre><pre>    /**<br>     * @dev Moves tokens `amount` from `sender` to `recipient`.<br>     *<br>     * This is internal function is equivalent to {transfer}, and can be used to<br>     * e.g. implement automatic token fees, slashing mechanisms, etc.<br>     *<br>     * Emits a {Transfer} event.<br>     *<br>     * Requirements:<br>     *<br>     * - `sender` cannot be the zero address.<br>     * - `recipient` cannot be the zero address.<br>     * - `sender` must have a balance of at least `amount`.<br>     */<br>    function _transfer(address sender, address recipient, uint256 amount) internal virtual {<br>        require(sender != address(0), &quot;ERC20: transfer from the zero address&quot;);<br>        require(recipient != address(0), &quot;ERC20: transfer to the zero address&quot;);</pre><pre>        _beforeTokenTransfer(sender, recipient, amount);</pre><pre>        _balances[sender] = _balances[sender].sub(amount, &quot;ERC20: transfer amount exceeds balance&quot;);<br>        _balances[recipient] = _balances[recipient].add(amount);<br>        emit Transfer(sender, recipient, amount);<br>    }</pre><pre>    /** @dev Creates `amount` tokens and assigns them to `account`, increasing<br>     * the total supply.<br>     *<br>     * Emits a {Transfer} event with `from` set to the zero address.<br>     *<br>     * Requirements<br>     *<br>     * - `to` cannot be the zero address.<br>     */<br>    function _mint(address account, uint256 amount) internal virtual {<br>        require(account != address(0), &quot;ERC20: mint to the zero address&quot;);</pre><pre>        _beforeTokenTransfer(address(0), account, amount);</pre><pre>        _totalSupply = _totalSupply.add(amount);<br>        _balances[account] = _balances[account].add(amount);<br>        emit Transfer(address(0), account, amount);<br>    }</pre><pre>    /**<br>     * @dev Destroys `amount` tokens from `account`, reducing the<br>     * total supply.<br>     *<br>     * Emits a {Transfer} event with `to` set to the zero address.<br>     *<br>     * Requirements<br>     *<br>     * - `account` cannot be the zero address.<br>     * - `account` must have at least `amount` tokens.<br>     */<br>    function _burn(address account, uint256 amount) internal virtual {<br>        require(account != address(0), &quot;ERC20: burn from the zero address&quot;);</pre><pre>        _beforeTokenTransfer(account, address(0), amount);</pre><pre>        _balances[account] = _balances[account].sub(amount, &quot;ERC20: burn amount exceeds balance&quot;);<br>        _totalSupply = _totalSupply.sub(amount);<br>        emit Transfer(account, address(0), amount);<br>    }</pre><pre>    /**<br>     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.<br>     *<br>     * This is internal function is equivalent to `approve`, and can be used to<br>     * e.g. set automatic allowances for certain subsystems, etc.<br>     *<br>     * Emits an {Approval} event.<br>     *<br>     * Requirements:<br>     *<br>     * - `owner` cannot be the zero address.<br>     * - `spender` cannot be the zero address.<br>     */<br>    function _approve(address owner, address spender, uint256 amount) internal virtual {<br>        require(owner != address(0), &quot;ERC20: approve from the zero address&quot;);<br>        require(spender != address(0), &quot;ERC20: approve to the zero address&quot;);</pre><pre>        _allowances[owner][spender] = amount;<br>        emit Approval(owner, spender, amount);<br>    }</pre><pre>    /**<br>     * @dev Sets {decimals} to a value other than the default one of 18.<br>     *<br>     * WARNING: This function should only be called from the constructor. Most<br>     * applications that interact with token contracts will not expect<br>     * {decimals} to ever change, and may work incorrectly if it does.<br>     */<br>    function _setupDecimals(uint8 decimals_) internal {<br>        _decimals = decimals_;<br>    }</pre><pre>    /**<br>     * @dev Hook that is called before any transfer of tokens. This includes<br>     * minting and burning.<br>     *<br>     * Calling conditions:<br>     *<br>     * - when `from` and `to` are both non-zero, `amount` of ``from``&#39;s tokens<br>     * will be to transferred to `to`.<br>     * - when `from` is zero, `amount` tokens will be minted for `to`.<br>     * - when `to` is zero, `amount` of ``from``&#39;s tokens will be burned.<br>     * - `from` and `to` are never both zero.<br>     *<br>     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].<br>     */<br>    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }<br>}</pre><p>Now, you would have noticed some basic configurations that you’ll have to do while deploying this smart contract, like token name, symbol, total supply and so on.</p><p>You can explore other <a href="https://github.com/ethereum/EIPs/tree/master/EIPS">Ethereum token standards here</a> usually termed as Ethereum Improvement Proposals (EIPs).</p><h3>DAPPs</h3><p>Ideally, I would have put this on top. You can just forget about how all blockchain works and just want to develop an application that sits on top of a decentralised network and work with tokens. Maybe create the next <a href="https://www.cryptokitties.co/">Cryptokitties</a>.</p><p>All you would need for this is some frontend development knowledge, with frameworks like ReactJs, VueJs, AngularJs, EmberJs and so on. Ideally for a dapp, you might not need any backend at all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xq-UXnQ1YKStGBIFiNG60w.png" /></figure><p>Just integrate web3.js library to connect directly with blockchain via <a href="https://metamask.io/">MetaMask</a> chrome plugin or <a href="https://infura.io/">Infura</a> apis. You might also would like to explore to connect via an external <a href="https://sentinel.acycliclabs.com/">Blockchain Oracle service provider, such as Sentinel</a>.</p><p><em>This is obviously an ever growing field so do not get overwhelmed if tomorrow you hear something entirely new in blockchain technology to work on.</em></p><p><a href="https://blockchainedindia.github.io/resources">Here’s some more of our curated resources for you to get started with.</a></p><p>Blockchained India is also doing a 100 days coding program. If you’re interested to be a participant in our program, click <a href="https://forms.gle/VeEmtp4sGHJjuNfUA"><strong>here</strong></a> and be a part of this amazing opportunity to enhance your skills and knowledge.</p><p>Also, if you liked this article, show some appreciation by giving claps!!</p><p>And don’t forget to be a part of <a href="https://blockchainedindia.com/">Blockchained India</a> community!</p><p><a href="https://t.me/blockchainedindia"><strong>TELEGRAM</strong></a><strong> | </strong><a href="https://twitter.com/blockchainedind"><strong>TWITTER </strong></a><strong>| </strong><a href="https://www.linkedin.com/company/blockchainedindia/"><strong>LINKEDIN</strong></a><strong> | </strong><a href="https://www.facebook.com/groups/blockchainedindia/"><strong>FACEBOOK GROUP </strong></a><strong>| </strong><a href="https://www.facebook.com/blockchainedindia/"><strong>FACEBOOK PAGE</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5664aa3f2cf9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blockchainedindia/getting-started-with-blockchain-development-5664aa3f2cf9">Getting started with Blockchain Development</a> was originally published in <a href="https://medium.com/blockchainedindia">Blockchained India</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BYOB — Build Your Own Blockchain]]></title>
            <link>https://medium.com/blockchainedindia/byob-build-your-own-blockchain-ab7bf635afbc?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab7bf635afbc</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[build]]></category>
            <category><![CDATA[dlt]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Tue, 25 Sep 2018 05:32:10 GMT</pubDate>
            <atom:updated>2018-09-26T10:28:36.179Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CgDPPbFpD-4ST3SMrA5CAg.jpeg" /><figcaption>Image Courtesy: Google</figcaption></figure><p>One of the ultimate buzz words of the decade, blockchain has indefinitely altered not only the data and security industry, but across multiple domains. Often, the amazing distributed database, powered by a decentralised network, incentivised by a sophisticated cryptocurrency or token designed for the network is very much difficult to understand or build for that matter. So, here, we take a shot at <em>Building Your Own Blockchain</em>.</p><h3>What is a Blockchain?</h3><p>A blockchain, is a growing list of records, called blocks, which are linked using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data (generally represented as a merkle tree root hash).<br>For all intend and purpose, we’ll keep it simple and focus on proof of work consensus based public blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TMCDSsEgOEwGdJIuu3y5lg.png" /><figcaption>A Proof-Of-Work based Bitcoin Blockchain example</figcaption></figure><p>By design, a blockchain is resistant to modification of the data, hence called immutable. It is “an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way”. For use as a distributed ledger, a blockchain is typically managed by a peer-to-peer network collectively adhering to a protocol for inter-node communication and validating new blocks. Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority. Although blockchain records are not unalterable, blockchains may be considered secure by design and exemplify a distributed computing system with high Byzantine fault tolerance. Decentralised consensus has therefore been claimed with a blockchain. Read more about blockchain introduction <a href="http://blog.blockchainedindia.com/en/2017/05/11/intro-to-blockchain/">here</a> and <a href="http://anistark.github.io/talks/blockchainIntro/">here</a>.</p><h3>Public vs Permissioned vs Private</h3><p>Blockchain can be primarily categorised into three types- <em>public</em>, <em>permissioned</em> and <em>private</em>.</p><p>Public blockchains are completely open data blockchain networks where all the data and signatures are put up on.</p><p>Permissioned blockchains are open data public blockchain networks but the validators or miners to the network are authorised or voted on.</p><p>Private blockchains are closed data blockchain networks, where they might further be divided to a private organisational blockchain network or a consortium of private organisations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*27ZB2gwh8MzjgeCHWZVy_g.png" /></figure><p>Each type of blockchain has there own pros and cons depending on the type of the task to be done.</p><h3>Properties of Blockchain</h3><p>Blockchain is simply an open distributed record of immutable data. So, it’s worth saying the properties of blockchain can be defined as follows:</p><ol><li><em>Decentralised Network</em>.</li><li><em>Open transparent distributed database</em>.</li><li><em>Immutable Data</em>.</li><li><em>Consensus</em>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3SOo1spS6_lvEQ6fYpcFQ.png" /><figcaption>Pic Courtesy: Deloitte</figcaption></figure><p>Read more about the properties of blockchain <a href="https://www.emeraldinsight.com/doi/full/10.1108/APJIE-12-2017-034">here</a>.</p><h3>Consensus</h3><p>One of the most important things in a decentralised network is how to agree on the data distributed amongst all to reach a consensus. To solve this, various algorithms have been introduced, most famous of which is Proof of Work, which is most widely used currently.<br>We won’t be covering various consensus algorithms at the moment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*ZZKeqFRy5M54IFk-2fVz1A.png" /><figcaption>Currently, there are various other consensus algorithms as well.</figcaption></figure><p>All we’ve to do is generate a block, it’s hash as the signature hash and attach to a previous block.<br>So first, let’s create a new block with these keys:</p><ol><li><strong>index</strong>: Shows the index of the blockchain</li><li><strong>timestamp</strong>: The exact timestamp of the block writing. Very critical while resolving conflicts.</li><li><strong>transactions</strong>: The transactions in the block.</li><li><strong>signature</strong>: The Proof of Work generates a unique hash. Let’s call it signature as it showcases the unique signature of the block.</li><li><strong>previous_block_hash</strong>: The hash of the previous block. This is used to create the linked list.</li></ol><p>Alright, now that we’ve defined a block, let’s go a step further to define a transaction data. Ideally, a lot more data is supposed to be there, but for simplicity of understanding, let’s have the following data in a transaction:</p><ol><li><strong>sender</strong>: The address of the sender.</li><li><strong>recipient</strong>: The address of the recipient.</li><li><strong>amount</strong>: The amount to be sent. (Please note that we have not defined any unit for this amount yet. The unit will defined by the token supporting the blockchain.)</li></ol><p>Awesome! Now, we’ve defined all the data. Let’s start our blockchain node.</p><h3>Running a node</h3><p>Let’s try by creating a simple node (centralised) at this point which will help other nodes to connect to later on. Refer to the <a href="https://raw.githubusercontent.com/anistark/byob/part1/blockchain.py"><em>blockchain.py</em></a> file.</p><p>Now, we create a small F<a href="https://palletsprojects.com/p/flask/">lask</a> app to run our blockchain from web browser. It’s not required but makes the interactions easier via our blockchain enabled APIs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d8c73f9085776bf2bd17bf2dc27bb82/href">https://medium.com/media/7d8c73f9085776bf2bd17bf2dc27bb82/href</a></iframe><p>Find the entire code on the <a href="https://github.com/anistark/byob/tree/part1">github repo here</a>.</p><p>Run the code by running:<br><strong><em>python blockchain.py<br></em></strong>and go to <a href="http://localhost:8000"><strong>http://localhost:8000</strong></a><strong> </strong>or replace the port 8000 with your own port.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*3IfCWK52HWQASWntNdaJoA.png" /></figure><p>At this point, you should be seeing something like this.<br>So, everything seems to be working.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*Ho3fPqjwQW3GCvPbirP2yQ.png" /></figure><p>Open the chain url by clicking on the link given.<br>You should be see the genesis block generated with the data as explained above.</p><p>Open a new terminal window/tab and run another on another port: <br><strong><em>python blockchain.py -p 8001<br></em></strong>Repeat the same operation as above to test the exclusiveness of the nodes.</p><h3>Mining</h3><p>Mining, in the context of blockchain technology, is the process of adding transactions to the large distributed public ledger of existing transactions, known as the blockchain.<br>Below is shown how a typical mining/validation works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*ljCbmEWRbeglj5o__ruy-A.jpeg" /></figure><p>So, let’s create a few new blocks and add to our blockchain.<br>Run the url <a href="http://localhost:8000/mine">/mine</a>(assuming you’re running on 8000 port or replace the url with your your port) on your browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*Y_l05JhsPmXCXSrXcXIcqQ.png" /></figure><p>Now, head back to <a href="http://localhost:8000/chain">/chain</a> and view all the new blocks that we just mined.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*KZnOq1g3nVKwnbCWUaW5Lw.png" /></figure><p>At this stage, we’ve successfully created a blockchain, mined new blocks and added to our blockchain. But, our different ports are not synced with each other. We’re yet to define our consensus algorithm and sync all the nodes.<br>We’ll be covering these on the next article series.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab7bf635afbc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blockchainedindia/byob-build-your-own-blockchain-ab7bf635afbc">BYOB — Build Your Own Blockchain</a> was originally published in <a href="https://medium.com/blockchainedindia">Blockchained India</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data, Currency and Technology]]></title>
            <link>https://medium.com/@anistark/data-currency-and-technology-6b708e3f622a?source=rss-8801cbe17598------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b708e3f622a</guid>
            <category><![CDATA[business]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[currency]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Kumar Anirudha]]></dc:creator>
            <pubDate>Sat, 21 Apr 2018 19:03:23 GMT</pubDate>
            <atom:updated>2018-04-21T19:03:23.924Z</atom:updated>
            <content:encoded><![CDATA[<p>Three words that is in everything and everywhere. The very essence of an object, be it physical or digital is encompassed within the realms of these 3 words. However, there is such distinction amongst the words that we often do not relate to them as the one single entity or even closely linked to each other. Today, we’ll try to find out if that’s true.</p><p>A most widely generic definition can be:</p><blockquote>Any piece of information, however small or intricate, vague or clear, story or not, if given a proper structure and category that be meaningful in one way or other to oneself, can be termed as data.</blockquote><p>So, in a way any piece of information can be termed as data. Interesting! I never knew that me, eating an apple instead of banana can be a meaningful piece of information to be classified as data. But it actually is. To the right person, in the right hands, any piece of information that they can monetise on is actually data. How, do you ask? Well, if an apple selling store knew about this, they would know that I prefer apple over banana and they would then try to sell more apples or other product of apples, perhaps Apple Juice or something. On the contrary if a banana store came around it, they would probably ask me what’s wrong and try to fix it so as to not lose a potential customer.<br>Of course, for as small a data set as a single person, nobody would bother. But say that data isn’t just of mine. It’s of thousands of people in the same neighbourhood. Then, it might catch their eye and they would react. Cause then they would need this data to get their business running. And they would be willing to pay to get such data. Maybe pay 1% of their rest 99% in profit from targeted marketing and sales. Believe me, it is already a thing. Which links to my next point: Currency.</p><p>Who doesn’t know what currency is? But do we really understand it? We take a dollar or rupee bill, and think it holds some value when actually, it doesn’t. If it’s unregistered, somewhere or other it’s not a legal form of currency note. Some bank or institution has to maintain a clear ledger of data as to where that particular note went through to reach your hands. If they do, that note is valid. Otherwise, it becomes something we term as black money and liable to get yourself a heavy charge for carrying illegal money. But, banking ledgers being controlled at a particular location or set defined books became easy to access or manipulate. One could copy all of the books and in process, insert their data in between the rest, which could eventually make their money legal. Eventually, the banks got smarter. They moved from books to storage devices and softwares. But now, it became even easier to randomly insert data. And copy data into new data. Now, the struggle only remained as a tug of war between who knew more technology to get ahead of the other.</p><p>Technology really just means the <em>science of craft</em>. But we’ve taken it so closely to gadgets, that for us, technology merely means catching a Pokemon with a ball by swiping up, in our phone. Well, technically, it ain’t wrong. Just incomplete. We live in a world surrounded by gadgets and apps. Alexa, Uber, Instagram, WhatsApp, Facebook, Twitter, Google Home, even cars now, Tesla. How can the meaning not change. Technological advancements has been tremendous in the last few years. Technology has influenced every part of our lives. From managing data to transferring currency. We don’t go to the banks anymore to fill out a form and transfer money. We just use Paypal or Paytm. Excel sheets have paved ways to databases, and then distributed databases to enhance the further security and accessibility of data. Yes, the social websites that we visit to do give us a lot of exposure. But they also clearly sell out your data to potential buyers. Data encourages currency. But technology really is the one that supports it. But the more important question is, do you really care? If you did, you would lived a monk life so far. But you don’t. You want people to show you ads of that camera, that you viewed a hundred times but can’t afford. If there’s ever an offer or better price somewhere else or newer bran, you’ll come to know about it. Isn’t that great? Of course it is. You may cower that you might not want to know about some other related item which even might get inappropriate sometime and I totally agree to it. But how will the systems learn and adapt to your needs and requirements if they are fed in with huge amounts of data on the same. Are they really breaching our privacy? Do we really need to shut them down. After-all, it’s our inability to read through the lengthy agreements of usage. We are in so hurry to get on-board the show, that we are ready to give it all up.<br>Being said that, obviously we would want a control over own data. Not all of us want to know the nearest restaurant or asked to check-in every time we are near one. And I totally am on the same page with that as well. We must have control over our data. But at the same time be aware of the advantages that data can bring to us.</p><p>Technology as helped us use our data in the form of currency today. There are various data marketplaces even, where companies buy and sell data legally. You can also utilise such marketplaces to monetise your data, the way you would want it to be used.</p><p>Put up your thoughts as to what you think the world should move on to the next phase of data privacy and sharing. Is it ok to come up on WikiLeaks and not on google or do we really want the control and are willing to spend time and give up the online social life to get free of that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b708e3f622a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>