<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Justice Sunday </title>
    <description>The latest articles on DEV Community by Justice Sunday  (@zuru122).</description>
    <link>https://dev.to/zuru122</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1214390%2F2d24caf4-9a87-4d38-a41c-05190e3e8ebe.png</url>
      <title>DEV Community: Justice Sunday </title>
      <link>https://dev.to/zuru122</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zuru122"/>
    <language>en</language>
    <item>
      <title>Solidity Alchemy - Course (ESCROW SMART CONTRACT)</title>
      <dc:creator>Justice Sunday </dc:creator>
      <pubDate>Sat, 01 Jun 2024 15:34:13 +0000</pubDate>
      <link>https://dev.to/zuru122/solidity-alchemy-course-escrow-smart-contract-55ek</link>
      <guid>https://dev.to/zuru122/solidity-alchemy-course-escrow-smart-contract-55ek</guid>
      <description>&lt;p&gt;The escrow smart contract is a system used for transferring funds upon the fulfillment of an agreement. Traditionally, this involves a third party, but in this case, the third party is an honest one facilitated by the smart contract. This contract involves three parties: the Depositor, the Arbiter, and the Beneficiary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Depositor:&lt;/strong&gt; The payer in the escrow agreement.&lt;br&gt;
&lt;strong&gt;Beneficiary:&lt;/strong&gt; The recipient of the funds from the escrow after the Arbiter confirms the transaction, typically for providing some service to the Depositor.&lt;br&gt;
&lt;strong&gt;Arbiter:&lt;/strong&gt; The trusted middleman responsible for approving the transaction. The Arbiter ensures the goods or services are received before releasing the funds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;From the lessons at Alchemy University, I learned to create an escrow smart contract with the following key components:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;State Variables:&lt;/strong&gt; Understanding and declaring variables that store the contract's state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Constructor:&lt;/strong&gt; Initializing the contract with specific parameters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Payable Constructor:&lt;/strong&gt; Allowing the constructor to handle Ether transactions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Functions:&lt;/strong&gt; Implementing the contract's logic through functions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function Security:&lt;/strong&gt; Restricting function calls to specific addresses for security purposes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Events:&lt;/strong&gt; Emitting events to log significant actions in the contract.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Here's a sample implementation of an escrow smart contract in Solidity:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;


contract Escrow {
    address public depositor;
    address public beneficiary;
    address public arbiter;

    constructor(address _arbiter, address _beneficiary)payable{
        depositor = msg.sender;
        arbiter = _arbiter;
        beneficiary = _beneficiary;
    }

    function approve()external  {
    //check if the caller of the function is the arbiter.
        require(msg.sender == arbiter, "Only arbiter can approve");
        uint balance = address(this).balance;
        payable(beneficiary).transfer(balance);
        emit Approved(balance);

        }

     event  Approved(uint);

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This contract ensures that only the Arbiter can approve the transfer of funds to the Beneficiary, adding a layer of security and trust to the transaction process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Please, questions and contributions are welcome&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://x.com/zuru122"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://university.alchemy.com/"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>smartcontract</category>
      <category>solidity</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
