<?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 Anmol Dhiman on Medium]]></title>
        <description><![CDATA[Stories by Anmol Dhiman on Medium]]></description>
        <link>https://medium.com/@anmoldh121?source=rss-71c37218c604------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dPGfAIDLfE8tEyWkXkeDBA.png</url>
            <title>Stories by Anmol Dhiman on Medium</title>
            <link>https://medium.com/@anmoldh121?source=rss-71c37218c604------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:42:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anmoldh121/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[Intro to Rust programming language]]></title>
            <link>https://towardsdev.com/intro-to-rust-programming-language-d2ed8db5a945?source=rss-71c37218c604------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2ed8db5a945</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[system-programming]]></category>
            <dc:creator><![CDATA[Anmol Dhiman]]></dc:creator>
            <pubDate>Sun, 13 Feb 2022 16:25:23 GMT</pubDate>
            <atom:updated>2022-02-15T07:28:14.839Z</atom:updated>
            <content:encoded><![CDATA[<h4>A quick intro to rust programming language</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W8KBrJgmsIlYtn24AhHfSQ.jpeg" /></figure><h4>Introduction</h4><p>Rust is most loved programming language 5 years in a row on stack overflow <a href="https://insights.stackoverflow.com/survey/2021">survey</a>. Developers of rust came up with concepts that made it easy to create memory safe projects with the performance of c and developers are loving it. Big players like Discord, Figma, Microsoft, Google, Dropbox are using rust.</p><p>Rust is a fast and memory safe general purpose programming language designed for performance and safety created by Mozilla. Rust looks something similar to C++ but includes a borrow checker.</p><p>The unifying principles behind Rust are:</p><ul><li>Strictly enforcing safe borrowing data.</li><li>functions, methods and closures to operate on data.</li><li>tuples, structs and enums to aggregate data.</li><li>patter matching to select and destructure data.</li><li>traits to define behaviour on data.</li></ul><h4>Setup</h4><p>Install rustup — Rust toolchain</p><pre>curl --proto &#39;=https&#39; --tlsv1.2 -sSf https://sh.rustup.rs | sh</pre><p>Verify installation using</p><pre>rustc --version</pre><h4>Get started</h4><p>To continue our culture of developers let’s write a Hello World program for warm up.</p><pre>fn main() {<br>    println!(&quot;Hello world!&quot;);<br>}</pre><p>Functions in rust are denoted by fn keyword and the functions that includes ! at the end are called macros, Macros are basically a function that writes code which is called <em>metaprogramming.</em></p><h4>Variables in Rust</h4><p>By default the variables in rust is immutable means it can not be change after initialisation. This is one the safety feature of rust. Let’s explore this.</p><pre>fn main() {<br>    let x = 1; // immutable<br>    let mut y = 2; // mutable;<br>}</pre><h4>Ownership Concept</h4><p>Ownership concept is new and unique concept and useful concept because it killed the need of garbage collection. It enables developers to write memory safe code. Ownership is a set of rules that determines how program is going to manage memory.</p><p>Ownership rules.</p><ul><li>Each value has a variable that’s called it’s owner.</li><li>There can only be one owner at a time.</li><li>When the owner goes out of scope, the value will be dropped.</li></ul><h4>Looping</h4><pre>fn main() {<br>    for i in 0..5 {<br>        println!(&quot;Hello {} times&quot;, i);<br>    }<br>}</pre><p>.. is used to determine range in loop so i goes from 0 to 4. This is very convenient in iterating index based data structure.</p><pre>fn main() {<br>    for i in 0..5 {<br>        if i % 2 == 0 {<br>            println!(&quot;even {}&quot;, i);<br>        } else {<br>            println!(&quot;odd {}&quot;, i);<br>        }<br>    }<br>}</pre><h4>Arrays and Slices</h4><p>All static type language have arrays, which are stream of values stored linearly in memory and indexed from zero.</p><pre>fn main() {<br>    let arr: [i32, 5] = [1, 2, 3, 4, 5];<br>    for i in 0..5 {<br>        println!(&quot;{}&quot;, arr[i]);<br>    }<br>}</pre><p>Slices are used often over arrays in rust. Slices are reference pointing to arrays. They behave like arrays and Slices let you reference a contiguous sequence of elements in a collection rather than the whole collection. so it does not have ownership.</p><pre>fn print_values(values: &amp;[i32]) {<br>    for i in 0..values.len() {<br>        println!(&quot;{}&quot;, i);<br>    }<br>}</pre><pre>fn main() {<br>    let arr = [1, 2, 3, 4];<br>    print_values(&amp;arr);<br>}</pre><h4>Vectors</h4><p>Vector is a collection type Vec&lt;&gt; that is used to store collection of a type. Like array vector allow to store more that one value that puts the value of same type to each other in memory. To create a vector call Vec::new or use vec! macro.</p><pre>let v: Vec&lt;i32&gt; = Vec::new();<br>let v = vec![1, 2, 3];</pre><p>To store values in vector call push() method.</p><pre>let mut v = Vec::new();</pre><pre>v.push(1);<br>v.push(2);</pre><p>To get values in vector call get(index) method.</p><pre>if let Some(value) = v.get(2) {<br>    println!(&quot;{}&quot;, value);<br>}</pre><p>Iterate over vector</p><pre>let v = vec![1, 2, 3, 4];</pre><pre>for i in &amp;v {<br>    println!(&quot;{}&quot;, i);<br>}</pre><p>Let’s connect on <a href="https://www.linkedin.com/in/anmoldhiman/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2ed8db5a945" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/intro-to-rust-programming-language-d2ed8db5a945">Intro to Rust programming language</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Libp2p: The network engine behind Ethereum, Polkadot and IPFS]]></title>
            <link>https://medium.com/cryptostars/libp2p-the-network-engine-behind-ethereum-polkadot-and-ipfs-bc2686affa6d?source=rss-71c37218c604------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc2686affa6d</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[peer-to-peer]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[libp2p]]></category>
            <dc:creator><![CDATA[Anmol Dhiman]]></dc:creator>
            <pubDate>Wed, 09 Feb 2022 23:20:48 GMT</pubDate>
            <atom:updated>2022-02-10T07:18:43.070Z</atom:updated>
            <content:encoded><![CDATA[<h4>A peer-to-peer network engine</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*zzu56AwKV-akrN8YD3Vb1A.png" /></figure><h4>Introduction</h4><p>Libp2p is a network framework that is used to create decentralized peer-to-peer application. It was created by Protocol labs and used in IPFS later ethereum used in there blockchain’s network layer. Both are created on golang implementation of libp2p. The project was so successful and robust that Polkadot used Rust implementation of libp2p in there network layer.</p><p><strong>So what’s so special about libp2p and why Big blockchains are using it ?</strong></p><p>To understand this we need to understand current model of internet. Internet these days is very fragile because it work on location addressing. Location addressing means when we connect to the internet every device has its own unique address and it is interacted by that location for example <a href="http://cat.com/cat.jpeg">http://cat.com/cat.jpeg</a>.</p><p>When you a use http or https to point to the webpage or any content, you are identifying content with it’s location which belongs to a perticular server. Whoever owns the server controls the content. Suppose thousands of people downloaded the content meaning the content exists in thousands of location but we have to believe that content only exist at one location and forced to download it from there.</p><p>These days we are so dependent to internet that it needs to be reliable and safe. Which is not the case with current model of internet. Some of the problems with current model are.</p><ul><li><strong><em>NAT</em></strong> — Translate your ip address to a single IP connecting to outside <em>network</em> to your home. this blinds the users from each other.</li><li><strong><em>Firewall</em></strong> — Firewall restricts different devices to talk to each other.</li><li><strong><em>High latency networks</em></strong> — Leaves user waiting for long time.</li><li><strong><em>Reliability</em></strong> — Sometimes user encounters slow network connection and connections drop frequently.</li><li><strong><em>Roaming</em></strong> — Changing in IP address while roaming, it is hard to keep user discoverable.</li><li><strong><em>Censorship</em></strong> — Websites these days can be blocked by government entity.</li><li><strong><em>Data Privacy </em></strong>— Users these days have become increasingly concerned about there data stored in server. We have seen big companies using our data for there purpose.</li><li><strong><em>Slow Innovation</em></strong> — It is controlled by single entity so creation of new protocols is slow.</li></ul><p>These problems have been solved by content addressing approach of networking.</p><blockquote>The goal is to create a network that is so reliable that can not be destroyed by nuclear bomb and can not be controlled by any single entity</blockquote><h4>What is content addressing ?</h4><p>Content addressing is the way of identifying the content by its <em>fingerprint </em>rather than identifying it by it’s location. If someone wants a content with particular fingerprint they can get it from someone who has a copy of the content. This can be achieved by identifying a content with cryptographic hash generated by SHA like IPFS do. When content is identified by cryptographic hash, this is called content-addressing. Cryptographic hash for a content never changes that means link will always return same content, regardless where it is retrieved from and who is retrieving.</p><h4>Significance of libp2p</h4><h4>Modularity</h4><p>Libp2p is designed to be modular, and can be implement in many ways in many projects. it supports <a href="https://github.com/multiformats/multiaddr">multiaddr</a> technology. A single libp2p application can run on many network protocols. For example</p><ul><li><strong>/ip4/127.0.0.1/tcp/8080 </strong>means the node with ip 127.0.0.1 is listening on TCP on Port 8080.</li><li><strong>/ip4/127.0.0.1/udp/8080</strong> means the node with ip 127.0.0.1 is listening on UDP on Port 8080.</li><li><strong>/ip4/127.0.0.1/udp/quic</strong> means node with ip 127.0.0.1 is listening on Quic protocol on top of udp with Port 8080.</li><li><strong>/ip4/127.0.0.1/tcp/ws</strong> means that node is listening on websocket on top of tcp on Port 80.</li></ul><p>Using all of them in project is not necessary we can add a layer of protocol according to project need.</p><h4>Transport</h4><p>Transport layer in libp2p is responsible for the actual transmission of data from one peer to another. Libp2p provides many interfaces for transport layer. The core operations that transport do is listening and dialing. Listening allows incoming packets and dialing lets you open an outgoing connection to a listening peer. Some transport protocols in libp2p are TCP, uTP, QUIC, SCTP, BLE, TOR, I2P</p><h4>Security</h4><p>Libp2p allows to add encryption to the transport channel so no third party can not read the conversation. This can also support multiple layers of security protocols. IPFS also used sacio as security protocol later they removed it and gave support for multiple layer of security protocol in version 0.7.</p><p>Every peer has its own identity that contains public key and private key, private key is secret from all other peers. The peer id is a cryptographic hash of a peer’s public key.</p><h4>Peer routing</h4><p>Peer routing is the process of discovering peer addresses by using the knowledge of other peers. Peer routing in libp2p uses a distributed hash table to iteratively route requests closer to the desired peer id using <a href="https://en.wikipedia.org/wiki/Kademlia">Kahdemlia algorithm</a>.</p><h4>Content discovery</h4><p>In content discovery peer ask for some piece of data no matter who sends it since you are able to verify its integrity. That can be achieved by content routing interface with same implementation of <a href="https://en.wikipedia.org/wiki/Kademlia">Kahdemlia algorithm</a>.</p><h4>Pub Sub</h4><p>Pub sub network which means publisher and subscriber used to create a real time data transfer system can be useful in chat applications. Peers and subscribe to topics they are interested. Libp2p provides a gossipsub protocol for this.</p><h4>Implementations of libp2p</h4><p>Libp2p is available in following implementations</p><ul><li><a href="https://github.com/libp2p/go-libp2p">go-libp2p</a> in Go</li><li><a href="https://github.com/libp2p/js-libp2p">js-libp2p </a>in JavaScript</li><li><a href="https://github.com/libp2p/rust-libp2p">rust-libp2p</a> in Rust</li><li><a href="https://github.com/libp2p/py-libp2p">py-libp2p</a> in Python</li></ul><blockquote>Libp2p was to designed with keep in mind that it could be able to follow many standards came before and will come in future of creating peer-to-peer network. It is broken into modules that user would be able to create there own structure or there own recipe of network with ease.</blockquote><p><strong>Thanks for reading</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc2686affa6d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cryptostars/libp2p-the-network-engine-behind-ethereum-polkadot-and-ipfs-bc2686affa6d">Libp2p: The network engine behind Ethereum, Polkadot and IPFS</a> was originally published in <a href="https://medium.com/cryptostars">CryptoStars</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make an NFT Minter on the NEAR Protocol]]></title>
            <link>https://medium.com/better-programming/make-an-nft-minter-on-the-near-protocol-56ac3c5c1f45?source=rss-71c37218c604------2</link>
            <guid isPermaLink="false">https://medium.com/p/56ac3c5c1f45</guid>
            <category><![CDATA[near-protocol]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Anmol Dhiman]]></dc:creator>
            <pubDate>Fri, 04 Feb 2022 17:23:00 GMT</pubDate>
            <atom:updated>2022-02-04T17:23:00.122Z</atom:updated>
            <content:encoded><![CDATA[<h4>Create NFTs on NEAR Protocol using rust</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JU4OoD2Ql03WEo3L8Bm_0Q.jpeg" /></figure><h4>Introduction</h4><p>NFT or Non fungible tokens are unique tokens with metadata associated with it. NFTs can not be replaced with something else. They can be bought and like cryptocurrencies. In this guide we are going to create a smart contract for near protocol that will mint NFTs.</p><h4>What is NEAR Protocol ?</h4><p><a href="https://near.org/">NEAR Protocol</a> is a new generation of layer 1 blockchain that is solving problems like slow transaction rates, limited throughput, and poor compatibility. It is developed on the amazing concept of sharding which means when the network utilization is high nodes slit into smaller shards, and computes parallel over these shards. This network can scale itself with high demand.</p><h4>Prerequisite</h4><p>To create the near smart contract we need.</p><ul><li><strong>Rust — </strong>Rust is a high-performance general purpose programming language, we are going to use it to create a smart contract. There is a very good <a href="https://doc.rust-lang.org/book/">book</a> available to learn Rust.</li><li><a href="https://docs.near.org/docs/tools/near-cli"><strong>Near CLI </strong></a><strong>— </strong>Command line interface to connect and interact with near blockchain.</li><li><strong>Near Wallet — </strong>Before starting our project we need a near wallet. Checkout this <a href="https://docs.near.org/docs/develop/basics/create-account">guide</a> for how to setup near wallet.</li></ul><h4><strong>Setup</strong></h4><p>To get started, Create a cargo project.</p><pre>cargo new nft --lib</pre><p>Go to project folder nft you will see.<br><strong>src/lib.rs — </strong>This is where we are going to write our smart contract<br><strong>Cargo.toml — </strong>This is our project configuration file</p><p>Go to the cargo.toml and add</p><pre>[lib]<br>crate-type = [&quot;cdylib&quot;, &quot;rlib&quot;]</pre><pre>[dependencies]<br>near-sdk = &quot;*&quot;<br>near-contract-standards = &quot;*&quot;</pre><h4><strong>Getting started</strong></h4><p>Let’s start with our smart contract scaffolding.</p><pre>use near_sdk::{<br>    near_bindgen,<br>    borsh::{self, BorshDeserialize, BorshSerialize}<br>};</pre><pre>near_sdk::setup_alloc!();</pre><pre>#[near_bindgen]<br>#[derive(BorshDeserialize, BorshDeserialize)]<br>pub struct Contract {}</pre><pre>#[near_bindgen]<br>impl Contract {}</pre><p>This looks like a weird code and do nothing right now let’s simplify it. NEAR follows a stateful approach so struct Contract is going to hold our contract state and in the implementation Contract we are going to write our functions that changes state.</p><p>The point to be noted here we are implementing some macros and deriving traits. the #[near_bindgen] macro converts the state into valid form to be live on NEAR chain. BorshDeserialize, BorshDeserialize are the traits from <a href="https://borsh.io/">borsh</a> crate for deserialization and serialization of state.</p><p>Now, let’s create our state for NFT. You know that NFT is a unique token and metadata associated with it. From this definition our state looks like this.</p><pre>use near_contract_standards::non_fungible_token::{<br>    metadata::NFTContractMetadata, NonFungibleToken,<br>};</pre><pre>pub struct Contract {<br>    token: NonFungibleToken,<br>    metadata: LazyOption&lt;NFTContractMetadata&gt;,<br>}</pre><p>Now, this state always need a default value, so we need an initializer function to set the default state.</p><pre>#[derive(BorshSerialize, BorshStorageKey)]<br>pub enum StorageKey {<br>    NonFungibleToken,<br>    Metadata,<br>    TokenMetadata,<br>    Enumeration,<br>    Approval<br>}</pre><pre>#[near_bindgen]<br>impl Contract {<br>    #[init]<br>    pub fn new(owner_id: ValidAccountId) -&gt; Self {<br>        Self {<br>            token: NonFungibleToken::new(<br>                StorageKey::NonFungibleToken,<br>                owner_id,<br>                Some(StorageKey::TokenMetadata),<br>                Some(StorageKey::Enumeration),<br>                Some(StorageKey::Approval)<br>             ),<br>             metadata: LazyOption::new(<br>                StorageKey::Metadata,<br>                Some(&amp;NFTContractMetadata {<br>                    spec: NFT_METADATA_SPEC.to_string(),<br>                    name: &quot;Example Name&quot;.to_string(),<br>                    symbol: &quot;Example&quot;.to_string(),<br>                    icon: Some(&quot;ANY_SVG&quot;.to_string()),<br>                    base_uri: None,<br>                    reference: None,<br>                    reference_hash: None,<br>                 })<br>             ),<br>        }<br>    }<br>}</pre><p>The function with #[init] macro will always execute first. Normally used to set the default state. For token standards and metadata standards, Irecommend checking out <a href="https://nomicon.io/Standards/NonFungibleToken/Core.html">this</a> and <a href="https://nomicon.io/Standards/NonFungibleToken/Metadata.html">this</a> link.</p><p>Now, everything is set for our initializer and our state. Let’s make our NFT minting function.</p><pre>impl Contract {<br>    <br>    ......<br>    <br>    #[payable]    <br>    pub fn nft_mint(<br>        &amp;mut self,<br>        token_id: TokenId,<br>        receiver_id: ValidAccountId,<br>        token_metadata: TokenMetadata,<br>    ) -&gt; Token {<br>        self.token.mint(token_id, receiver_id, Some(token_metadata))<br>    }<br>}</pre><p>Let’s deploy this to the chain. Run this command to make a build:</p><pre>cargo build --target wasm32-unknown-unknown --release</pre><p>Run this command to deploy:</p><pre>near deploy --wasmFile target/wasm32-unknown-unknown/release/nft.wasm --accountId &quot;your near account username&quot;</pre><p>This will return a program id that can be used to call RPCs of the smart contract. You can either use near CLI or javascript client to interact with contract.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56ac3c5c1f45" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/make-an-nft-minter-on-the-near-protocol-56ac3c5c1f45">Make an NFT Minter on the NEAR Protocol</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Decentralization is important]]></title>
            <link>https://medium.com/cryptostars/why-decentralization-is-important-33719463e6a6?source=rss-71c37218c604------2</link>
            <guid isPermaLink="false">https://medium.com/p/33719463e6a6</guid>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[decentralisation]]></category>
            <category><![CDATA[metaverse]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <dc:creator><![CDATA[Anmol Dhiman]]></dc:creator>
            <pubDate>Fri, 28 Jan 2022 17:14:12 GMT</pubDate>
            <atom:updated>2022-01-30T18:46:45.063Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L7lHkEl3zow9thEL01DleQ.jpeg" /></figure><p><strong>History of internet</strong></p><p>Internet started in 1960s during war as a better and faster way to transfer data. In late 1989 the concept of web was introduced by Tim Burners-Lee and it is being evolving since then. The early version of web is called web 1.0 lasted from 1989 to 2005. It was a way to serve static hypertext content. The only dynamic thing about that was links to go from pages to pages. So in simple words we can say it was boring as hell. Some dudes thought that this is plain boring we need some fun, then came web 2.0. It was based on the principal of participation that means it was all about user generated contents, ease of use. The best thing that happened during web 2.0 is <strong>JavaScript. </strong>Now we started to enjoy awesome social media contents. awesome videos on YouTube, awesome blogs, and you know what else.</p><p><strong>if web 2.0 is that awesome why we need the web 3.0 ? </strong>Because internet is not what it used to be. It is dominated and governed by with tech giants and government. They provide services in exchange with your personal data. That data can be manipulated and affect our lives in many ways.</p><p><strong>What is decentralization and decentralized network</strong></p><p>In terms of computer science, a decentralized network also known as peer to peer network contains several machines connected with some network protocol and workload is distributed to these machines instead of having any central server and blockchain ecosystem make sure everything works smoothly. This also leads to performance improvement, meaning extra machine can be put to use if needed.</p><h3><strong>Some benefits of decentralize internet</strong></h3><ol><li><strong>No central authority. </strong>Usually companies and government controls the web platforms. We trust them with our information, which is OK. But we have seen companies selling our data to advertisement companies. Imagine searching of a pair of Adidas shoes on any eCommerce website and you will see there ads pops up from nowhere whenever you surf the internet.</li><li><strong>It is Open source. </strong>The code is available to anyone to access and contribute. Anyone can build awesome tools and awesome services on top of blockchain. The larger the network the better it becomes. It is so cool with compatibility that anyonone can make products and make money out of it.</li><li><strong>Ownership. </strong>You must be familiar about non fungible tokens, very trending these days. The cool artworks selling in millions is being made possible by the blockchain technology. But NFTs are more than just artworks, technically NFT is a token generated by blockchain which is unique with metadata of asset associated with it. This uniqueness is what makes it very special. Imagine you are content creator and you created an amazing piece of content and uploaded on any social media website. Something happened and they deleted your content, What now !!. If you generate your content as an NFT, your masterpiece is yours.</li><li><strong>Uninterrupted Service. </strong>Because service is distributed over network there is no single of failure. The data is going to be stored on multiple nodes to ensure backup of the data.</li><li><strong>Distributed computation power. </strong>Imagine playing games build on a network made of interconnected thousands of GPUs. Just think about this how much rendering they can do and make your experience better. Now imagine thousands of GPUs is rendering game playing thousands of players on a single network. <strong>Amazing right !!! Now METAVERSE is real bro.</strong></li></ol><h3><strong>Conclusion</strong></h3><p>Web 3.0 is bringing lot of changes in the way we see internet. Web 2.0 improved communication and transaction. Web 3.0 will focus on personalization and data ownership. The network is built by public for public and powered by public. Web 3.0 will create lot of opportunities in different sectors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33719463e6a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cryptostars/why-decentralization-is-important-33719463e6a6">Why Decentralization is important</a> was originally published in <a href="https://medium.com/cryptostars">CryptoStars</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create Smart Contracts in Solana and Anchor]]></title>
            <link>https://medium.com/better-programming/how-to-create-smart-contracts-in-solana-and-anchor-e67ff0747c63?source=rss-71c37218c604------2</link>
            <guid isPermaLink="false">https://medium.com/p/e67ff0747c63</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web3]]></category>
            <dc:creator><![CDATA[Anmol Dhiman]]></dc:creator>
            <pubDate>Sat, 22 Jan 2022 13:53:38 GMT</pubDate>
            <atom:updated>2022-01-29T17:16:38.323Z</atom:updated>
            <content:encoded><![CDATA[<h4>Deploy your contracts on Anchor</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o_4-v8m9QxLD8_sKf6uhsQ.png" /></figure><h3>What is Solana?</h3><p>Solana is a decentralized blockchain platform created by Anatoly Yakavenko. Solana has a block time of 400 ms which is freakingly fast.</p><p>This is because of their proof of history consensus mechanism, which is actually a proof of stake but added extra variable time. PoH is used to encode trustless passage of time into a ledger in an append-only data structure.</p><p>Blockchains have to agree on time before submitting a block, Nodes have to chat back and forth to determine time until they agree on it and this can take a lot of time. Solana came up with a solution with proof of history to save timestamps so nodes don’t have to wait to agree on time and they also have a cryptographic proof for that.</p><p>For more information on proof of history, I recommend you to go through <a href="https://solana.com/solana-whitepaper.pdf">whitepaper</a> of Solana.</p><h3><strong>What is Anchor?</strong></h3><p>Anchor is a framework for developing Solana smart contract that contains several developer tools. So basically, the Anchor is a lifesaver and makes it really easy to develop smart contracts.</p><h3><strong>Project overview</strong></h3><p>In this guide, we’ll be focusing on project setup, basic operation, and testing.</p><p>We will create a counter app that increments the counter by one every time we call the RPC.</p><h3><strong>Prerequisite</strong></h3><p>Rust — Rust is a very powerful general-purpose programming language. We are going to use this for smart contract development. There is a very good <a href="https://doc.rust-lang.org/book/">book</a> available to learn Rust.</p><p><a href="https://docs.solana.com/cli/install-solana-cli-tools">Solana Tool Suit</a> — This includes the Solana CLI.</p><p>The code for this project can be found <a href="https://github.com/anmoldh121/solana-counter">here</a>.</p><h3><strong>Getting Started</strong></h3><p>To get started, create a new anchor project:</p><pre>anchor init counterapp</pre><p>In the project structure, you will see the following files and folders.</p><p>program — This is the directory of Solana programs (Smart contracts)</p><p>test — This is where javascript test code lives</p><p>migrations — This is the deploy script</p><p>app — This is where frontend is going to be built</p><p>Let’s look at our lib.rs file in the program directory.</p><pre>use anchor_lang::prelude::*;</pre><pre><br>declare_id!(&quot;Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS&quot;);</pre><pre><br>#[program]<br>pub mod counterapp {<br>    use super::*;<br>    pub fn initialize(ctx: Context&lt;Initialize&gt;) -&gt; ProgramResult {       </pre><pre>        Ok(())<br>    }<br>}</pre><pre>#[derive(Accounts)]<br>pub struct Initialize {}</pre><p>This is the most basic program written by CLI. There is a function initialize when invoked do nothing just execute successfully, the initialize struct defines the context of the initialize function.</p><p>Now that we have set up our project let’s build our counter app.</p><p>To do that we need to create an account to store our data. You must be thinking what the heck is this account. Accounts are just the way of storing and accessing the data in Solana sealevel. For more information, I recommend reading <a href="https://solana.wiki/zh-cn/docs/account-model/#:~:text=On%20Solana%2C%20any%20account%20can,completely%20stored%20in%20other%20accounts.">this</a>.</p><p>In the above code we have defined two structs, the CounterAccount struct is our Account contains a count variable that is going to store our count.</p><pre>#[derive(Accounts)]<br>pub struct Create&lt;&#39;info&gt; {<br>    <br>    #[account(init, payer=user, space = 16+16)]<br>    pub counter_account: Account&lt;&#39;info, CounterAccount&gt;,<br>    <br>    #[account(mut)]<br>    pub user: Signer&lt;&#39;info&gt;,<br>    <br>    pub system_program: Program&lt;&#39;info, System&gt;,<br>}</pre><pre>#[account]<br>pub struct CounterAccount {<br>    pub count: u64,<br>}</pre><p>The Create struct is our instruction struct that defines our context for creating an account, that is saying, “Hey I want to create an account counter_account with the space 32 byte”.</p><p>The #[account(…)] attributes define constraints and instructions in preprocessing done by Anchor to create context. Now let’s create our function.</p><pre>pub fn create(ctx: Context&lt;Create&gt;) -&gt; ProgramResult {<br>    let counter_account = &amp;mut ctx.accounts.counter_account;<br>    counter_account.count = 0;<br>    Ok(())<br>}</pre><p>create function is our handler for rpc request which takes the context created with Create struct.</p><p>Cool. We are done with this amazing program. Now let’s create the test function and deploy our masterpiece.</p><pre>import * as anchor from &#39;@project-serum/anchor&#39;;<br>import { Program } from &#39;@project-serum/anchor&#39;;<br>import { Counterapp } from &#39;../target/types/counterapp&#39;;</pre><pre>describe(&#39;counterapp&#39;, () =&gt; {</pre><pre>    const provider = anchor.Provider.env()<br>    anchor.setProvider(provider);</pre><pre>    const program = anchor.workspace.Counterapp as Program&lt;Counterapp&gt;;</pre><pre>    const counterAccount = anchor.web3.Keypair.generate();</pre><pre>    it(&#39;Is initialized!&#39;, async () =&gt; {<br>        await program.rpc.create({<br>            accounts: {<br>                counterAccount: counterAccount.publicKey,<br>                user: provider.wallet.publicKey,<br>                systemProgram: anchor.web3.SystemProgram.programId,<br>            },<br>            signers: [counterAccount]<br>        } as any)<br>    });</pre><pre>    it(&quot;Increment counter&quot;, async () =&gt; {<br>        await program.rpc.increment({<br>            accounts: {<br>                counterAccount: counterAccount.publicKey<br>            }<br>        } as any)<br>    })</pre><pre>    it(&quot;Fetch account&quot;, async () =&gt; {<br>        const account: any = await<br>        program.account.counterAccount.fetch(counterAccount.publicKey)<br>        console.log(account.count)<br>    })<br>});</pre><p>Now, run the test.</p><pre>anchor test</pre><p>After the test passes, we can now deploy the program. Be sure that solana-test-validator is running.</p><pre>anchor deploy</pre><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e67ff0747c63" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/how-to-create-smart-contracts-in-solana-and-anchor-e67ff0747c63">How to Create Smart Contracts in Solana and Anchor</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>