<?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 Dario Gomez on Medium]]></title>
        <description><![CDATA[Stories by Dario Gomez on Medium]]></description>
        <link>https://medium.com/@gomezdn?source=rss-a39ab0c83bc1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QYBtNsatV9Vrt0p9</url>
            <title>Stories by Dario Gomez on Medium</title>
            <link>https://medium.com/@gomezdn?source=rss-a39ab0c83bc1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:11:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gomezdn/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 operate in RSK without worrying about the private keys]]></title>
            <link>https://medium.com/@gomezdn/how-to-operate-in-rsk-without-worrying-about-the-private-keys-0df4a552517d?source=rss-a39ab0c83bc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/0df4a552517d</guid>
            <category><![CDATA[devex]]></category>
            <category><![CDATA[fireblocks]]></category>
            <category><![CDATA[rsk]]></category>
            <category><![CDATA[rootstock]]></category>
            <category><![CDATA[rsksmart]]></category>
            <dc:creator><![CDATA[Dario Gomez]]></dc:creator>
            <pubDate>Thu, 29 Feb 2024 06:41:44 GMT</pubDate>
            <atom:updated>2024-02-29T20:40:26.330Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to operate in Rootstock blockchain without worrying about private keys</h3><h3>Why to develop in Rootstock</h3><p>Rootstock presents a compelling fusion of innovation and compatibility, leveraging the robustness of Bitcoin while incorporating the versatility of Ethereum smart contracts. At its core, <a href="https://dev.rootstock.io/">Rootstock</a> (RSK) operates as a symbiotic extension of the Bitcoin network, seamlessly integrating smart contract capabilities through its sophisticated Rootstock Virtual Machine (RVM), a forked version of the Ethereum Virtual Machine (EVM).</p><p>Its appeal lies in the ability to bridge the gap between Bitcoin’s proven security and Ethereum’s expansive functionality. The RVM not only ensures compatibility with Ethereum Smart Contracts but also facilitates seamless deployment and interaction using familiar tools, thereby streamlining the development process for blockchain enthusiasts and developers alike. Moreover, Rootstock introduces its native currency, Smart Bitcoin (RBTC), pegged 1:1 with Bitcoin, offering users a familiar and stable medium of exchange within the Rootstock ecosystem.</p><p>Rootstock’s unparalleled blend of security, compatibility, and scalability positions it as a frontrunner in the blockchain space, offering a compelling solution for developers seeking to harness the full potential of Bitcoin’s network. As the demand for decentralized finance (DeFi) and Smart Contract functionality continues to surge, Rootstock stands poised to revolutionize the landscape, ushering in a new era of innovation and accessibility in the world of blockchain technology.</p><h3>The private keys problem</h3><p>However, ensuring the safety of assets in such a decentralized landscape requires innovative solutions.</p><p>One of the primary risks associated with managing private keys within an application is the potential for exploits and security breaches. In a centralized setup, if an attacker gains access to the application’s infrastructure, they could potentially compromise the private keys, leading to unauthorized access and theft of funds. Additionally, the complexity of securely managing private keys within the application itself adds another layer of vulnerability, as any flaw or oversight in the implementation could expose sensitive data to malicious actors.</p><p>By leveraging a third-party service to decouple private keys, developers can offload the responsibility of safeguarding tokens to a dedicated and specialized platform.</p><h3>The solution</h3><p><a href="https://www.fireblocks.com/">Fireblocks</a> employs cutting-edge security measures such as multi-party computation (MPC) and hardware security modules (HSMs) to protect private keys from unauthorized access and tampering. This ensures that even in the event of a breach or compromise within the application’s infrastructure, the private keys remain secure and inaccessible to malicious entities.</p><p>Moreover, the simplicity and ease of integration offered by Fireblocks further enhance its appeal as a third-party service provider. By requiring only a simple API key for integration, developers can seamlessly incorporate Fireblocks’ services into their applications without the need for extensive modifications or complex setup procedures. This not only reduces the development time and effort required but also ensures that the security measures provided by Fireblocks are readily accessible and implementable by a wide range of applications and developers.</p><h4>Fireblocks users</h4><p>Initiating a new user prompts the system to generate an associated API key. This key serves as a crucial identifier, facilitating seamless authentication for user requests via both the API and SDK channels. Additionally, users have the option to either download or create a secret key, further strengthen the authentication process. This dual-layered authentication mechanism ensures enhanced security and streamlined access for users navigating the Fireblocks ecosystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JD-OEqPs3qmwMM8ZdASPaQ.png" /><figcaption>Each Fireblocks account can have multiple users with different permissions</figcaption></figure><h4>Code example</h4><p>In this example an instance of the Fireblocks SDK is used to send a <a href="https://developers.fireblocks.com/docs/creating-a-transaction">transaction</a> to the network. It then uses the returned id to poll another endpoint until the transaction is either confirmed, rejected or has any finished status and then lets you inspect the transaction result.</p><pre>async function sendRskTransaction(assetId: RBTCAsset, {<br>to,<br>value,<br>data,<br>gasLimit,<br>gasPrice<br>}: RskTxRequest) {<br>  const payload: FireblocksRskTxPayload = {<br>    assetId,<br>    amount: value || &#39;0&#39;,<br>    source: {<br>        type: PeerType.VAULT_ACCOUNT,<br>        id: &#39;0&#39;<br>    },<br>    destination: {<br>      type: PeerType.ONE_TIME_ADDRESS,<br>      oneTimeAddress: {<br>        address: to<br>      }<br>    },<br>    gasLimit,<br>    gasPrice<br>  }<br><br>  if (typeof data === &#39;string&#39; &amp;&amp; data.length) {<br>    payload.operation = TransactionOperation.CONTRACT_CALL<br>    payload.extraParameters = {<br>      contractCallData: data<br>    }<br>  }<br>  const { id } = await fireblocksClient.createTransaction(payload)<br><br>  const txInfo = await waitForResult(id, &#39;txHash&#39;)<br><br>  return txInfo<br>}</pre><p>Requesting a balance is also a simple procedure as specifying which asset you want to know the balance of.</p><pre>async function getAssetBalance(assetId: Asset) {<br>  const {<br>    total,<br>    blockHeight<br>  } = await fireblocksClient.getVaultBalanceByAsset(assetId)<br><br>  return { total, blockHeight }<br>}</pre><p>Its <a href="https://developers.fireblocks.com/docs/introduction">functionalities</a> are pretty well documented and you can try everything with their <a href="https://developers.fireblocks.com/docs/postman-guide">Postman</a> collection.</p><h3>Conclusion</h3><p>Decoupling private keys and entrusting them to a specialized service like Fireblocks presents a compelling solution to the security challenges inherent in cryptocurrency management. By mitigating the risks of exploits and security breaches while providing robust security measures and simplified integration processes, Fireblocks empowers developers to safeguard their tokens effectively and focus on delivering innovative and secure cryptocurrency applications to their users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0df4a552517d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do a contract call in RSK network]]></title>
            <link>https://medium.com/@gomezdn/how-to-do-a-contract-call-in-rsk-network-6879990fda54?source=rss-a39ab0c83bc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/6879990fda54</guid>
            <category><![CDATA[rootstock]]></category>
            <category><![CDATA[rsk]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[devex]]></category>
            <dc:creator><![CDATA[Dario Gomez]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 19:19:17 GMT</pubDate>
            <atom:updated>2023-06-26T19:19:17.937Z</atom:updated>
            <content:encoded><![CDATA[<p>Unlike sending a transaction, where one must pay a fee and wait for it to be mined (because it modifies the blockchain’s state), calling directly a <em>view</em> or <em>pure</em> function in a contract is a free procedure where the node responds immediately.</p><p>This will be useful for <a href="https://en.wikipedia.org/wiki/Blockchain_oracle">oracles</a> or any process that needs to check information frequently or dynamically that is stored or calculated in a smart contract.</p><p><strong>Here will be explained two ways to do it:</strong></p><ul><li>Using the <em>cURL</em> command line, which will be already present in most of bash terminals.</li><li>Using <em>ethers.js</em> library for NodeJS which requires installing some dependencies and a small script.</li></ul><p><strong>Both will require:</strong></p><ul><li>The data that will be sent in the contract call, which is basically the encoded signature of the smart contract’s function you want to call.</li><li>The contract address that is being called.</li><li>The node url to send the call. For this example it will be used the RSK testnet public node: https://public-node.testnet.rsk.co</li></ul><h4>Get the encoded signature</h4><p>If there’s a method declared as <em>function multiply(uint256 x, uint256 y)</em>, the signature will be <em>multiply(uint256, uint256)</em>, which is the name of the function and the type of the parameters between parentheses. If it doesn’t have any parameter, the parentheses will be empty.</p><p>Now it needs to be hashed with keccak256 in order to indicate the contract which method you are calling. This <a href="https://emn178.github.io/online-tools/keccak_256.html">webapp</a> will do it. Entering the function signature in the input will output the hashed one. Now taking the first 4 bytes (the 8 first characters from the left), and adding <em>0x</em> at the beginning will result in the data to send in the contract call.</p><p>Let’s use a real example of a contract in RSK testnet; the Rif On Chain (RoC) stablecoin price feeder. It has the method <em>getPrice()</em>, so:</p><pre>Method signature: getPrice()<br>Hashed signature: 98d5fdcadea1306147ea4341c5601cc83106db3090e2da99fbba25961fd05868<br>Call data: 0x98d5fdca</pre><h3>Call the contract using cURL</h3><p>This is the fastest and easiest method since it only requires to enter a command in a terminal; but since it won’t be integrated into any program it may be more useful for occasional calls.<br>Open a terminal and run:</p><pre>curl -X POST -H &quot;Content-Type: application/json&quot; \<br>--data &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;<strong>method</strong>&quot;:&quot;eth_call&quot;,&quot;params&quot;:[{&quot;<strong>to</strong>&quot;:&quot;0x159980A48aBb56b190C2Ea8593515ee8fE7B197b&quot;,&quot;<strong>data</strong>&quot;:&quot;0x98d5fdca&quot;}, &quot;<strong>latest</strong>&quot;],&quot;id&quot;:1}&#39; \<br>https://public-node.testnet.rsk.co</pre><p>As it’s shown, the method used is <em>eth_call. </em>The first parameter has the <em>to</em> property, which is the contract being called (the testnet RoC stablecoin price feeder in this case), the <em>data</em> property that is the encoded signature <em>getPrice()</em>, and the second parameter is a string asking for the more recent block to read the blockchain’s state from. If the block was other than the latest one, and the method depended on any permanent state, it would reflect the state of that block.<br>At the end of the command there’s the public node url for testnet.</p><p>It will output something like this:</p><pre>{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:1,&quot;result&quot;:&quot;0x0000000000000000000000000000000000000000000000000de0b6b3a763ffff&quot;}</pre><p>The hexadecimal result converted to decimal will be the RoC stablecoin price.</p><h3>Call the contract using Ethers.js</h3><ul><li>NodeJS and NPM need to be <a href="https://kinsta.com/blog/how-to-install-node-js/#how-to-install-nodejs-and-npm">installed</a>.</li><li>Open a terminal, create a folder and move into it: <strong>mkdir test-call &amp;&amp; cd test-call</strong></li><li>Install Ethers.js library and create an empty .js file: <strong>npm install ethers &amp;&amp; touch script.js</strong></li><li>Edit the script with your preferred code editor and add the following code:</li></ul><pre>const { ethers } = require(&#39;ethers&#39;)<br><br>const nodeURL = &#39;https://public-node.testnet.rsk.co&#39;<br>const provider = new ethers.JsonRpcProvider(nodeURL)<br>const GET_PRICE_METHOD = &#39;0x98d5fdca&#39;<br>const PRICE_FEEDER_ADDRESS = &#39;0x159980A48aBb56b190C2Ea8593515ee8fE7B197b&#39;<br><br>const getPriceTx = {<br>  to: PRICE_FEEDER_ADDRESS,<br>  data: GET_PRICE_METHOD<br>}<br><br>async function main() {<br>  const price = await provider.call(getPriceTx)<br>  <br>  console.log(price)<br>  return<br>}<br><br>main()</pre><ul><li>Save the script and run it: <strong>node script.js</strong></li></ul><p>It will output the price directly in the console, in hexadecimal as the cURL approach as well.</p><p>And that’s how a smart contract can be called from outside the blockchain, without spending any money and getting an immediate response.<br>Remember this will only work with view and pure functions, which don’t modify the EVM state.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6879990fda54" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>