<?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 Mehmet Sait Gulmez on Medium]]></title>
        <description><![CDATA[Stories by Mehmet Sait Gulmez on Medium]]></description>
        <link>https://medium.com/@sgulmez?source=rss-56f53fc600d3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SUyAvj3QhMRrgJSJW3H62g.jpeg</url>
            <title>Stories by Mehmet Sait Gulmez on Medium</title>
            <link>https://medium.com/@sgulmez?source=rss-56f53fc600d3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:36:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sgulmez/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[How to Connect to the Casper Network using Ruby]]></title>
            <link>https://medium.com/@sgulmez/how-to-connect-to-the-casper-network-using-ruby-1a43dbd0df4d?source=rss-56f53fc600d3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a43dbd0df4d</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[casper-network]]></category>
            <category><![CDATA[rubygems]]></category>
            <category><![CDATA[casperlabs]]></category>
            <dc:creator><![CDATA[Mehmet Sait Gulmez]]></dc:creator>
            <pubDate>Wed, 23 Nov 2022 15:31:56 GMT</pubDate>
            <atom:updated>2022-11-26T19:20:05.471Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>The Ruby programming language has a huge fanbase. Ruby was developed by its creator with an intention to invent a language developers can enjoy learning and using. Ruby has been largely accepted by developers all around the world since its launch, in fact, the biggest tech communities in many cities consist of Ruby developers. In this guide, we will learn how to connect to the Casper Network using a Ruby gem (or package) called <a href="https://github.com/saitgulmez/casper-ruby-sdk"><strong>casper-ruby-sdk</strong></a><strong> .</strong></p><p>By using <strong>casper-ruby-sdk</strong>, we can make direct JSON RPC calls to a node from any Ruby application. <strong>casper-ruby-sdk</strong> also boasts numerous other functionalities listed in their official Github <a href="https://github.com/saitgulmez/casper-ruby-sdk">repo</a>:</p><ul><li>Get the list of Peer objects</li><li>Current Status of the node</li><li>Get Block Transfers</li><li>Get Block By Hash</li><li>Get Block By Height</li><li>Get Era Info</li><li>Get State Item</li><li>Get Dictionary Item</li><li>Get Account Balance</li><li>Get Auction State</li><li>Put Deploy</li><li>Serialization</li><li>Key Management</li></ul><p>In this guide, we’ll take a closer look into how we can install and interact with this package by setting it up locally on our machine and then retrieving the block height from a node on Casper Network. Let’s get started!</p><p><strong>Prerequisites</strong></p><ul><li>Ruby version &gt;= 3.0.2</li><li>A code editor</li><li>Terminal aka Command Line</li></ul><h3>Installing the casper_network Gem</h3><p>Before installing the gem, let us first ensure that Ruby is installed. Simply open a terminal and run:</p><pre>ruby -v</pre><p>If this returns a version 3.0.2 or higher, you’re all set! If the command is not recognized, then you will need to install Ruby. If it is and the version is older than 3.0.2, you will need to use a newer one. Note: the version of Ruby that ships with macOS is usually for Apple’s own use and it is best not to change it. You <em>can</em> make changes to this version, however, instead, we suggest using <strong>rbenv</strong> or <strong>RVM</strong> (Ruby Version Manager) to manage a separate Ruby version, which will be installed into a sandbox in your home directory. You can make changes to this version without worrying about changing the system’s Ruby version. For more information, read <a href="https://mac.install.guide/faq/check-ruby-version/index.html">this external guide from mac.install</a>.</p><p>Once you’re ready to move on, we can install the <strong>casper_network</strong> gem. This gem will allow us to connect to the Casper blockchain Network using the Ruby language. We can install it from the command line using the RubyGems package manager:</p><pre>gem install casper_network</pre><p><strong>How can we access a block and its attributes in Casper Network?</strong></p><p>Let’s start with a simple example and then continue with a detailed one to show how to access a block and block members.</p><p>Create a new file, <strong>script.rb</strong>, through your Terminal or directly in your file system. If you choose to use a Terminal, you can use this command:</p><pre>echo &gt; script.rb</pre><p>Open <strong>script.rb</strong> in a code editor of choice and add the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44d722ddd98b3257945dae710339a918/href">https://medium.com/media/44d722ddd98b3257945dae710339a918/href</a></iframe><p>You can choose an IP address among peers list from <a href="https://testnet.cspr.live/tools/peers">https://testnet.cspr.live/tools/peers</a></p><p>Replace the <strong>YOUR_CASPER_NETWORK_NODE_IP_ADDRESS</strong> with one of these IP addresses available in the <a href="https://testnet.cspr.live/tools/peers">peers</a> list.</p><p>Let us break down the code:</p><ul><li>Line 1: We are importing the <strong>casper_network</strong> gem we installed earlier.</li><li>Line 3: We are creating a new Casper Network RPC <strong>client</strong>, passing in our Casper Network node IP.</li><li>Line 6: <strong>block_hash</strong> that taken from the Casper Network. You can select a block_hash in <a href="https://testnet.cspr.live/blocks">here</a></li><li>Line 8: We are getting the latest block data using the <strong>chain_get_block</strong> method and store retrieved data to the <strong>block</strong> object.</li><li>Line 11: We are printing the <strong>era id </strong>in which this block was created.</li><li>Line 14: We are printing the <strong>height</strong> of the block.</li></ul><h3>Run the Script</h3><p>Execute the script by running the following in your Terminal:</p><pre>ruby script.rb</pre><p>After running this command, you will be able to see <strong>era id </strong>and <strong>height </strong>information of the block as outputs. It is done! We’ve successfully connected to the Casper Network by using Ruby.</p><p><strong>Block Structure</strong></p><p>A <strong>block</strong> in Casper Network consists of the following attributes</p><ul><li><strong>hash</strong></li><li><strong>header</strong></li><li><strong>body</strong></li><li><strong>proofs</strong></li></ul><p>If you want to learn more about block structure and its properties in Casper Network, please click <a href="https://docs.casperlabs.io/design/serialization-standard/#serialization-standard-block">here</a>.</p><p>Let’s take a deep dive into the block and block properties in Casper Network with another example in ruby.</p><p>Create a new file, <strong>block.rb </strong>and<strong> </strong>add the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e7be5ebe134ba363554fa5c6140d0ca/href">https://medium.com/media/9e7be5ebe134ba363554fa5c6140d0ca/href</a></iframe><p>Then Execute the <strong>block.rb</strong> by running the following command in your terminal:</p><pre>ruby block.rb</pre><p>After running this command, you will be able to see outputs similar to following.</p><pre>#&lt;Casper::Entity::Block:0x0000000003a81648&gt;<br>53943d39b0ea69dbdd3e255cfafbe0a3d610ccd0e83d86c83ee6d2f623b92e84<br>#&lt;Casper::Entity::BlockHeader:0x0000000003a815a8&gt;<br>f702dc5f9b3b09bfd019fadd48892f9fab35a07c8da93ae17cf241e15f4e5ec2<br>fb3282f8d0b14d72ebdf366ade5851e557a8bcf0fbc4c82a96f1b13add822c80<br>81c671e614566b5d22693b9dcf3cd09c008f3b679e4fdc7505c5560d49a23cea<br>false<br>8be3cba85847dd141720e5634e4706c42e1d7487d96916bf3630131891180b75<br><br>2022-11-22T15:58:33.984Z<br>7098<br>1275281<br>1.4.8<br>#&lt;Casper::Entity::BlockBody:0x0000000003a81508&gt;<br>0157f18d47996f1bbb059f2043bafea9c218d7f50e4d4dd508bc3661844300c3d1<br>5cb466be5d7aaf875fb3cb34164f1bc9afb5f7b78435ae0c949be96b01701a9b<br>proofs[0]: #&lt;Casper::Entity::BlockProof:0x0000000003a81440&gt;<br>public_key: 01018525deae6091abccab6704a0fa44e12c495eec9e8fe6929862e1b75580e715<br>signature: 017fabbfb10943e0dcedcb405f5cf5956b7ea62f930a816c6ae9d91a3785dfce98245c89278cf8bdbf5351a99116c381d36b2bc358cb9e421e26a5d2b9b99ea708<br>proofs[1]: #&lt;Casper::Entity::BlockProof:0x0000000003a813f0&gt;<br>public_key: 0102112a711eb3bee9043ebf036fbdfd4482f0e37d1a65627e09922943713973f8<br>signature: 01388784b45165c6d171d9e700ae467185efab89f66233d6490dabf421f20bc5305af36d269dac180c73360888c352fb8527b828eace879043ca92b53af043ee0c<br>proofs[2]: #&lt;Casper::Entity::BlockProof:0x0000000003a813c8&gt;<br>public_key: 01028e248170a7f328bf7a04696d8f271a1debb54763e05e537eefc1cf24531bc7<br>signature: 011b1c673488c7c8e1605eb85bd550e52753c3649a342fdca611ad55c629203f23afa7c5a0c3bdcbaf4b79d0a45adee23f71113db89f72c0f666a8c1b4d7bead07<br>proofs[3]: #&lt;Casper::Entity::BlockProof:0x0000000003a813a0&gt;<br>public_key: 0106618e1493f73ee0bc67ffbad4ba4e3863b995d61786d9b9a68ec7676f697981<br>signature: 01a1c62d9db3e376f9f4ab2c02b75f2574fabe14ddb66639a805c1c26bb8968185224c0a9631574366de1f5cab0c6458482a9035fba7356d8b5d5d18176fc2060c<br>.<br>.<br>.<br>.</pre><p>To summarize, I tried to explain how to access a block and block items in<strong> Casper Network</strong> by using Ruby in this article.</p><p>Casper Ruby SDK is an open source project funded by <a href="https://www.devxdao.com/">DEVxDAO</a>. I would like to thank <a href="https://www.devxdao.com/">DEVxDAO</a> for funding the SDK.</p><p><strong>References</strong>:<br><a href="https://casper.network/en-us/">https://casper.network/en-us/</a><br><a href="https://docs.casperlabs.io/design/serialization-standard/#serialization-standard-block">https://docs.casperlabs.io/design/serialization-standard/#serialization-standard-block</a><br><a href="https://docs.rs/casper-node/latest/casper_node/">https://docs.rs/casper-node/latest/casper_node/</a><br><a href="https://github.com/saitgulmez/casper-ruby-sdk">https://github.com/saitgulmez/casper-ruby-sdk</a><br><a href="https://www.quicknode.com/guides/ethereum-development/how-to-connect-to-the-ethereum-network-using-ruby">https://www.quicknode.com/guides/ethereum-development/how-to-connect-to-the-ethereum-network-using-ruby</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a43dbd0df4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>