<?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 Angella Mulikatete on Medium]]></title>
        <description><![CDATA[Stories by Angella Mulikatete on Medium]]></description>
        <link>https://medium.com/@angellamulikatete?source=rss-b5037d1b1931------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Z6yyrWptEPs-aVwfQaDyXw.jpeg</url>
            <title>Stories by Angella Mulikatete on Medium</title>
            <link>https://medium.com/@angellamulikatete?source=rss-b5037d1b1931------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:14:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@angellamulikatete/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 send ether in solidity: A Comprehensive Guide]]></title>
            <link>https://medium.com/@angellamulikatete/how-to-send-ether-in-solidity-a-comprehensive-guide-e9b8a517f4b1?source=rss-b5037d1b1931------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9b8a517f4b1</guid>
            <dc:creator><![CDATA[Angella Mulikatete]]></dc:creator>
            <pubDate>Thu, 29 Aug 2024 08:27:11 GMT</pubDate>
            <atom:updated>2024-08-29T08:27:11.073Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Kd3w7EA7-uc6FmWpgT0_A.jpeg" /></figure><p>Sending Ether in Solidity is a fundamental aspect of developing decentralized applications (DApps). Ether (ETH) is the native cryptocurrency of the Ethereum blockchain, and understanding how to transfer it securely and efficiently is crucial for any Solidity developer.</p><p>In this article, we will explore the different methods to send Ether, and the best practices to follow to ensure your transactions are safe and effective.</p><p><strong>Introduction to Ether Transfers</strong><br>When programming smart contracts in Solidity, you will encounter scenarios where you need to transfer Ether to Externally Owned Accounts (EOAs) or other smart contracts. There are three primary methods to achieve this: send, transfer, and call.</p><p><strong>send Method</strong><br>The send method allows you to send Ether while consuming 2,300 gas units. If the operation fails, it returns false instead of throwing an exception, allowing your contract to handle the failure.</p><p><strong>When sending ether using send(), the following happens;</strong></p><ul><li>Sends 2,300 gas units.</li><li>Returns a boolean indicating success or failure.</li><li>Does not revert on failure, allowing for custom error handling.</li></ul><p><strong>Transfer Method</strong><br>The transfer method is similar to send but differs in its error-handling approach. If the transfer fails, it automatically reverts the transaction, which can prevent certain issues but also means you have less control over failure cases. It is also limited to forwarding 2,300 gas units, which may not be sufficient for complex operations in the receiving contract.</p><p><strong>When sending ether using transfer(), the following happens;</strong></p><ul><li>Sends 2,300 gas units.</li><li>Automatically reverts the transaction if it fails.</li><li>Limited to simple Ether transfers due to the fixed gas limit.</li></ul><blockquote>If a payment is made, either the fallback() or receive() function in the receiving contract is triggered. This provides the opportunity for the receiving contract to react upon a payment.</blockquote><p><strong>NOTE</strong></p><blockquote>Both send and transfer functions were considered the go-to solution for making payments to EOAs or other smart contracts. But since the amount of gas they forward to the called smart contract is very low, the called smart contract can easily run out of gas. This would make the payment impossible.</blockquote><blockquote>The problem here is that even if the receiving contract is designed carefully not to exceed the gas limit, future changes in the gas costs for some opcodes can break this design.</blockquote><blockquote>Therefore, the recommended way of sending payments is the function call().</blockquote><h3><strong>call() function</strong></h3><p>The call method is the most flexible and recommended way to send Ether in modern Solidity development. Introduced as part of Solidity 0.6.0, call() allows you to specify the amount of gas to forward, making it suitable for more complex operations. However, with great power comes great responsibility: you need to handle errors and potential reentrancy attacks manually.</p><blockquote>A reentrancy attack is a critical vulnerability where an attacker manipulates the contract’s withdrawal process. A reentrancy attack happens when the contract allows a function to be called again before the previous call finishes. This can lead to unexpected behavior and security vulnerabilities.</blockquote><p><strong>When sending ether using call(), the following happens;</strong></p><ul><li>Allows forwarding of a customizable amount of gas.</li><li>Returns both a boolean indicating success and the return data.</li><li>Flexible enough to trigger other functions in the receiving contract.</li><li>Requires careful error handling and reentrancy protection.</li></ul><h4>Why Call is More Preferable</h4><ul><li>Flexibility: call offers more control over the execution environment. You can specify exactly how much gas to use, which is crucial for complex operations.</li><li>Security: Unlike transfer and send, call doesn’t automatically revert on failure. This allows you to handle errors and implement proper error checking.</li><li>Functionality: With call, you’re not limited to just sending Ether. You can trigger specific functions in the receiving contract, providing more functionality.</li><li>Reentrancy Protection: By not reverting on failure, call actually helps protect against reentrancy attacks. Attackers can’t rely on automatic reversion to exploit vulnerabilities.</li><li>Gas Efficiency: When you know exactly how much gas you need, you can optimize the gas usage, potentially saving costs.</li></ul><h4><strong>Solidity code to demonstrate methods used for Ether transfer</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*g7JFonJZfIrJ25megSRKyA.png" /><figcaption>three types of transferring ether</figcaption></figure><h4>Code explanation</h4><p>Line 6: The transferEher function is a payable function and it takes two parameters:</p><ul><li>_to: The Ethereum address of the recipient</li><li>_amount: The amount of Ether to be transferred</li></ul><blockquote>To enable the transfer of Ether within a function, it is necessary to declare the function as payable. This enables the function to accept Ether as part of the transaction and facilitating its transfer to another address.</blockquote><p>Line 7: The require statement ensures that the contract has sufficient balance to fulfill the transfer. If the condition is not met, an error message “Insufficient funds” is thrown and the transfer is halted.</p><p>Line 11: The send function sends the specified amount of Ether to the recipient’s(_to) address.</p><p>Line 12: The require statement is used to check if the transfer was successful. If the transfer fails, the execution will be halted, and the error message “Transaction unsuccessful” will be displayed.</p><p>Line 16: The transfer function sends the specified amount of Ether to the recipient’s (_to) address.</p><p>Line 19: The call function is used to send the specified amount of Ether to the recipient’s address which returns a tuple with two values.</p><ul><li>The first value, callSuccess, is a boolean indicating the success or failure of the call.</li><li>The second value retrieves the returned data from the call, but since we are not interested in capturing it in this case, we leave it empty, using the comma without assigning it to any variable.</li><li>The empty argument triggers the fallback function of the receiving address.</li></ul><p>Line 20: The require statement is used to check if the transfer was successful. If the transfer fails, the execution will be halted, and the error message “Transfer failed” will be displayed.</p><h3>Best Practices for Sending Ether</h3><p>When sending Ether in Solidity, it’s crucial to follow best practices to ensure that your transactions are secure and efficient. Below are some guidelines to keep in mind:</p><ol><li>Input Validation<br> Always validate the input parameters to ensure they meet the required criteria. For instance, check that the receiving address is not a zero address and that the amount of Ether being sent is greater than zero. Use the require function to enforce these checks.</li></ol><p>for example</p><pre>require(recipient != address(0), &quot;Invalid recipient address&quot;);<br>require(amount &gt; 0, &quot;Amount must be greater than zero&quot;);</pre><p>2. Handle Error Conditions<br>Use appropriate error-handling mechanisms to deal with exceptional cases. For instance, when using the call method, always check the returned boolean value to confirm whether the transfer was successful. If not, take necessary actions, such as reverting the transaction or logging the error.</p><pre>(bool success, ) = recipient.call{value: amount}(&quot;&quot;);<br>require(success, &quot;Transfer failed&quot;);</pre><p>3. Gas Optimization<br>Gas is a critical factor in Ethereum transactions. While transfer was traditionally the simplest and safest method, it’s now often considered less reliable due to its fixed gas limit. <strong>call(),</strong> on the other hand, allows you to optimize gas usage by specifying the exact amount needed for the operation.</p><p>In the next part, We are going to see how to receive Ether</p><h4>Conclusion</h4><p>Understanding the methods to send Ether in Solidity is fundamental for any smart contract developer. While send and transfer offer simplicity, <strong>call</strong> provides the flexibility and security needed for modern DApp development. By following best practices and using call appropriately, you can create secure and efficient smart contracts that handle Ether transfers robustly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9b8a517f4b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ERC20 SmartContracts: ERC20 Token Creation and Management]]></title>
            <link>https://medium.com/@angellamulikatete/erc20-smartcontracts-erc20-token-creation-and-management-e62bc95d9b29?source=rss-b5037d1b1931------2</link>
            <guid isPermaLink="false">https://medium.com/p/e62bc95d9b29</guid>
            <dc:creator><![CDATA[Angella Mulikatete]]></dc:creator>
            <pubDate>Tue, 27 Aug 2024 14:02:01 GMT</pubDate>
            <atom:updated>2024-08-27T14:02:01.774Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*GpYtRg4korEiWUQl-Z1wtw.png" /></figure><p>Let us first understand the concept of Tokenization:</p><p><strong>Tokenization</strong> is the process of converting the rights of an asset into a digital token on a blockchain. It involves issuing a blockchain token representing a unit of value or an asset. Tokens digitally represent a real tradable asset.<br>These assets can be physical, like real estate or artwork, or digital, like a share in a company or a utility within a specific ecosystem.</p><p>They offer:</p><ul><li>Ownership representation</li><li>Decentralized participation</li><li>Transaction facilitation</li><li>Diverse asset representation</li></ul><p><strong>What is an ERC-20 token?</strong></p><p>ERC-20 “Ethereum Request for Comment- 20” is a standard for creating and managing fungible tokens on the Ethereum Blockchain.</p><p>The ERC-20 standard arose from a 2015 proposal that was merged into the Ethereum protocol via an Ethereum Improvement Proposal (IEP-20).</p><p>Developers use this standard to build smart contract-enabled tokens that represent assets, ownerships, rights, cryptos, and beyond. ERC-20 enables developers to create tokens that are the same as other tokens.</p><p><strong>Key Features of ERC-20 Token</strong></p><ul><li>Interoperability: ERC20 allows tokens to be compatible with other Ethereum-based applications and wallets. Therefore any contract on the blockchain can theoretically interact and build on top of any other contract on the same blockchain</li><li>Standardized Functions: ERC20 tokens follow a specific set of standards, which means they have a common list of rules and functions. it defines a set of six functions and events that all ERC-20 — compliant tokens must implement, This includes how the tokens can be transferred, how transactions are approved, how users can access data about a token, and the total supply of tokens.</li><li>Fungibility: Each token of ERC20 is interchangeable with every other token of the same type.</li><li>Token Creation: While ERC20 doesn’t specify how tokens are created, it defines how they can be managed once created.</li><li>Transparency: All token transactions and balances are visible on the public ledger so they operate with transparency which makes them easier to audit and verify.</li></ul><h4>How does ERC20 work?</h4><p>At the core, ERC20 outlines the functions that a token contract must <strong><em>Implement</em></strong> to be considered ERC20 compliant. These functions(methods) include:</p><ul><li>totalSupply(): This function returns the total number of tokens in existence. When the limit is reached, the smart contract will refuse to create new tokens</li><li>balanceOf(): Provides account balance of the owner’s account. This function returns the balance of the owner’s account.</li><li>transfer(): Executes transfers of a specified number of tokens from the total supply to a specified address.</li><li>approve(): function approves a spender to spend a certain amount of tokens on behalf of the owner.</li><li>allowance(): This function returns the amount of tokens that an approved spender is allowed to spend on behalf of an owner</li><li>transferFrom(): This function allows a spender to transfer a certain amount of tokens on behalf of the owner.</li></ul><p><strong><em>Note</em></strong><em>: These functions will trigger two events</em></p><p><strong>Events</strong></p><ul><li>Transfer(from, to, value) — It is emitted when tokens are transferred, including zero-value transfers.</li><li>Approval(owner, spender, value) — Emitted on any successful call to approve(spender, value).</li></ul><p><strong>Note: There are three optional functions;</strong></p><ul><li>Name: This method returns the token’s unique name</li><li>Symbol: An abbreviation used as a ticker or for other identification purposes. This method returns the symbol of the token</li><li>Decimals: How many decimal places the token will use, signifying how small an amount can be transferred or owned</li></ul><h3>Use Cases and Varieties of ERC-20 Tokens</h3><p>ERC-20 tokens offer multiple use cases that make them a popular choice for a wide range of applications within the blockchain ecosystem:</p><ul><li>ICO (Initial Coin Offering) Crowdfunding: ERC-20 tokens are widely used for ICOs. They allow projects to raise funds by issuing and distributing their native tokens to investors. <em>for example</em>:- the OmiseGo (OMG) token was issued during an ICO to raise funds for developing their blockchain network</li><li>Tokenized Assets: You can tokenize real-world assets, such as real estate or art, using ERC-20 standards. This enables fractional ownership and increased liquidity.</li><li>Decentralized Exchanges (DEX): Many DEXs utilize ERC-20 tokens for trading pairs. The standardization ensures compatibility across various platforms.</li><li>Utility Tokens: Projects create utility tokens on the ERC-20 standard. These tokens provide access to specific features or services within their platforms.</li></ul><h3>Common ERC20 Tokens</h3><p>Many popular cryptocurrencies use the ERC20 standard, including Tether (USDT), USD Coin(USDC), Chainlink(LINK), Uniswap(UNI), and Wrapped Bitcoin(WBTC).</p><h3>Limitations</h3><ul><li>Centralization: Some argue that ERC20 tokens are too centralized due to the reliance on smart contracts.</li><li>Security Risks: Complex ERC20 token implementations can sometimes lead to security vulnerabilities.</li></ul><p>In the next part, we are going to see how we can interact with the ERC20 token, and how to create a new Token.</p><h3>HOW TO CREATE AN ERC-20 TOKEN</h3><p><strong>Step 1</strong>: Setup the Working Environment</p><p>For the start, we shall be using <a href="https://remix.ethereum.org/">REMIX IDE</a> . This IDE has an already set up environment for you with accounts that contain the testEth that will help you to deploy on a “fake” blockchain, they simulate how your contract will behave once deployed on the real blockchain. But also we can use meta mask wallet for our transaction</p><p>For deployment, one may need to get test eth(Sepolia). First, you need to install web3 wallet for example you can choose to use the meta mask wallet extension. Other wallets include Phantom or WalletConnect.</p><p>To get testEth, you go to <a href="https://faucets.chain.link/">https://faucets.chain.link/</a></p><p><strong>Step 2: Write a Smart Contract:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*2vJn23QqZW3W4PVkUeBxaw.png" /><figcaption>myToken.sol file</figcaption></figure><p><strong>Explanation of the code </strong>🙂</p><p>The SPDX-License-Identifier comment specifies the license under which the contract is released.</p><p>The pragma directive states the compiler version to use.</p><p>The ERC20 contract from OpenZeppelin is imported and used as a base.<br>Our contract reuses the <a href="https://docs.openzeppelin.com/contracts/5.x/api/token/ERC20#erc20">ERC20</a> by using a concept called <a href="https://solidity.readthedocs.io/en/latest/contracts.html#inheritance">inheritance</a>. It extends the ERC20 contract<br>The constructor function initializes your token with a name (“MyToken”) and a symbol (“MTK”).</p><p>The _mint function in the constructor mints an initial supply of tokens. In this example, 1 million tokens are minted and assigned to the address that deploys the contract. The number of tokens is adjusted by the decimal value, which defaults to 18 in the OpenZeppelin implementation.</p><blockquote><strong>NOTE</strong>: <br> Since we import the ERC20 smart contract from OpenZeppelin and the MyToken contract inherits the ERC20 contract, it is not necessary to define all functions. All functions that are defined in the ERC20 contract are imported into the MyToken contract. See more <a href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol">here</a></blockquote><p><strong>Step 3: Deploy</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xT7EyN0w9j3i34aPBHAnpQ.png" /></figure><p>For deployment, use the Injected Provider option under the Environment. Before the deployment, ensure that your MetaMask is set to the Sepolia testnet, and MyToken contract is the selected contract to be deployed. Finally, click on the Deploy button to deploy your contract.</p><p><strong>Step 4: Confirm the transaction in MetaMask</strong></p><p>When you tap on the deploy button, the Metamask wallet is triggered. Tap on confirm so as you confirm your transaction</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*X9slReVn6vLv--SRiyKn7g.png" /></figure><p>Congratulations!! Your token contract is now deployed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*v6WXHmiozytLav3tAwNgaw.png" /></figure><p>Now let us interact with our token: To confirm your contact has been deployed to the blockchain, go to <a href="https://sepolia.etherscan.io/">Etherscan Sepolia</a>, and search by your contract’s address</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-ikjWY6YKTIw_YZG2fNOA.png" /></figure><h3>HOW TO INTERACT WITH ERC-20 TOKENS</h3><p>In this example, we are going to interact with an already existing ERC20 contract called the USDTtoken contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*TvyOzqPYl61NBFwljzl6lg.png" /></figure><p><strong>Explanation of the code </strong>👍<br>Start with The SPDX-License-Identifier comment specifies the license under which the contract is released.// SPDX-License-Identifier: MIT</p><p>Then add The pragma directive states the compiler version to use: <em>forexample</em> pragma solidity ^0.8.0;</p><p>We define the interface for the ERC-20 token we want to interact with. The interface defines the functions that can be called on the token contract.<br> <em>An interface is a way of defining a set of functions that another contract should implement</em>. The interface <strong>doesn’t implement</strong> any of the functions, it just defines the function signatures.<br>We are going to use the interface to create our token, myUSDT.</p><p>After defining the interface for the ERC20, In order to interact with it, you can start calling any functions in our contract using the interface we defined.</p><p>In this example, we are going to interact with an already existing ERC20 contract called the USDTtoken contract and we are to call the balanceOf() and transfer() functions of the existing ERC20 contract (USDT Contract) through our new contract using the interface we defined.</p><p>First define an instance of the IERC20 interface, called usdt. Do this by passing the address of the USDT token contract to the constructor.</p><p>Then define two functions: getUSDTBalance and transferUSDT.<br>The <em>getUSDTBalance</em> function returns the balance of a specified account, it uses the balanceOf function defined in the interface using usdt.balanceOf to get the balance of the USDT.</p><p>The <em>transferUSDT </em>function transfers tokens to a specified recipient, it uses the transfer function defined in the interface using usdt.transfer to transfer the tokens.</p><p>The getUSDTBalance function is marked as public and view, which means it can be called by anyone and it doesn’t modify the state of the contract.</p><p>The transferUSDT function is marked as public, which means it can be called by anyone, and it uses the require statement to make sure the transfer was successful. If the transfer fails, the function will revert and the transfer will not be completed.</p><blockquote><strong>NOTE</strong><br>There are a multitude of ERC20-compliant tokens already operational on the Ethereum blockchain, developed by different groups. These implementations vary, with some focusing on reducing gas costs and others prioritizing enhanced security. For a robust and secure implementation, many developers opt to use <strong>OpenZeppelin’s ERC20 token standard</strong>. OpenZeppelin provides a well-tested, community-audited library of reusable smart contracts, which includes a reliable and secure framework for ERC20 tokens, making it a preferred choice for ensuring compliance and security in token development</blockquote><p><strong>Conclusion</strong><br>ERC20 plays a crucial role in the Ethereum ecosystem by providing a standardized way to create and interact with fungible tokens. Its widespread adoption has made it easier for developers to build applications that work with various cryptocurrencies and tokens, contributing to the growth and diversity of the decentralized finance (DeFi) space.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e62bc95d9b29" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>