<?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 Santiago Trujillo Zuluaga on Medium]]></title>
        <description><![CDATA[Stories by Santiago Trujillo Zuluaga on Medium]]></description>
        <link>https://medium.com/@santiagodevrel?source=rss-ab56f97886ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zxRRkYlJ9IwKaBffL9MocQ.jpeg</url>
            <title>Stories by Santiago Trujillo Zuluaga on Medium</title>
            <link>https://medium.com/@santiagodevrel?source=rss-ab56f97886ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 23:19:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@santiagodevrel/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[Understanding the Difference Between «call»and «delegatecall»in Solidity]]></title>
            <link>https://medium.com/@santiagodevrel/understanding-the-difference-between-call-and-delegatecall-in-solidity-75ce14a8adcc?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/75ce14a8adcc</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[solidity-tutorial]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[blockchain-developer]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Wed, 30 Aug 2023 20:57:31 GMT</pubDate>
            <atom:updated>2023-12-12T20:57:24.164Z</atom:updated>
            <content:encoded><![CDATA[<p>In Solidity, two important functions for interacting with other contracts are call and delegatecall. These functions might seem similar at first glance, but they have distinct behaviors that are crucial to understand when working with smart contracts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eraxkh1ewzmo_fZ9" /><figcaption>Photo by <a href="https://unsplash.com/@tbonz?utm_source=medium&amp;utm_medium=referral">Emmanuel Edward</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>1. The Basics: call Function</h4><p>The call function in Solidity is used to interact with external contracts by invoking their functions. It allows your contract to send a message (transaction) to another contract and execute a specific function within that contract&#39;s context. Here&#39;s how you can use it:</p><pre>pragma solidity ^0.8.0;<br>contract Caller {<br>    funcsotion callAnotherContract(address _contractAddress, uint256 _value) external {<br>        // Call the target contract&#39;s function and send some ether<br>        bytes memory _functionName = abi.encodeWithSignature(&quot;doSomething()&quot;)<br>        (bool success, bytes data ) = _contractAddress.call{value: _value}(_functionName);<br>        require(success, &quot;Call failed&quot;);<br>    }<br>}</pre><h4>2. Understanding delegatecall</h4><p>delegatecall is a more advanced and nuanced function. Unlike call, which executes a function in the context of the called contract, delegatecall executes the called contract&#39;s code within the context of the calling contract. This means that the called contract shares the same storage as the calling contract.</p><p>Here’s how delegatecall is used:</p><pre>pragma solidity ^0.8.0;<br>contract DelegateCaller {<br>    uint256 public value;<br>    function delegateCallAnotherContract(address _contractAddress) external {<br>        // Use delegatecall to execute the target contract&#39;s code<br>        (bool success, ) = _contractAddress.delegatecall(<br>            abi.encodeWithSignature(&quot;setValue(uint256)&quot;, 42)<br>        );<br>        require(success, &quot;DelegateCall failed&quot;);<br>    }<br>}<br>contract TargetContract {<br>    uint256 public value;<br>    function setValue(uint256 _newValue) external {<br>        value = _newValue;<br>    }<br>}</pre><h4>3. Key Differences and Use Cases</h4><p>The main difference between call and delegatecall is how they handle storage and context.</p><ul><li>call keeps the context of the calling contract separate from the called contract. It&#39;s useful for interacting with external contracts and retrieving data from them.</li><li>delegatecall preserves the context of the calling contract, allowing the called contract to modify the storage of the calling contract. This can be powerful, but it also introduces potential risks if not used carefully.</li></ul><h4>4. Risks and Considerations</h4><p>While delegatecall can be a powerful tool, it&#39;s important to exercise caution. Because the called contract can modify the calling contract&#39;s storage, unintended changes might occur, potentially leading to vulnerabilities.</p><h4>Conclusion</h4><p>In summary, call and delegatecall are both essential functions for contract interaction in Solidity. Understanding their differences and use cases is crucial to developing secure and efficient smart contracts. Use call when you need to interact with external contracts while keeping contexts separate, and consider delegatecall when you want to execute external contract code within your own contract&#39;s context, but be mindful of the potential risks involved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75ce14a8adcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decoding the «data» field in Ethereum Transactions [with code snippets] ️]]></title>
            <link>https://blog.blockmagnates.com/decoding-the-data-field-in-ethereum-transactions-with-code-snippets-7142bc6751ed?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/7142bc6751ed</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[solidity-tutorial]]></category>
            <category><![CDATA[metamask]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Sun, 20 Aug 2023 15:37:53 GMT</pubDate>
            <atom:updated>2023-08-30T20:58:34.158Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When diving into the world of Ethereum transactions, the data field might appear as an enigma wrapped in cryptographic layers. Fear not! This article will unravel the significance of the data field, shedding light on when it should be empty when it should have a value, and how to construct that value.</p><pre>signer.sendTransaction({<br>    from: // Address of the sender,<br>    to: // Address of the recipient,<br>    data: // Data to include in the transaction<br>    value: // Amount of Ether to send,<br>    nonce: // Current counter of transactions for the &#39;from&#39; account.<br>    gasLimit: // Optional maximum value to pay for gas<br>});<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iNvsfbkgAg6wS-oI" /><figcaption>Photo by <a href="https://unsplash.com/@theshubhamdhage?utm_source=medium&amp;utm_medium=referral">Shubham Dhage</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Understanding the Data Field</h3><p>At its core, the data field in an Ethereum transaction serves as a vessel for carrying additional information or instructions. <strong>It’s an essential tool for interacting with smart contracts</strong>, but its usage varies based on the nature of the transaction. <a href="https://ethereum.org/en/developers/docs/transactions/#whats-a-transaction">https://ethereum.org/en/developers/docs/transactions/#whats-a-transaction</a></p><h4><strong>1. Empty Data Field</strong></h4><p>When you’re sending Ether (ETH) from one account to another, without any interaction with smart contracts.</p><p>In this scenario, the data field can be left empty. The primary purpose of the transaction is to transfer value, making the data field redundant. The transaction’s focus is on moving funds, and there’s no need for additional information.</p><pre>signer.sendTransaction({<br>    from: signer.address, //Address of the sender<br>    to: 0x..., //Address of the recipient<br>    data: &quot;&quot;, //Empty data field<br>    value: 1*10**18 //Amount of Ether to send,<br>  });</pre><h4>2. Data field when Interacting with Smart Contracts</h4><p>When you want to interact with a smart contract, invoke a function or trigger an action on the blockchain.</p><p>Here’s where the data field’s power truly shines. To interact with a smart contract, you need to provide the following:</p><ul><li>The <strong><em>to</em></strong> field must have the address of the smart contract to interact with.</li><li>The <strong><em>data </em></strong>field must have the function selector of the specific function you want to call within the smart contract.</li><li>The <strong><em>data </em></strong>field must have the encoded arguments for the function (if the function requires arguments, otherwise, the data field must have only the function signature)</li></ul><p><em>The function selector is the first 4 bytes of the keccak256 of the function signature.</em></p><p><em>Encoding data is like translating the values into bytes, and ensuring they fit into a 32-byte structure.</em></p><p><em>For example, let’s consider the encoding of a 20-byte Ethereum address (0x1234…) and the number “1” as arguments. both the address and the number “1” are padded with zeros to fit within a total of 32 bytes for each argument. This process results in a 64 bytes representation such as 000000000000000000000000123456789abcdef123456789abcdef123456789a0000000000000000000000000000000000000000000000000000000000000001</em></p><p><strong>Example:</strong></p><p>Consider a scenario where we will interact with the smart contract <strong>0x7a65FdAb89cE1e8E5b939dB01f3fB6B9594E3849</strong>, and we will call the <strong>function transfer</strong>, which takes an <strong>address </strong>and an <strong>amount </strong>as it’s arguments.</p><pre>const { ethers } = require(&quot;ethers&quot;);<br><br>const contractAddress = &#39;0x7a65FdAb89cE1e8E5b939dB01f3fB6B9594E3849&#39;; // Address of the contract to call<br>const functionSignature = &#39;transfer(address,uint256)&#39;; // Function signature<br>const functionSelector = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(functionSignature)).substr(0, 10); // Take the first 8 characters (4 bytes)<br><br>//Encode the function arguments<br>const arguments = ethers.utils.defaultAbiCoder.encode(<br>  [&#39;address&#39;, &#39;uint256&#39;],<br>  [&quot;0x123456789abcdef123456789abcdef123456789a&quot;, 1]<br>);<br><br>const encodedData = functionSelector + arguments;<br>//encodedData == 0xa9059cbb000000000000000000000000123456789abcdef123456789abcdef123456789a0000000000000000000000000000000000000000000000000000000000000001<br><br>signer.sendTransaction({<br>    from: signer.address, // Address of the sender,<br>    to: contractAddress, //Address of the smart contract to interact with<br>    data: encodedData,//Function selector + encoded arguments <br>    value: 0 //Amount of Ether to send,<br>  });</pre><h4>Conclusion</h4><p>The data field stands as a versatile and crucial component. Whether you’re sending Ether, interacting with smart contracts, or encoding function calls, understanding how to construct and utilize the data field empowers you to navigate the blockchain landscape with confidence. By grasping the nuances of data encoding and its various applications, you can harness the full potential of Ethereum’s decentralized ecosystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7142bc6751ed" width="1" height="1" alt=""><hr><p><a href="https://blog.blockmagnates.com/decoding-the-data-field-in-ethereum-transactions-with-code-snippets-7142bc6751ed">Decoding the «data» field in Ethereum Transactions [with code snippets] 🛠️</a> was originally published in <a href="https://blog.blockmagnates.com/">Block Magnates</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Ethereum Transactions: A Simple Explanation]]></title>
            <link>https://medium.com/@santiagodevrel/understanding-ethereum-transactions-a-simple-explanation-e44020382b43?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/e44020382b43</guid>
            <category><![CDATA[metamask]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Sun, 20 Aug 2023 14:24:26 GMT</pubDate>
            <atom:updated>2023-08-20T14:24:26.786Z</atom:updated>
            <content:encoded><![CDATA[<p>Transactions are the heart of the Ethereum (or any EVM-compatible) blockchain, enabling the transfer of value and interactions with smart contracts. In this article, we’ll break down the key components of an Ethereum transaction using easy-to-understand language.</p><h3>What’s a Transaction?</h3><p>A transaction is like a digital message that tells the Ethereum network to do something. Imagine you’re sending a friend some money using your bank’s app — that’s similar to what a transaction does on Ethereum. It’s a set of instructions from one person’s account to another’s.</p><h3>What Does a Transaction Include?</h3><p>When you send a transaction on Ethereum, you provide some important information:</p><ul><li>From Address: This is like your return address. It shows who’s sending the transaction.</li><li>To Address: This is the recipient’s address, where the transaction is going.</li><li>Value: This is the amount of Ethereum you’re sending. Think of it like the money in your envelope.</li><li>Signature: This is like your personal seal. It proves that you really want to send this transaction.</li><li>Nonce: It’s like a number that helps order your transactions. Each new transaction gets a higher nonce.</li><li>Gas Limit: This is like a budget for the transaction. It tells the network how much work it can do.</li><li>Gas Fees: These are like fees for using the Ethereum network. You pay them with Ethereum.</li><li>Data: This is extra info you can add, like a note attached to your transaction.</li></ul><h3>How Does It Work?</h3><ol><li>Creating the Transaction: You fill out the transaction details, like the sender, receiver, amount, and more.</li><li>Signing the Transaction: Imagine sealing an envelope with your signature. Your private key creates this digital signature, ensuring the transaction is valid.</li><li>Broadcasting to the Network: You send the sealed envelope (transaction) to the Ethereum network.</li><li>Validation and Execution: Miners (validators) check your transaction. If everything’s good, they execute it — moving the money or doing the action you asked for.</li><li>Updating the Network: The network now knows about your transaction. It’s added to a block, which is like a page in the Ethereum history book.</li></ol><h3>Why Pay Gas?</h3><p>Just like sending a package, using the Ethereum network requires energy and effort. Gas is like the payment for that work. The more complex your transaction, the more gas it needs. You pay gas fees to the miners who do the work.</p><h3>Types of Transactions</h3><ul><li>Regular Transactions: Sending Ether from one person to another.</li><li>Contract Deployment Transactions: Creating new smart contracts.</li><li>Contract Execution Transactions: Interacting with existing smart contracts.</li></ul><h3>Making Sense of It All</h3><p>Ethereum transactions might sound complex, but they’re like digital letters that move money and information. Remember, it’s about sending instructions securely and fairly across the Ethereum network.</p><p>By understanding these transaction basics, you’re taking your first steps into the fascinating world of blockchain technology. Happy transacting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e44020382b43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking PYUSD’s Smart Contract Secrets: Balancing Compliance and Innovation [With code snippets]]]></title>
            <link>https://medium.com/coinmonks/unlocking-pyusds-smart-contract-secrets-innovation-centralization-and-security-with-code-da72286043f0?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/da72286043f0</guid>
            <category><![CDATA[paypal]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[stable-coin]]></category>
            <category><![CDATA[technical-analysis]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Wed, 09 Aug 2023 21:08:51 GMT</pubDate>
            <atom:updated>2023-08-22T15:02:38.533Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In the realm of smart contracts, the PYUSDI implementation contract stands out with its versatile features. It handles an ERC20 token that can be paused, minted, and burned. It’s controlled by a central <strong>SupplyController</strong>. The contract also includes ways to protect assets, control supply, and delegate transfers. This article provides a straightforward breakdown of what the contract does and points out potential risks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IwqhwpSqTS8Yxxfo" /><figcaption>Photo by <a href="https://unsplash.com/@asyfaul?utm_source=medium&amp;utm_medium=referral">Muhammad Asyfaul</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Sources</h3><h4><strong>Proxy contract address</strong></h4><p><a href="https://etherscan.io/address/0x6c3ea9036406852006290770bedfcaba0e23a0e8#code">https://etherscan.io/address/0x6c3ea9036406852006290770bedfcaba0e23a0e8#code</a></p><h4><strong>Implementation contract address</strong></h4><p><a href="https://etherscan.io/address/0xe17b8adf8e46b15f3f9ab4bb9e3b6e31db09126e#code">https://etherscan.io/address/0xe17b8adf8e46b15f3f9ab4bb9e3b6e31db09126e#code</a></p><h4>GitHub repository</h4><p><a href="https://github.com/paxosglobal/pyusd-contract/blob/master/contracts/PYUSDImplementation.sol">https://github.com/paxosglobal/pyusd-contract/blob/master/contracts/PYUSDImplementation.sol</a></p><h3>Smart Contract Odyssey: Navigating Solidity Versions, Proxies, and Account Control</h3><h4><strong>1. “Outdated” Solidity Version (0.4.24)</strong></h4><p>pragma solidity 0.4.24;</p><p>When considering the Solidity version for the PYUSD stablecoin implementation, the choice between Solidity 0.4.24 and 0.8.x revolves around a trade-off between established reliability and cutting-edge capabilities. Opting for Solidity 0.4.24 provides a stable and proven foundation, ensuring compatibility with existing systems and libraries. Conversely, adopting Solidity 0.8.x offers a host of advanced features, heightened security protocols, and performance optimizations. While the former guarantees a well-tested environment, the latter empowers developers with innovations like checked arithmetic, improved error handling, and more sophisticated compiler tools.</p><p><strong>It’s important to recognize that this choice doesn’t necessarily pose a potential risk</strong>. Instead, it represents a robust measure akin to the prudent approach adopted by established organizations like PayPal. The decision hinges on the project’s specific requirements and priorities, balancing the reliability of a tried-and-true version with the advanced capabilities offered by the latest iteration.</p><h4>2. Proxy Pattern and Upgradeability:</h4><p>As we dive into the PYUSD smart contract, we come across two important contracts: the “<strong>implementation contract</strong>” (that’s where the logic/rules are) and the “<strong>proxy contract</strong>” (that holds all the layout/storage of the contract). This setup, showcased by the <strong>UpgradeabilityProxy </strong>and <strong>AdminUpgradeabilityProxy </strong>contracts, brings clear benefits and things to think about:</p><pre>/**<br> * @title AdminUpgradeabilityProxy<br> * @dev This contract combines an upgradeability proxy with an authorization<br> * mechanism for administrative tasks.<br> * All external functions in this contract must be guarded by the<br> * `ifAdmin` modifier.<br> */<br>contract AdminUpgradeabilityProxy is UpgradeabilityProxy {<br>    bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b;<br><br>    modifier ifAdmin() {<br>        if (msg.sender == _admin()) {<br>            _;<br>        } else {<br>            _fallback();<br>        }<br>    }<br><br>    constructor(address _implementation) UpgradeabilityProxy(_implementation) public {<br>        assert(ADMIN_SLOT == keccak256(&quot;org.zeppelinos.proxy.admin&quot;));<br>        _setAdmin(msg.sender);<br>    }<br><br>    // Functions to manage admin and implementation<br>    function _admin() internal view returns (address adm) { ... }<br>    function _setAdmin(address newAdmin) internal { ... }<br>    function upgradeTo(address newImplementation) external ifAdmin { ... }<br>}</pre><p><strong>Advantages:</strong></p><p><strong>a. Upgradeability:</strong> Proxies enable you to modify the contract’s logic without changing its address. This allows for seamless upgrades, enhancing the contract’s capabilities without interrupting its usage.</p><p><strong>b. Administrative Control: </strong>The AdminUpgradeabilityProxy introduces an authorization mechanism via the <em>ifAdmin</em> modifier. This feature empowers specific addresses to manage upgrades and administrative actions.</p><p><strong>Considerations:</strong></p><p><strong>a. Complexity:</strong> Proxies introduce an additional layer of complexity to the contract’s architecture. While enabling upgrades, this complexity can make the contract harder to understand, debug, and secure.</p><p><strong>b. Auditing and Testing</strong>: The use of proxies necessitates thorough auditing and comprehensive testing. Ensuring the proper implementation of upgrade mechanisms and guarding against potential vulnerabilities is crucial.</p><p><strong>c. Dependency on Libraries:</strong> Proxies may rely on external libraries or tools. Ensuring compatibility and support for these dependencies is important for maintaining a stable and secure contract.</p><p><strong>d. Risk Mitigation:</strong> While proxies themselves can add a level of security, improper management or vulnerabilities in the proxy implementation could lead to unknown risks.</p><p><strong>e. Whitelisting and Centralization:</strong> The contract has beta delegate whitelisting. Some addresses get special transfer powers. This could lead to centralization if not managed well.</p><h4>3. Whitelisting and Freezing accounts</h4><p>Frozen accounts can’t execute transfers, here it’s the compliant and centralized part of the token.</p><p>There is a main <strong>AssetProtectionRole</strong> (that is currently the<strong> owner</strong> as well<strong>) </strong>that has literally control over the whole token (it can <strong>freeze </strong>and <strong>whitelist </strong>accounts)</p><p><strong>AssetProtectionRole: </strong>0x0644Bd0248d5F89e4F6E845a91D15c23591e5D33</p><pre>    /**<br>     * @dev Freezes an address balance from being transferred.<br>     * @param _addr The new address to freeze.<br>     */<br>    function freeze(address _addr) public onlyAssetProtectionRole {w<br>        require(!frozen[_addr], &quot;address already frozen&quot;);<br>        frozen[_addr] = true;<br>        emit AddressFrozen(_addr);<br>    }</pre><pre>require(!frozen[_to] &amp;&amp; !frozen[msg.sender], &quot;address frozen&quot;);</pre><p>This <strong>require() </strong>check is implemented in most of the functions, freezing specific accounts to do any type of interaction with PYUSD.</p><pre>    /*    <br>    * @dev Transfer token to a specified address from msg.sender<br>    * Note: the use of Safemath ensures that _value is nonnegative.<br>    * @param _to The address to transfer to.<br>    * @param _value The amount to be transferred.<br>    */<br>    function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {<br>        require(_to != address(0), &quot;cannot transfer to address zero&quot;);<br>        require(!frozen[_to] &amp;&amp; !frozen[msg.sender], &quot;address frozen&quot;); //COMPLIANT + DANGER HERE<br>        require(_value &lt;= balances[msg.sender], &quot;insufficient funds&quot;);<br><br>        balances[msg.sender] = balances[msg.sender].sub(_value);<br>        balances[_to] = balances[_to].add(_value);<br>        emit Transfer(msg.sender, _to, _value);<br>        return true;<br>    }</pre><p>The incorporation of whitelisting and freezing capabilities within the smart contract introduces a dual-edged potential impact. On one hand, these features can significantly bolster security and risk management by allowing the contract owner to restrict or control specific addresses’ actions. <strong>Whitelisting </strong>can enable the authorization of trusted entities, enhancing the contract’s usability for designated purposes. <strong>Freezing</strong>, on the other hand, empowers the contract owner to safeguard against unauthorized or suspicious activities, acting as a protective measure against potential threats.</p><p>However, it is essential to recognize that these capabilities could also raise concerns related to centralization and potential misuse of power. Striking a balance between enhancing security and ensuring decentralization remains pivotal. Thorough assessment, transparency, and proper governance mechanisms are vital to leveraging these functionalities effectively and responsibly within the contract ecosystem.</p><h3>Conclusion</h3><p>In summary, the PYUSD Smart Contract Implementation brings practical insights. The choice of Solidity version balances reliability with advanced features. The Proxy Pattern enables smooth upgrades and control, but demands thorough testing. Whitelisting and freezing boost security, yet centralization risks need attention. PYUSD’s example teaches us to balance <strong>innovation </strong>and <strong>compliance </strong>responsibly. As we evolve, let’s stay practical, transparent, and focused on efficient decentralized finance solutions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da72286043f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/unlocking-pyusds-smart-contract-secrets-innovation-centralization-and-security-with-code-da72286043f0">Unlocking PYUSD’s Smart Contract Secrets: Balancing Compliance and Innovation [With code snippets]</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PayPal USD (PYUSD) Stablecoin: Technical Overview of the Smart Contract [No code]]]></title>
            <link>https://medium.com/@santiagodevrel/paypal-usd-pyusd-stablecoin-technical-overview-of-the-smart-contract-no-code-739a00711e76?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/739a00711e76</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[stable-coin]]></category>
            <category><![CDATA[paypal]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Wed, 09 Aug 2023 17:34:33 GMT</pubDate>
            <atom:updated>2023-08-09T17:34:33.450Z</atom:updated>
            <content:encoded><![CDATA[<p>PayPal’s entry into the stablecoin market with PYUSD involves the deployment of a robust smart contract on the Ethereum blockchain. This report provides a detailed technical overview of the PYUSD smart contract, its functionality, and the underlying mechanisms that enable the stablecoin’s operation.</p><h4>Smart Contract Basics</h4><p>The PYUSD stablecoin is represented by an ERC-20-compliant smart contract deployed on the Ethereum blockchain. This contract facilitates the issuance, transfer, and management of PYUSD tokens. Let’s delve into the key technical aspects of the PYUSD smart contract:</p><p><strong>ERC-20 Implementation:</strong> The PYUSD smart contract adheres to the ERC-20 standard, following the specifications outlined in Ethereum Improvement Proposal (EIP) 20. This standard ensures interoperability with various wallets, exchanges, and dApps in the Ethereum ecosystem.</p><p><strong>Token Information:</strong> The contract provides essential functions to retrieve information about the token, such as its name, symbol, and decimal places. These functions enable users and applications to interact with the token effectively.</p><p><strong>Token Transfers: </strong>The contract includes functions for transferring PYUSD tokens between addresses. The transfer, transferFrom, and related functions allow users to initiate and verify token transfers.</p><p><strong>Approval Mechanism:</strong> Users can approve third-party addresses to spend a certain amount of their PYUSD tokens using the approve function. This mechanism is crucial for enabling features like decentralized exchanges and other interactions that require token spending authorization.</p><p><strong>Supply Control: </strong>The total supply of PYUSD tokens is managed by a supply controller address. This address has the authority to mint and burn tokens based on the actual movement of USD funds held in reserve by Paxos Trust Company.</p><p><strong>Pause Mechanism: </strong>The contract can be paused to prevent transfers and approvals in the event of a security threat. This capability is controlled by an owner role and follows the OpenZeppelin Pausable pattern.</p><p><strong>Asset Protection Role:</strong> The contract includes an assetProtectionRole that can freeze or unfreeze the balance of any address on the chain. This role is in line with regulatory requirements and serves to protect against criminal activities.</p><p><strong>BetaDelegatedTransfer: </strong>To allow gas-less transactions, the contract implements a variation of EIP-865 through the betaDelegatedTransfer and betaDelegatedTransferBatch functions. These functions enable approved parties to transfer PYUSD on behalf of end users using signed messages.</p><p><strong>Upgradeability: </strong>The contract is designed for upgradeability using the AdminUpgradeabilityProxy from ZeppelinOS. This allows for seamless updates to the contract’s logic without affecting its data or contract address.</p><p>Bytecode Verification: The contract’s bytecode has been verified on Etherscan to ensure its integrity and authenticity.</p><p><strong>Conclusion</strong></p><p>The PYUSD stablecoin’s smart contract on the Ethereum blockchain provides a comprehensive infrastructure for issuing, managing, and transferring the stablecoin. Leveraging the ERC-20 standard and incorporating features such as supply control, pausing, and asset protection, the contract ensures the secure and reliable operation of PYUSD within the Ethereum ecosystem. Additionally, the implementation of upgradeability mechanisms demonstrates a forward-looking approach to potential improvements and enhancements in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=739a00711e76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Guide: Deploying & Interacting with a Smart Contract using Hardhat]]></title>
            <link>https://medium.com/@santiagodevrel/quick-guide-deploying-interacting-with-a-smart-contract-using-hardhat-f8a4a56a06f7?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8a4a56a06f7</guid>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[solidity-tutorial]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Sat, 05 Aug 2023 21:54:44 GMT</pubDate>
            <atom:updated>2023-08-05T21:54:44.187Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re a developer looking to deploy your first smart contract using Hardhat, this guide is for you. I’ll walk you through the process step-by-step, from setting up your project to deploying your contract on the Ethereum network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*KzruHXglQsgb4z0B-b74RA.png" /></figure><p>Prerequisites:</p><ul><li><strong>Basic understanding of Ethereum and smart contracts.</strong></li><li><strong>Node.js and npm installed on your machine.</strong></li></ul><h4>Step 1: Project Setup</h4><ol><li>Create a new project directory:</li></ol><pre>mkdir smart-contract-guide <br><br></pre><pre>cd smart-contract-guide</pre><p>2. Initialize a Node.js project and install Hardhat:</p><pre>npm init -y </pre><pre>npm install --save-dev hardhat</pre><h4>Step 2: Write the Smart Contract</h4><ol><li>In your project directory, create a file named SimpleContract.so</li></ol><pre>pragma solidity ^0.8.0;<br>contract SimpleContract {<br>    string private message;    <br>    <br>    //function to set a message in the message variable<br>    function setMessage(string memory _message) external {<br>        message = _message;<br>    }<br>    <br>    //function to retrieve the message set in the message variable<br>    function getMessage() external view returns (string memory) {<br>        return message;<br>    }<br>}</pre><h4>Step 3: Deployment Script</h4><ol><li>Inside the scripts directory, create a file named deploy.js:</li></ol><pre>const hre = require(&quot;hardhat&quot;);<br><br>async function main() {<br>  try {<br>    // Get the ContractFactory of your SimpleContract<br>    const SimpleContract = await hre.ethers.getContractFactory(&quot;SimpleContract&quot;);<br><br>    // Deploy the contract<br>    const contract = await SimpleContract.deploy();<br><br>    // Wait for the deployment transaction to be mined<br>    await contract.deployed();<br><br>    console.log(`SimpleContract deployed to: ${contract.address}`);<br>  } catch (error) {<br>    console.error(error);<br>    process.exit(1);<br>  }<br>}<br><br>main();</pre><h4>Step 4: Configure Hardhat</h4><ol><li>Create a file named hardhat.config.js:</li></ol><pre>module.exports = {<br>  solidity: &quot;0.8.0&quot;,<br>  networks: {<br>    // Define your networks here, such as &quot;sepolia&quot;, &quot;goerli&quot;, &quot;mainnet&quot;, etc.<br>    // Example:<br>    // sepolia: {<br>    //   url: &quot;&lt;SEPOLIA_RPC_URL&gt;&quot;,<br>    //   accounts: [&quot;0xYOUR_PRIVATE_KEY&quot;],<br>    // },<br>  },<br>};</pre><h4>Step 5: Deploy Your Contract</h4><ol><li>Open a terminal and navigate to your project directory.</li><li>Compile and deploy the contract to the Ethereum network:</li></ol><pre>npx hardhat run scripts/deploy.js --network &lt;network-name&gt;</pre><p>Replace &lt;network-name&gt; with the Ethereum network, you want (e.g., sepolia, goerli, mainnet).</p><p><strong>NOTE: Make sure you have enough funds in your wallet</strong></p><h4>Step 6: Create an Interaction Script</h4><ol><li>Inside the scripts directory, create a file named interact.js.</li><li>Add the following code to the interact.js file:</li></ol><pre>const hre = require(&quot;hardhat&quot;);<br><br>async function main() {<br>  try {<br>    // Get the ContractFactory of your SimpleContract<br>    const SimpleContract = await hre.ethers.getContractFactory(&quot;SimpleContract&quot;);<br><br>    // Connect to the deployed contract<br>    const contractAddress = &quot;&lt;DEPLOYED_CONTRACT_ADDRESS&gt;&quot;; // Replace with your deployed contract address<br>    const contract = await SimpleContract.attach(contractAddress);<br><br>    // Set a new message in the contract<br>    const newMessage = &quot;Hello, Hardhat!&quot;;<br>    await contract.setMessage(newMessage);<br><br>    // Retrieve the updated message<br>    const updatedMessage = await contract.getMessage();<br>    console.log(&quot;Updated Message:&quot;, updatedMessage);<br>  } catch (error) {<br>    console.error(error);<br>    process.exit(1);<br>  }<br>}<br><br>main();</pre><h4>Step 7: Run the Interaction Script</h4><ol><li>Open a terminal and navigate to your project directory.</li><li>Run the interaction script:</li></ol><pre>npx hardhat run scripts/interact.js --network &lt;network-name&gt;</pre><p>Replace &lt;network-name&gt; with the Ethereum network you&#39;re using (e.g., sepolia, goerli, mainnet).</p><p><strong>The script will set a new message in your deployed contract and retrieve the updated message.</strong></p><p>Congratulations! 🎉 You’ve completed the guide on deploying and interacting with a simple smart contract using Hardhat. This hands-on experience sets you on the path to exploring more complex contract functionality and advanced features.</p><p>Keep exploring the exciting world of Ethereum smart contracts and enjoy your coding journey! 💡🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8a4a56a06f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Simple Registration Contract in Solidity: A Step-by-Step Guide]]></title>
            <link>https://medium.com/coinmonks/building-a-simple-registration-contract-in-solidity-a-step-by-step-guide-636af44f1892?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/636af44f1892</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity-tutorial]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Sun, 16 Jul 2023 23:02:08 GMT</pubDate>
            <atom:updated>2023-07-21T07:57:31.475Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>Solidity, a programming language specifically designed for developing smart contracts on the EVMs blockchains, empowers developers to create decentralized applications with self-executing code. In this article, we will explore how to build a simple registration contract using Solidity. We will walk through the code implementation, explaining each step along the way.</p><h4>Prerequisites</h4><p>To follow along with this guide, you will need the following:</p><ul><li><a href="https://remix.ethereum.org/">Remix IDE</a>: Set up the Remix IDE, which provides an integrated development environment for Solidity development.</li></ul><h4>Step 1</h4><p>Contract Structure Let’s start by defining the structure of our registration contract:</p><pre>pragma solidity ^0.8.0;<br>contract Registration {<br>    // Variables, events, and functions will be defined here.<br>}  </pre><h4>Step 2</h4><p>Declare Variables Next, let’s declare the variables needed for our registration contract:</p><pre>contract Registration {<br>    mapping(address =&gt; bool) public registeredUsers;<br>    uint256 public totalRegisteredUsers;<br>    <br>    // Constructor<br>    constructor() {<br>        totalRegisteredUsers = 0;<br>    }<br>    <br>    // Functions will be defined here.<br>}</pre><p>In this example, we use a mapping called registeredUsers to keep track of registered users by their Ethereum addresses. We also declare a totalRegisteredUsers variable to store the count of registered users.</p><h4>Step 3:</h4><p>Implement the Registration Function Now, let’s implement the registration function that allows users to register themselves:</p><pre>contract Registration {<br>    // Previous code<br>    <br>    function register() public {<br>        require(!registeredUsers[msg.sender], &quot;Already registered&quot;);<br>        <br>        registeredUsers[msg.sender] = true;<br>        totalRegisteredUsers++;<br>    }<br>    <br>    // Additional functions if needed<br>}</pre><p>Here, the register function checks if the user is not already registered by verifying the registeredUsers mapping. If the user is not registered, their Ethereum address is added to the mapping, and the totalRegisteredUsers count is incremented.</p><h4>Step 4</h4><p>Adding Event for Registration To provide additional information when a user registers, let’s add an event to our contract:</p><pre>contract Registration {<br>    // Previous code<br>    <br>    event UserRegistered(address indexed user);<br>    <br>    function register() public {<br>        // Previous code<br>        <br>        emit UserRegistered(msg.sender);<br>    }<br>    <br>    // Additional functions if needed<br>}</pre><p>The UserRegistered event emits the address of the user who successfully registers. This event can be listened to by external applications to perform further actions when a user registers.</p><h4>Conclusion</h4><p>Congratulations! You have successfully built a simple registration contract using Solidity. This example demonstrates the core concepts of Solidity programming, including contract structure, variable declaration, function implementation, and event usage. With this foundation, you can expand the functionality of the contract to suit your specific use case.</p><p>To deploy the contract and interact with it, you can use the Remix IDE. For more detailed instructions on deployment and testing, refer to this article: <a href="https://medium.com/@santiagotrujilloz/getting-started-with-smart-contract-development-in-solidity-a-beginners-guide-with-code-snippets-f3d0c8daf95b">Getting Started with Smart Contract Development in Solidity: A Beginner’s Guide with code snippets</a></p><p><em>Note: This article provides a simplified example for educational purposes. In a real-world scenario, additional considerations, such as access control, data validation, and error handling, should be taken into account.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=636af44f1892" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/building-a-simple-registration-contract-in-solidity-a-step-by-step-guide-636af44f1892">Building a Simple Registration Contract in Solidity: A Step-by-Step Guide</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Popular Opcodes in EVM: A Guide to Ethereum Virtual Machine]]></title>
            <link>https://medium.com/@santiagodevrel/popular-opcodes-in-evm-a-guide-to-ethereum-virtual-machine-2b58cc8d2738?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b58cc8d2738</guid>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[opcodes]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Sat, 15 Jul 2023 23:29:32 GMT</pubDate>
            <atom:updated>2023-07-15T23:29:32.870Z</atom:updated>
            <content:encoded><![CDATA[<p>The Ethereum Virtual Machine (EVM) is the runtime environment for executing smart contracts on the Ethereum blockchain. It operates using a set of instructions known as opcodes, which define the operations that can be performed by the EVM. In this article, we will explore five popular opcodes in the EVM and provide examples to help you understand their functionalities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M5O3WPBlXHiSRWUg" /><figcaption>Photo by <a href="https://unsplash.com/@theshubhamdhage?utm_source=medium&amp;utm_medium=referral">Shubham Dhage</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>PUSH</h4><p>The PUSH opcode is used to push a value onto the stack. The value can be a small integer or a sequence of bytes. The PUSH opcode is followed by a byte that specifies the number of bytes to be pushed onto the stack. For example, PUSH1 0x05 pushes the value 0x05 onto the stack, while PUSH4 0x01234567 pushes the 32-bit value 0x01234567 onto the stack.</p><p>Example:</p><pre>PUSH1 0x05<br>PUSH1 0x03<br>ADD</pre><p>Explanation: The above example pushes the values 0x05 and 0x03 onto the stack and then performs an addition operation using the ADD opcode. The result, 0x08, is left on the stack.</p><h4>POP</h4><p>The POP opcode removes the top value from the stack. It is useful for discarding unnecessary values and cleaning up the stack after an operation. Since the EVM operates on a stack-based model, removing unnecessary values helps optimize gas costs and storage.</p><p>Example:</p><pre>PUSH1 0x05<br>PUSH1 0x03<br>ADD<br>POP</pre><p>Explanation: In this example, the result of the addition operation (0x08) is removed from the stack using the POP opcode. This ensures that the stack remains clean and only contains the necessary values.</p><h4>SSTORE</h4><p>The SSTORE opcode is used to store a value in the contract’s storage. It takes two arguments: the storage key and the value to be stored. The storage key is typically generated by hashing a combination of the contract’s address and other relevant data.</p><p>Example:</p><pre>PUSH1 0x01<br>PUSH1 0x10<br>SSTORE</pre><p>Explanation: The above example stores the value 0x10 at the storage location associated with the key 0x01. This opcode is crucial for persistently storing data within a smart contract.</p><h4>JUMP</h4><p>The JUMP opcode is used to alter the flow of execution by jumping to a different position in the code. It takes the destination position as its argument, which is typically specified as an offset relative to the current position.</p><p>Example:</p><pre>USH1 0x03<br>JUMP<br>PUSH1 0x01</pre><p>Explanation: In this example, the JUMP opcode is used to skip the PUSH1 0x01 instruction and directly jump to the PUSH1 0x03 instruction. This allows for conditional and unconditional jumps within the code, enabling more complex program flow.</p><h4>CALL</h4><p>The CALL opcode is used to invoke other smart contracts or external accounts. It takes several arguments, including the gas limit, recipient address, value to transfer, input data, and more. It allows for interactions with other contracts and can facilitate complex interactions within the Ethereum ecosystem.</p><p>Example:</p><pre>PUSH1 0x02<br>PUSH1 0x00<br>CALL</pre><p>Explanation: The above example initiates a CALL to the contract located at address 0x02 with no value to transfer. The CALL opcode enables interactions with other contracts and external accounts, such as transferring funds or retrieving data.</p><h4>Conclusion</h4><p>Understanding the popular opcodes in the Ethereum Virtual Machine (EVM) is essential for developing smart contracts and interacting with the Ethereum blockchain. The five opcodes discussed in this article — PUSH, POP, SSTORE, JUMP, and CALL — provide a glimpse into the versatility and power of the EVM. By leveraging these opcodes effectively, developers can create complex and powerful decentralized applications on EVM-compatible blockchains.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b58cc8d2738" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Smart Contract Development in Solidity: A Beginner’s Guide with code snippets]]></title>
            <link>https://medium.com/@santiagodevrel/getting-started-with-smart-contract-development-in-solidity-a-beginners-guide-with-code-snippets-f3d0c8daf95b?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3d0c8daf95b</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity-tutorial]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Sat, 15 Jul 2023 14:27:21 GMT</pubDate>
            <atom:updated>2023-07-15T14:27:21.419Z</atom:updated>
            <content:encoded><![CDATA[<p>Smart contracts are the backbone of decentralized applications on the blockchain. In this article, I will walk you through the process of writing your first smart contract using Solidity, the programming language for Ethereum. We will provide step-by-step instructions and explain each code snippet with comments to help beginners grasp the fundamentals of smart contract development.</p><h4>Prerequisites</h4><p>Before diving into writing your first smart contract, make sure you have basic knowledge of programming concepts and familiarity with any programming language. Additionally, set up a development environment for an Ethereum client like <a href="https://remix.ethereum.org/">RemixIDE</a> to write and deploy your smart contracts.</p><h4>Step 1:</h4><p>Contract Declaration and State Variables Begin by declaring your contract and defining the state variables that will store data. These variables hold the state of your smart contract and can be accessed by the contract’s functions.</p><pre>// Contract declaration<br>contract MyFirstContract {<br>    <br>    // State variables<br>    uint256 public myNumber;<br>    string public myString;<br>}</pre><h4>Step 2:</h4><p>Constructor and Initialization Add a constructor function to initialize the state variables when the contract is deployed. The constructor runs only once during deployment and is used to set an initial state.</p><pre>// Contract declaration<br>contract MyFirstContract {<br>    <br>  // State variables<br>  uint256 public myNumber;<br>  string public myString;<br><br>  constructor() {<br>      myNumber = 100;<br>      myString = &quot;Hello, World!&quot;;<br>  }<br><br>}<br></pre><h4>Step 3:</h4><p>Function Declarations and Modifiers Define functions that allow interaction with the smart contract. Functions can be used to read or modify the state variables and perform specific operations.</p><pre>// Contract declaration<br>contract MyFirstContract {<br>    <br>  // State variables<br>  uint256 public myNumber;<br>  string public myString;<br><br>  constructor() {<br>      myNumber = 100;<br>      myString = &quot;Hello, World!&quot;;<br>  }<br><br>  // Function to update the myNumber variable<br>  function updateNumber(uint256 _newNumber) public {<br>      myNumber = _newNumber;<br>  }<br><br>  // Function to retrieve the myString variable<br>  function getString() public view returns (string memory) {<br>      return myString;<br>  }<br><br>}<br></pre><h4>Step 4:</h4><p>Testing and Deployment Using your development environment, compile and deploy the smart contract to an Ethereum network or a local blockchain. Interact with the contract by calling its functions and observing the changes in state variables.</p><p>Compilation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fI4B9aNZqu5UtNj4O4SWPw.png" /></figure><p>Deployment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FHzlcwkHC0N8yg0aXC0XCA.png" /></figure><p>Testing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LfdMCMu9vrn-e1KozCxjAQ.png" /></figure><h4>Conclusion</h4><p>Congratulations! You’ve written your first smart contract in Solidity. By following this beginner’s guide and understanding the code snippets explained with comments, you’ve taken your first steps into the exciting world of smart contract development. Continue exploring Solidity’s capabilities and dive deeper into blockchain programming to build more sophisticated and impactful decentralized applications.</p><p><strong>Note:</strong><em> The provided code snippets are for educational purposes and may not include all necessary security and error-handling mechanisms. Always ensure thorough testing and best practices when deploying smart contracts to production environments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3d0c8daf95b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solidity Data Structures: Exploring Mappings, Structs, and Arrays with code snippets]]></title>
            <link>https://medium.com/@santiagodevrel/solidity-data-structures-exploring-mappings-structs-and-arrays-with-code-snippets-3fdaf5b30854?source=rss-ab56f97886ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fdaf5b30854</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[solidity-tutorial]]></category>
            <category><![CDATA[solidity-development]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Santiago Trujillo Zuluaga]]></dc:creator>
            <pubDate>Sat, 15 Jul 2023 14:04:31 GMT</pubDate>
            <atom:updated>2023-07-15T14:04:31.932Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will delve into the core data structures in Solidity, including mappings, structs, and arrays. Understanding how to use these data structures effectively will empower you to build robust and scalable smart contracts on the Ethereum blockchain.</p><h4><strong>1. Mappings</strong></h4><p>Mappings are key-value pairs that allow efficient storage and retrieval of data. Learn how to declare, initialize, and use mappings to create associative arrays in Solidity. Explore various use cases where mappings excel, such as maintaining user balances, tracking ownership, or creating lookup tables.</p><pre>// Declaration and initialization of a mapping<br>mapping(address =&gt; uint256) public balances;<br><br>// Accessing and modifying values in a mapping<br>balances[msg.sender] = 100; // Assigning a value to the sender&#39;s address<br>uint256 myBalance = balances[msg.sender]; // Retrieving the sender&#39;s balance</pre><h4><strong>2. Structs</strong></h4><p>Structs enable the creation of custom data types in Solidity. Discover how to define and utilize structs to encapsulate related variables into a single composite data structure. Explore the flexibility and organization that structs bring to your smart contracts, allowing you to create complex data representations and user-defined types.</p><pre>// Declaration of a struct<br>struct Person {<br>    string name;<br>    uint256 age;<br>}<br><br>// Creating and using struct instances<br>Person public alice = Person(&quot;Alice&quot;, 25);<br>Person public bob = Person(&quot;Bob&quot;, 30);</pre><h4><strong>3. Arrays</strong></h4><p>Solidity provides different types of arrays, including dynamic arrays and fixed-size arrays. Learn how to declare, initialize, and manipulate arrays in Solidity. Dive into concepts like array length, accessing array elements, iterating over arrays, and working with multi-dimensional arrays. Understand the memory implications and gas costs associated with array operations.</p><pre>// Declaration and initialization of dynamic arrays<br>uint256[] public numbers;<br>numbers.push(10); // Adding an element to the array<br>numbers.push(20);<br>numbers.push(30);<br><br>// Accessing array elements<br>uint256 secondNumber = numbers[1]; // Accessing the second element (index 1)<br><br>// Declaration and initialization of fixed-size arrays<br>uint256[3] public fixedArray = [10, 20, 30];<br><br>// Iterating over an array<br>for (uint256 i = 0; i &lt; numbers.length; i++) {<br>    // Accessing each element of the dynamic array<br>    uint256 currentNumber = numbers[i];<br>    // Perform operations with the current element<br>}</pre><h4>4. <strong>Mapping with Structs and Arrays</strong></h4><p>Combine the power of mappings, structs, and arrays to create advanced data structures in Solidity. Explore scenarios where you might use mappings of structs or arrays of structs to build more sophisticated contract logic. Understand how these combinations can enhance the efficiency and flexibility of your smart contract designs.</p><pre>// Declaration of a struct<br>struct Person {<br>    string name;<br>    uint256 age;<br>}<br><br>// Declaration of a mapping with struct values<br>mapping(address =&gt; Person) public people;<br><br>// Adding struct instances to the mapping<br>function addPerson(address _address, string memory _name, uint256 _age) public {<br>    Person memory newPerson = Person(_name, _age);<br>    people[_address] = newPerson;<br>}<br><br>// Accessing struct members within the mapping<br>function getPersonName(address _address) public view returns (string memory) {<br>    return people[_address].name;<br>}<br><br>// Using arrays within a struct<br>struct Group {<br>    string name;<br>    uint256[] memberIds;<br>}<br><br>// Adding an array to the struct and updating values<br>Group public myGroup;<br>myGroup.name = &quot;My Group&quot;;<br>myGroup.memberIds.push(1);<br>myGroup.memberIds.push(2);<br>myGroup.memberIds.push(3);<br><br>// Accessing array elements within the struct<br>function getGroupMemberId(uint256 index) public view returns (uint256) {<br>    return myGroup.memberIds[index];<br>}</pre><h4>Conclusion</h4><p>Solidity provides a rich set of data structures that allow developers to efficiently manage and manipulate data within smart contracts. By mastering mappings, structs, and arrays, you unlock powerful capabilities to design complex contract logic and optimize gas usage. Embrace best practices and explore the limitless possibilities that Solidity data structures offer in building robust and scalable decentralized applications on the Ethereum blockchain.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fdaf5b30854" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>