<?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 MainnetReady on Medium]]></title>
        <description><![CDATA[Stories by MainnetReady on Medium]]></description>
        <link>https://medium.com/@mainnetready?source=rss-6c02a3264b90------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yaqIOu8roxGUxB4-OZzCrw.png</url>
            <title>Stories by MainnetReady on Medium</title>
            <link>https://medium.com/@mainnetready?source=rss-6c02a3264b90------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:05:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mainnetready/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[Enforcing Royalties on OpenSea and Blur Using ERC721-C]]></title>
            <link>https://medium.com/@mainnetready/enforcing-royalties-on-opensea-and-blur-using-erc721-c-157d314cdae3?source=rss-6c02a3264b90------2</link>
            <guid isPermaLink="false">https://medium.com/p/157d314cdae3</guid>
            <category><![CDATA[opensea]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[MainnetReady]]></dc:creator>
            <pubDate>Thu, 29 May 2025 11:07:47 GMT</pubDate>
            <atom:updated>2025-05-29T11:07:47.680Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CUF7AkrvfhiLDTfcFCVMHQ.png" /></figure><p><a href="https://github.com/DRIVENpol/enforced_royalties">[GITHUB REPO]</a></p><p>In this tutorial, we’ll walk through how to enforce NFT royalties on both OpenSea and Blur by combining ERC2981 with OpenSea’s ERC721-C validator interface. You’ll deploy a royalty-enforced ERC721 smart contract, test a sale using Seaport, and confirm the royalties were sent successfully.</p><h3>✨ Prerequisites</h3><p>Before we begin, make sure you have the following:</p><ul><li><a href="https://app.buildbear.io/"><strong>BuildBear</strong></a><strong> account and testnet node URL</strong></li><li><strong>3 private keys</strong> with at least 50 ETH each from the BuildBear faucet</li><li><strong>Hardhat</strong> installed</li><li><strong>Basic Solidity and JavaScript knowledge</strong></li></ul><h3>.env File Example:</h3><pre>DEPLOYER=&lt;private-key&gt;<br>BUYER=&lt;private-key&gt;<br>SELLER=&lt;private-key&gt;<br>ROYALTY_ADDRESS=&lt;royalty-address&gt;<br>BUILDBEAR_RPC_URL=&lt;buildbear-node-url&gt;<br>BUILDBEAR_CHAIN_ID=&lt;buildbear-chain-id&gt;</pre><h3>✅ Step 1: Create a Basic ERC721 Royalty-Enforced Contract</h3><p>Start by creating a new contract named ERC721_Enforced_Royalties.sol:</p><h3>Step 1.1: Import Required Contracts</h3><pre>import {ERC721} from “@openzeppelin/contracts/token/ERC721/ERC721.sol”;<br>import {ERC721Enumerable} from “@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol”;<br>import {ERC721URIStorage} from “@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol”;<br>import {Ownable} from “@openzeppelin/contracts/access/Ownable.sol”;<br>import {ERC2981} from “@openzeppelin/contracts/token/common/ERC2981.sol”;</pre><h3>Step 1.2: Declare the ERC721-C Interface</h3><pre>interface ICreatorToken {<br> event TransferValidatorUpdated(address oldValidator, address newValidator);<br> function getTransferValidator() external view returns (address);<br> function getTransferValidationFunction() external view returns (bytes4, bool);<br> function setTransferValidator(address validator) external;<br>}</pre><h3>Step 1.3: Inherit Interfaces in the Contract</h3><pre>contract ERC721_Enforced_Royalties is <br> ERC721, <br> ERC721Enumerable, <br> ERC721URIStorage, <br> ERC2981, <br> ICreatorToken, <br> Ownable {</pre><h3>Step 1.4: Declare State Variables</h3><pre>address private _transferValidator;<br>uint256 private _nextTokenId;</pre><h3>Step 1.5: Constructor Parameters</h3><pre>constructor(<br> address initialOwner,<br> address initialTransferValidator,<br> address initialRoyaltyRecipient,<br> uint96 royalties<br> ) ERC721(“MyToken”, “MTK”) Ownable(initialOwner) {<br> _transferValidator = initialTransferValidator;<br> _setDefaultRoyalty(initialRoyaltyRecipient, royalties);<br> _nextTokenId = 1;<br> emit TransferValidatorUpdated(address(0), initialTransferValidator);<br> }</pre><h3>Step 1.6: Implement ICreatorToken Interface</h3><pre>function getTransferValidator() external view override returns (address) {<br> return _transferValidator;<br> }</pre><pre>function getTransferValidationFunction() external pure override returns (bytes4, bool) {<br> return (bytes4(keccak256(“validateTransfer(address,address,address,uint256)”)), true);<br> }</pre><pre>function setTransferValidator(address validator) external override onlyOwner {<br> emit TransferValidatorUpdated(_transferValidator, validator);<br> _transferValidator = validator;<br> }</pre><h3>Step 1.7: Additional Contract Logic (Mint, Overrides)</h3><pre>function safeMint(address to, string memory uri) public onlyOwner returns (uint256) {<br> uint256 tokenId = _nextTokenId++;<br> _mint(to, tokenId);<br> _setTokenURI(tokenId, uri);<br> return tokenId;<br> }</pre><pre>function _update(address to, uint256 tokenId, address auth)<br> internal override(ERC721, ERC721Enumerable) returns (address) {<br> return super._update(to, tokenId, auth);<br> }</pre><pre>function _increaseBalance(address account, uint128 value)<br> internal override(ERC721, ERC721Enumerable) {<br> super._increaseBalance(account, value);<br> }</pre><pre>function tokenURI(uint256 tokenId)<br> public view override(ERC721, ERC721URIStorage) returns (string memory) {<br> return super.tokenURI(tokenId);<br> }</pre><pre>function supportsInterface(bytes4 interfaceId)<br> public view override(ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981) returns (bool) {<br> return super.supportsInterface(interfaceId);<br> }</pre><h3>📂 Step 2: Deploy the Contract</h3><p>Use deployERC721.js script with Hardhat. It will:</p><ul><li>Load signer keys from .env</li><li>Deploy your royalty-enforced ERC721 contract</li><li>Write metadata to deployments.json</li></ul><p>Run the deployment:</p><pre>npx hardhat run scripts/deployERC721.js — network buildbear</pre><p>Make sure you <strong>do not modify</strong> this validator address:</p><pre>const validator = “0x721C002B0059009a671D00aD1700c9748146cd1B”; // Mainnet validator</pre><h3>🪙 Step 3: Simulate a Sale via Seaport</h3><p>Use the provided interactERC721.js script to:</p><ul><li>Mint a token</li><li>List it using Seaport</li><li>Fulfill the order using another wallet</li><li>Track and verify royalty payments</li></ul><p>Run it with:</p><pre>npx hardhat run scripts/interactERC721.js — network buildbear</pre><h3>🚀 Next Steps</h3><blockquote>Note: If royalties are enforced on OpenSea, they’re also enforced on Blur, according to Blur’s support.</blockquote><p>To go further:</p><ul><li>Deploy to Ethereum mainnet</li><li>Repeat the same OpenSea setup (Studio + Creator Earnings)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*5rNoQQoGdEl4m3ZHMdQuBg.png" /></figure><ul><li>Verify that the “Disable royalties” toggle is <strong>locked</strong> for your collection</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*eTnEIbpYPWVOjen57DWnOw.png" /></figure><ul><li>Try selling an NFT on OpenSea or Blur to confirm that royalties flow properly</li></ul><h3>💼 Want Enforced Royalties for Your NFT Collection?</h3><p>If you’re launching a new NFT collection and want <strong>royalties to be enforced</strong> on OpenSea and Blur — or if you already have a collection and want to <strong>upgrade it to support enforced royalties</strong> going forward — feel free to reach out!</p><p>📬 <strong>DM me on LinkedIn</strong>: <a href="https://www.linkedin.com/in/socardepaul/">https://www.linkedin.com/in/socardepaul/</a></p><p>Let’s build something that pays creators <strong>forever</strong>, the way it should.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=157d314cdae3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Manage a Decentralized Development Team]]></title>
            <link>https://medium.com/@mainnetready/how-to-manage-a-decentralized-development-team-527f150ff300?source=rss-6c02a3264b90------2</link>
            <guid isPermaLink="false">https://medium.com/p/527f150ff300</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[web3-development]]></category>
            <category><![CDATA[web3-marketing]]></category>
            <category><![CDATA[web3]]></category>
            <dc:creator><![CDATA[MainnetReady]]></dc:creator>
            <pubDate>Fri, 24 Jan 2025 16:49:48 GMT</pubDate>
            <atom:updated>2025-01-24T16:49:48.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G-o-e2cftb6TqmlR" /><figcaption>Photo by <a href="https://unsplash.com/@alvarordesign?utm_source=medium&amp;utm_medium=referral">Alvaro Reyes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Managing a decentralized development team can be both exciting and challenging. With team members located in different regions, time zones, and sometimes even working in different cultures, a decentralized approach can enhance flexibility and creativity — but it also requires careful planning and clear communication. Below are some practical strategies and best practices to help you successfully manage a decentralized development team.</p><h3>1. Establish Clear Communication Channels</h3><p><strong>Why It Matters:</strong><br>A common pitfall in decentralized teams is miscommunication. When developers are working in different time zones and on varying schedules, clarity becomes crucial.</p><p><strong>How to Do It:</strong></p><ul><li><strong>Use the Right Tools:</strong> Consider communication platforms like Slack, Microsoft Teams, or email for asynchronous conversations. For more face-to-face interactions, schedule video meetings via Zoom or Google Meet.</li><li><strong>Set Communication Guidelines:</strong> Define expectations regarding response times and availability. For example, specify that team members should respond to critical messages within a few hours.</li><li><strong>Encourage Consistent Check-Ins:</strong> Weekly or bi-weekly stand-ups help keep everyone informed of progress, setbacks, and upcoming tasks.</li></ul><h3>2. Create a Shared Vision and Goals</h3><p><strong>Why It Matters:</strong><br>When team members are physically apart, shared goals act as a unifying force. A clear direction helps remote developers understand the bigger picture and prioritize their work accordingly.</p><p><strong>How to Do It:</strong></p><ul><li><strong>Align on Objectives:</strong> Make sure everyone understands the overarching project objectives. This can be done through a well-defined product roadmap or project plan.</li><li><strong>Set Clear Milestones:</strong> Break down larger goals into smaller, achievable tasks. This helps everyone see immediate progress and stay motivated.</li><li><strong>Reiterate the Vision:</strong> Regularly remind the team about the project’s vision, whether in team meetings or on internal communication platforms.</li></ul><h3>3. Leverage Project Management Tools</h3><p><strong>Why It Matters:</strong><br>Project management tools centralize tasks, deadlines, and progress updates. They also reduce the risk of duplicate work or missed deadlines.</p><p><strong>How to Do It:</strong></p><ul><li><strong>Pick a Single Source of Truth:</strong> Whether you choose Jira, Trello, Asana, or another platform, ensure all tasks and documentation are in one location.</li><li><strong>Define Task Ownership:</strong> Clearly assign tasks to individual team members, with deadlines and relevant files attached. This prevents confusion and ensures accountability.</li><li><strong>Monitor Progress:</strong> Regularly review tasks to see if they are on schedule. If something is delayed, use the tool to communicate next steps and re-assign tasks if necessary.</li></ul><h3>4. Foster Trust and Autonomy</h3><p><strong>Why It Matters:</strong><br>In a decentralized environment, managers cannot always see what everyone is doing in real time. Developing trust is essential so team members can work independently without feeling micromanaged.</p><p><strong>How to Do It:</strong></p><ul><li><strong>Encourage Autonomy:</strong> Give developers freedom to structure their work hours. If possible, adopt a flexible schedule. The focus should be on results, not just hours logged.</li><li><strong>Set Clear Expectations:</strong> While flexibility is important, clarity about deadlines, quality standards, and communication rules helps maintain discipline.</li><li><strong>Celebrate Successes:</strong> Acknowledge achievements publicly to foster a positive environment. Recognition can boost morale, particularly when people are working remotely.</li></ul><h3>5. Prioritize Documentation</h3><p><strong>Why It Matters:</strong><br>Detailed documentation ensures consistency and reduces dependency on any single individual’s memory. Decentralized teams often rely on asynchronous communication, which makes thorough records essential.</p><p><strong>How to Do It:</strong></p><ul><li><strong>Document Processes:</strong> For example, maintain guidelines on how to submit code changes, review processes, and release procedures.</li><li><strong>Use Version Control Effectively:</strong> Platforms like GitHub or GitLab are essential for tracking changes, merging code, and ensuring everyone is working on the latest version.</li><li><strong>Encourage Team Contributions:</strong> Ask developers to document their work clearly. Well-structured wikis, knowledge bases, or even project-specific documents can be invaluable references.</li></ul><h3>6. Be Mindful of Time Zones</h3><p><strong>Why It Matters:</strong><br>Team members in different countries may have limited overlapping work hours. Scheduling can become complex, and productivity can suffer if meetings are not planned carefully.</p><p><strong>How to Do It:</strong></p><ul><li><strong>Agree on Core Hours:</strong> If possible, define a few overlapping hours where everyone is available for real-time discussions.</li><li><strong>Rotate Meeting Times:</strong> If you have a global team, rotate meeting times so no single group is always forced to join at inconvenient hours.</li><li><strong>Use Asynchronous Methods:</strong> Record important meetings and share the recordings so that absent members can catch up at their convenience.</li></ul><h3>7. Encourage Team Building</h3><p><strong>Why It Matters:</strong><br>Remote developers often work in isolation, which can lead to a sense of disconnection. Positive relationships among team members can increase job satisfaction and retention.</p><p><strong>How to Do It:</strong></p><ul><li><strong>Organize Virtual Events:</strong> Casual online hangouts, quizzes, or coffee chats can help everyone get to know each other better.</li><li><strong>Leverage Collaborative Tools:</strong> Consider creating non-work-related channels in your communication platform. These can serve as spaces for sharing hobbies, interests, or fun updates.</li><li><strong>Plan In-Person Meetings (If Possible):</strong> If your budget allows, occasional face-to-face gatherings (like annual offsite meetings) can significantly strengthen team bonds.</li></ul><h3>8. Provide Growth Opportunities</h3><p><strong>Why It Matters:</strong><br>Employees who feel stuck in their roles often become disengaged. Supporting professional development is a key way to keep motivation and performance high.</p><p><strong>How to Do It:</strong></p><ul><li><strong>Offer Mentorship:</strong> Pair junior developers with senior team members. This not only builds skills but also fosters closer personal connections.</li><li><strong>Support Learning:</strong> Provide subscriptions to online training platforms or reimburse costs for attending conferences.</li><li><strong>Encourage Internal Movement:</strong> If your organization allows it, give developers the chance to explore different projects or roles that align with their interests and career goals.</li></ul><h3>9. Monitor Performance and Provide Feedback</h3><p><strong>Why It Matters:</strong><br>Regular feedback loops help maintain high standards and identify potential issues early. In a remote setting, feedback sessions can keep developers aligned and motivated.</p><p><strong>How to Do It:</strong></p><ul><li><strong>Schedule 1-on-1 Meetings:</strong> Even a short monthly call can reveal individual concerns, provide an opportunity to discuss goals, and offer timely feedback.</li><li><strong>Use Collaborative Reviews:</strong> For developers, code reviews or pair programming sessions can be a powerful way to share knowledge and maintain quality.</li><li><strong>Be Constructive and Supportive:</strong> Offer solutions rather than just pointing out problems. Celebrate improvements and highlight lessons learned.</li></ul><p>Strengthen your DeFi project with tailored Web3 strategies that prioritize security, efficiency, and sustainable growth. Let’s discuss how I can help safeguard your protocols and streamline operations — schedule a consultation today: <a href="https://www.linkedin.com/in/socardepaul/">https://www.linkedin.com/in/socardepaul/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=527f150ff300" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EIP-6551: Unlocking the True Potential of Non-Fungible Tokens]]></title>
            <link>https://medium.com/@mainnetready/eip-6551-the-future-of-non-fungible-tokens-a6f0651ab04d?source=rss-6c02a3264b90------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6f0651ab04d</guid>
            <category><![CDATA[erc721]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[metaverse]]></category>
            <category><![CDATA[erc6551]]></category>
            <dc:creator><![CDATA[MainnetReady]]></dc:creator>
            <pubDate>Tue, 19 Sep 2023 19:21:28 GMT</pubDate>
            <atom:updated>2023-09-19T19:34:36.394Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ITlgLHTsAh80mCWN" /><figcaption>Photo by <a href="https://unsplash.com/@marekpiwnicki?utm_source=medium&amp;utm_medium=referral">Marek Piwnicki</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the ever-evolving world of blockchain, non-fungible tokens (NFTs) have undoubtedly carved a niche for themselves. Their ability to authenticate digital assets uniquely and provide a platform for creators to monetize their work has caused a paradigm shift in digital ownership. But despite their vast potential, traditional NFTs have had limitations, primarily, the inability to function as smart wallets.</p><h3>Understanding EIP-6551</h3><p>Also recognized as the “Backpack Wallet,” ERC-6551 represents an Ethereum Improvement Proposal that transforms NFTs, enabling them to act as self-contained wallets. This transformative function allows NFTs to custody other digital assets, including Ethereum-based tokens and other derivative NFTs like digital wearables.</p><p>At its core, the intention behind EIP-6551 is to simplify and enhance digital ownership within the rapidly developing Web3 domain. Users can now assign wallet functionalities to their NFTs, opening the door to direct asset transactions through the NFTs themselves.</p><h3>Token Bound Accounts: A Revolutionary Step</h3><p>The brilliance of EIP-6551 lies in the concept of Token Bound Accounts. With this, each Ethereum NFT, traditionally recognized only for its unique identity, morphs into a mini financial hub. It can now possess other assets, including its native cryptocurrency, Ethereum (ETH), and can directly interact with other smart contracts, moving tokens, and transferring NFTs.</p><h3>Growing Traction in the Crypto Ecosystem</h3><p>The implications of this new standard are broad and impactful. Already, platforms like the decentralized social media entity Lens and Web3 studio Stapleverse have integrated EIP-6551, facilitating tokens to hold profiles or even own external NFTs. This proposal paves the way for innovative use cases ranging from gaming, where avatars can maintain in-game assets, to decentralized autonomous organizations (DAOs) that can award NFTs to contributors.</p><p>Furthermore, the compatibility of ERC-6551 with the Ethereum Virtual Machine (EVM) ensures its operability on a plethora of networks, including Polygon, Arbitrum, and Optimism. Plus, it seamlessly integrates with the widely adopted ERC-721 token standard in the Ethereum NFT ecosystem.</p><h3>Challenges and Future Outlook</h3><p>While the potential of ERC-6551 is immense, it’s essential to acknowledge the inherent challenges. The recursive nature of tokens holding tokens can introduce higher gas fees and transactional friction. Yet, the technological advancements and commitment of the community are addressing these hurdles, hinting at a bright future for this proposal.</p><h3>Conclusion</h3><p>EIP-6551 is a testament to the blockchain community’s continual pursuit of innovation. By transforming NFTs into versatile, smart wallets, it redefines digital ownership, presenting unparalleled opportunities in the Web3 landscape. While it remains a proposal as of now, the consistent adoption and evident benefits make it clear — EIP-6551 is not just the future; it’s the next big leap in the blockchain realm.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6f0651ab04d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SRP: A Zero-Knowledge Protocol for Password Authentication]]></title>
            <link>https://medium.com/@mainnetready/srp-a-zero-knowledge-protocol-for-password-authentication-1e19582aab29?source=rss-6c02a3264b90------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e19582aab29</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[zkp]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[MainnetReady]]></dc:creator>
            <pubDate>Wed, 29 Mar 2023 10:33:24 GMT</pubDate>
            <atom:updated>2023-03-29T10:33:24.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ciUZTrbrfEa1w53R6Nnz2Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@flyd2069?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">FLY:D</a> on <a href="https://unsplash.com/photos/mT7lXZPjk7U?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Passwords are a crucial aspect of security in modern computing. They safeguard our sensitive data and secure our accounts from unauthorized access. However, the traditional methods of storing passwords, such as hashing and salting, are not foolproof, and attackers can still exploit vulnerabilities to crack passwords. This has led to the development of more advanced techniques such as the Secure Remote Password (SRP) protocol, which provides a secure mechanism for password authentication.</p><h3>The Secure Remote Password (SRP) Protocol</h3><p>The SRP protocol is a cryptographic protocol developed by Tom Wu in 1998 as a secure alternative to traditional password authentication methods. It is a zero-knowledge protocol that ensures no information is revealed during the authentication process except that the parties share the same secret. This makes SRP highly resistant to password-cracking attacks, as attackers cannot use intercepted data to access the system.</p><h3><strong>The SRP protocol consists of six phases:</strong></h3><ol><li><strong>Setup:</strong> The client and server agree on parameters, including a large prime number and a generator. These parameters are used to generate the shared secret.</li><li><strong>Authentication Request (Client):</strong> The client sends a message to the server requesting authentication.</li><li><strong>Authentication Response (Server):</strong> The server sends a challenge to the client containing a random number and a value derived from the group parameters and the server’s private key.</li><li><strong>Authentication Response(Client):</strong> The client uses the challenge and its private key to calculate a response, which it sends to the server.</li><li><strong>Verification (Server): </strong>The server verifies the client’s response and, if it is valid, sends a verification message to the client.</li><li><strong>Session Key Calculation:</strong> Both parties use the shared secret to calculate a session key, which is used for subsequent communication.</li></ol><p>The SRP protocol uses hash functions and modular arithmetic to protect the shared secret. The hash functions ensure that the password is not transmitted over the network, while the modular arithmetic provides a secure method for calculating the shared secret.</p><h3><strong>Implementation</strong></h3><p>Implementing the SRP protocol requires a good understanding of the underlying cryptographic concepts and careful attention to detail. However, several libraries and frameworks are available that can simplify the process. Let’s explore some of the popular implementations of SRP.</p><ol><li>libsodium: libsodium is a widely used cryptography library that provides a high-level interface for implementing SRP. It includes a secure implementation of the SRP protocol based on the work of Dan Bernstein and Tanja Lange. libsodium provides a simple API for generating the group parameters and performing the six phases of the SRP protocol. The library also includes support for password hashing and key derivation functions, making it a comprehensive solution for password-based authentication.</li><li>OpenSSL: OpenSSL is another widely used cryptography library that includes support for SRP. It provides a C API for performing the six phases of the SRP protocol, as well as functions for generating the group parameters and performing key derivation.</li><li>PySRP: PySRP is a Python library that provides an easy-to-use interface for implementing SRP. It includes a pure-Python implementation of the SRP protocol that is compatible with the implementations in libsodium and OpenSSL. PySRP provides a high-level API for generating the group parameters and performing the six phases of the SRP protocol. It also includes support for password hashing and key derivation functions.</li><li>Golang SRP: Golang SRP is a Go library that provides an implementation of the SRP protocol. It includes functions for generating the group parameters and performing the six phases of the protocol. Golang SRP uses the Elliptic Curve Cryptography (ECC) version of SRP, which provides a more secure method for generating the shared secret.</li><li>Cryptlib: Cryptlib is a comprehensive cryptography library that includes support for SRP. The library provides a C API for performing the six phases of the protocol, as well as functions for generating the group parameters and performing key derivation.</li></ol><h3><strong>The security of SRP</strong></h3><p>The security of the SRP protocol is based on the difficulty of solving the discrete logarithm problem in finite fields. This problem is believed to be computationally infeasible, which means that an attacker cannot calculate the shared secret from intercepted data. The SRP protocol uses hash functions to protect the password, which ensures that the password is not transmitted over the network in plaintext.</p><p>Several academic papers have evaluated the security of the SRP protocol. In 2001, John Brainard and David Wagner published a paper titled “A Secure Protocol for Password Authentication,” in which they analyzed the security of the SRP protocol. They concluded that the SRP protocol provides a secure method for password authentication and is resistant to the dictionary and brute-force attacks.</p><p>In 2002, Mihir Bellare, David Pointcheval, and Phillip Rogaway published a paper titled “Authenticated Key Exchange Secure Against Dictionary Attacks,” in which they presented a formal analysis of the SRP protocol. They proved that the SRP protocol provides strong security guarantees against dictionary attacks, even in the presence of an active attacker.</p><p>In 2012, Alain Hiltgen and Martin Boesgaard published a paper titled “The Secure Remote Password Protocol: Attacks, Improvements, and Implementation,” in which they analyzed the security of the SRP protocol and proposed several improvements. They concluded that the SRP protocol provides a strong method for password authentication, but that some weaknesses can be exploited by attackers. They proposed several improvements to the protocol, including the use of stronger hash functions and key derivation functions.</p><h3>Conclusion</h3><p>In conclusion, the SRP protocol is a secure and reliable method for password authentication. By implementing SRP, we can protect sensitive data and secure our accounts from unauthorized access. Implementing SRP requires a good understanding of the underlying cryptographic concepts and careful attention to detail. However, several libraries and frameworks are available that can simplify the process, such as libsodium, OpenSSL, PySRP, Golang SRP, and Cryptlib.</p><p>The security of the SRP protocol is based on the difficulty of solving the discrete logarithm problem in finite fields. There have been several academic papers that have evaluated the security of the SRP protocol, and they have concluded that SRP provides a strong method for password authentication, but there are some weaknesses that can be exploited by attackers. Therefore, it is essential to implement SRP carefully and to keep up-to-date with the latest security improvements and updates.</p><p>In conclusion, the Secure Remote Password (SRP) protocol is an excellent choice for securing remote access to systems, databases, and web services. It provides a secure and reliable method for password authentication that is resistant to password-cracking attacks. By implementing SRP, we can safeguard our sensitive data and protect our accounts from unauthorized access.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e19582aab29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Revealing Nothing: An Exploration of Zero Knowledge Proofs and Cryptographic Privacy]]></title>
            <link>https://medium.com/@mainnetready/the-art-of-revealing-nothing-an-exploration-of-zero-knowledge-proofs-and-cryptographic-privacy-f218cabff361?source=rss-6c02a3264b90------2</link>
            <guid isPermaLink="false">https://medium.com/p/f218cabff361</guid>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[MainnetReady]]></dc:creator>
            <pubDate>Mon, 27 Mar 2023 08:34:13 GMT</pubDate>
            <atom:updated>2023-03-27T08:41:53.532Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_iW5YbSFUBWkBYoM0lWuA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@tinaflour?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kristina Flour</a> on <a href="https://unsplash.com/s/photos/secret?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Living in the digital age, privacy has become a critical aspect of online communications and transactions. The challenge of safeguarding sensitive data while validating the authenticity of transactions is an ongoing battle. Enter Zero Knowledge Proofs (ZKPs), a powerful cryptographic technique that allows one party to prove the validity of a statement without disclosing any additional information. In this article, we will explore the inner workings of ZKPs, their real-world applications, and various protocols that have evolved over time.</p><h4>What Are Zero-Knowledge Proofs?</h4><p>Introduced by Shafi Goldwasser, Silvio Micali, and Charles Rackoff in 1985, Zero Knowledge Proofs offer a way for a person (let’s call her Alice) to prove to another person (let’s call him Bob) that she knows a secret without actually revealing the secret itself. This intriguing concept relies on three fundamental properties:</p><ol><li><strong>Completeness: </strong>If the statement is true, an honest prover (Alice) can always convince a verifier (Bob) of its truth.</li><li><strong>Soundness:</strong> If the statement is false, no dishonest prover can persuade a verifier of its truth with any significant probability.</li><li><strong>Zero-Knowledge:</strong> If the statement is true, the verifier learns nothing other than the fact that it is true.</li></ol><h4>A Simple Example of Zero Knowledge Proofs in Action</h4><p>To better grasp the idea, let’s consider a straightforward example:</p><ol><li>Alice has three cards: two black cards and one red card. She places them face-down on a table, with the red card in the middle.</li><li>Alice then asks Bob to look away while she shuffles the cards, changing their positions.</li><li>Bob looks back at the table and now needs to guess the position of the red card.</li><li>Alice privately selects one of the black cards and turns it face up, revealing its color without disclosing the red card’s position.</li><li>Bob then has to make a final guess about the location of the red card.</li></ol><p>This process is repeated several times. If Alice can always reveal a black card and Bob’s final guess is consistently wrong, Bob becomes increasingly confident that Alice knows the red card’s position without ever learning it himself. This demonstrates that Alice possesses knowledge of the red card’s location without revealing any additional information to Bob.</p><h4>Diverse Approaches to Implementing Zero Knowledge Proofs</h4><p>Throughout the years, numerous protocols have been devised to facilitate the implementation of ZKPs across a wide range of applications. Some of the most prominent ones include:</p><ol><li><strong>Interactive Proofs (IP): </strong>In this protocol, the prover and verifier engage in a series of information exchanges. The verifier poses challenges to the prover, who must provide responses that convince the verifier of the statement’s truth, without revealing any extra information. The example mentioned earlier is a type of interactive proof.</li><li><strong>Non-Interactive Zero-Knowledge (NIZK):</strong> NIZK protocols do away with the need for interaction between the prover and verifier by relying on a common reference string (CRS). Generated by a trusted third party, the CRS is a publicly available, random string. Using this string, the prover can create proof that the verifier can independently check without any interaction.</li><li><strong>zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge):</strong> Gaining popularity due to their efficiency and compact proof sizes, zk-SNARKs are a type of NIZK particularly useful in blockchain applications where computational resources and storage space are limited. A prominent example of zk-SNARKs in action is the privacy-centric cryptocurrency Zcash.</li><li><strong>zk-STARKs (Zero-Knowledge Scalable Transparent ARguments of Knowledge):</strong> As an alternative to zk-SNARKs, zk-STARKs offer similar benefits in terms of efficiency and proof size but with added transparency and scalability. Unlike zk-SNARKs, zk-STARKs do not rely on a trusted setup or common reference string, thus eliminating the need for a trusted third party. Additionally, zk-STARKs are resistant to quantum computing attacks, making them a more future-proof choice for some applications.</li></ol><p><strong>Exploring the Diverse Applications of Zero Knowledge Proofs</strong></p><ol><li><strong>Cryptocurrencies:</strong> Privacy-oriented cryptocurrencies like Zcash and Monero make use of ZKPs to ensure the confidentiality of transaction data. By leveraging zk-SNARKs, Zcash allows users to carry out transactions without exposing the sender, recipient, or amount involved. Similarly, Monero uses a variant of ZKPs called Ring Confidential Transactions (RingCT) to protect transaction details.</li><li><strong>Secure Authentication:</strong> ZKPs can be employed to develop secure authentication systems where users can prove their identity without disclosing their secret credentials. For instance, Zero Knowledge Password Proof (ZKPP) enables users to authenticate themselves to a server without sending their password, thus minimizing the risk of eavesdropping or man-in-the-middle attacks.</li><li><strong>Electronic Voting:</strong> ZKPs have the potential to enhance the privacy and integrity of electronic voting systems. They can be used to prove that a voter’s choice is valid without revealing the actual vote, ensuring voter anonymity. Additionally, ZKPs can help confirm that the vote tallying process is accurate without exposing individual votes.</li><li><strong>Secure Multi-Party Computation (SMPC):</strong> SMPC involves multiple parties jointly computing a function over their private inputs while keeping those inputs confidential. ZKPs play a crucial role in SMPC by enabling parties to prove the correctness of their computations without sharing their private data.</li><li><strong>Private Blockchain Data:</strong> ZKPs can be utilized to create private smart contracts, where data and execution details are kept confidential from other network participants. This allows enterprises to benefit from blockchain technology while preserving data privacy and adhering to regulatory requirements.</li></ol><p>Zero Knowledge Proofs have risen to prominence as a robust cryptographic technique adept at balancing privacy needs with verifiability across a myriad of applications. With the ongoing evolution of the digital realm, the adoption of ZKPs is anticipated to expand, delivering heightened security and privacy solutions throughout diverse domains. While the foundational mathematics and protocols may be complex, the central tenet of demonstrating a statement’s validity without divulging supplementary information continues to captivate and serve as a crucial element in contemporary cryptography.</p><p><strong>Additional links if you want to deep-dive into the world of ZKPs:</strong></p><p><a href="https://epubs.siam.org/doi/10.1137/0218012">Goldwasser, S., Micali, S., &amp; Rackoff, C. (1985). The Knowledge Complexity of Interactive Proof Systems</a></p><p><a href="https://dl.acm.org/doi/pdf/10.1145/62212.62223">Ben-Or, M., Goldwasser, S., Kilian, J., &amp; Wigderson, A. (1988). Multi-Prover Interactive Proofs: How to Remove Intractability Assumptions</a></p><p><a href="https://dl.acm.org/doi/pdf/10.1145/62212.62222">Blum, M., Feldman, P., &amp; Micali, S. (1991). Non-Interactive Zero-Knowledge and Its Applications</a></p><p><a href="https://link.springer.com/chapter/10.1007/978-3-540-78967-3_25">Groth, J., &amp; Sahai, A. (2008). Efficient Non-Interactive Proof Systems for Bilinear Groups</a></p><p><a href="https://link.springer.com/chapter/10.1007/978-3-642-40084-1_6">Ben-Sasson, E., Chiesa, A., Genkin, D., Tromer, E., &amp; Virza, M. (2013). SNARKs for C: Verifying Program Executions Succinctly and in Zero Knowledge</a></p><p><a href="https://dl.acm.org/doi/10.1145/3319535.3354261">Maller, M., Bowe, S., Kohlweiss, M., &amp; Meiklejohn, S. (2019). Sonic: Zero-Knowledge SNARKs from Linear-Size Universal and Updateable Structured Reference Strings</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f218cabff361" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create an ERC20 bridge without a web interface]]></title>
            <link>https://medium.com/@mainnetready/how-to-create-an-erc20-bridge-without-a-web-interface-54a717f5263d?source=rss-6c02a3264b90------2</link>
            <guid isPermaLink="false">https://medium.com/p/54a717f5263d</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[solidity-tutorial]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[bridge]]></category>
            <dc:creator><![CDATA[MainnetReady]]></dc:creator>
            <pubDate>Tue, 13 Dec 2022 14:48:31 GMT</pubDate>
            <atom:updated>2022-12-13T14:48:31.190Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-vV8t3h1mzgQIieSgci38g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@codyhiscox?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Cody Hiscox</a> on <a href="https://unsplash.com/s/photos/bridge?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Hello everybody! Long time no post, but I am back with a simple tutorial for an ERC20 bridge managed by a Node.js script.</p><p>What do you need in order to complete this tutorial?</p><ul><li>Node.js installed on your machine;</li><li>Metamask — a brand-new wallet;</li><li>Test funds for BSC Testnet and Polygon Mumbai;</li></ul><h3>What is a bridge?</h3><blockquote>“A blockchain bridge is a tool that lets you port assets from one <a href="https://www.coindesk.com/learn/what-is-blockchain-technology/">blockchain</a> to another, solving one of the main pain points within blockchains — a lack of interoperability.</blockquote><blockquote>Since blockchain assets are often not compatible with one another, bridges create synthetic derivatives that represent an asset from another blockchain.” — <a href="https://www.coindesk.com/learn/what-are-blockchain-bridges-and-how-do-they-work/">CoinDesk</a></blockquote><h3><strong>The architecture</strong></h3><p>To create an ERC20 bridge we will need to deploy 4 smart contracts and a Node.js script that will listen to emitted events and perform actions using a “hot wallet”.</p><ol><li>Simple ERC20 smart contract that will be deployed on BSC Testnet and on Polygon Mumbai.</li><li>A custom smart contract that will receive and send ERC20 tokens. As well, this will be deployed on both networks.</li><li>Node.js script that will listen to Transfer events emitted by the token smart contracts on both chains.</li></ol><h3>The code</h3><p>To deploy the smart contracts on both chains, you can use <a href="https://remix.ethereum.org/">Remix — Ethereum IDE</a>. But in order to do that, you’ll need to 1) Add both networks on your Metamask; 2) Request faucet funds on both networks: <a href="https://testnet.bnbchain.org/faucet-smart">BSC Testnet faucet</a> &amp;<a href="https://faucet.polygon.technology/"> Polygon Mumbai faucet</a>;</p><h4>1. ERC20 Smart Contract</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EztwQm73c2BaXgaHn1Adrw.png" /><figcaption>Simple ERC20 Smart Contract; Source Code: <a href="https://github.com/DRIVENpol/bridge/blob/main/CONTRACTS/TokenSc.sol">https://github.com/DRIVENpol/bridge/blob/main/CONTRACTS/TokenSc.sol</a></figcaption></figure><h4>2. Custom Smart Contract</h4><p>Now we will need a custom smart contract where users will send tokens on <strong>Chain A</strong> in order to receive them on <strong>Chain B</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBDlv7-2iliPABjPPNdY0Q.png" /><figcaption>Custom Smart Contract; Source Code: <a href="https://github.com/DRIVENpol/bridge/blob/main/CONTRACTS/SwitchBsc.sol">[BSC]</a> // <a href="https://github.com/DRIVENpol/bridge/blob/main/CONTRACTS/SwitchMatic.sol">[MATIC]</a></figcaption></figure><p>Now let me explain to you every line of this smart contract. (If you are an experienced Solidity developer, you can skip to the 3rd step after you deployed this smart contract on both chains).</p><p><strong>Lines 1 &amp; 3:</strong> The <a href="https://spdx.dev/ids/">SPDX license</a> and the version of solidity that we are using.</p><p><strong>Line 6–10:</strong> We declared the IERC20 interface. We need that in order to be able to interact with our ERC20 token.</p><p><strong>Line 12–18:</strong> We declare the smart contract and the needed variables. In our case, we have 1) The hot wallet — which is an EOA; 2) The token address that you recently deployed.</p><p><strong>Line 21–24:</strong> The constructor — a piece of code that is executed when you deploy the smart contract. There we give values to the hotWallet and myToken (IERC20 object).</p><p><strong>Line 28:</strong> Declare an event that will be emitted when the smart contract will transfer the tokens to an address. To emit an event, you consume gas. It’s a good practice to have them and a lot of auditors will ask for that aspect, but you can avoid them in internal functions.</p><p><strong>Line 32–34:</strong> The onlyHotWallet modifier. If a function is using a modifier, the piece of code that is written in the modifier will be executed before the body of the function. In our case, we use it for the “sendTokens” function and require the msg.sender (who calls the function) to be equal to the hot wallet’s address.</p><p><strong>Line 37–45:</strong> The “sendTokens” function — accepts two parameters as input: 1) _to — the address of the receiver and 2) _amount — that amount that we send. The first line of the function requires the balance of the smart contract for our ERC20 token to be higher or equal to the amount that we send.</p><p>After that, we call the “approve” function and allow the receiver to spend the tokens.</p><p>Finally, we send the tokens from the smart contract and emit the event.</p><h4>3. The Node.js Script</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gqyw4zNnFGi3TnvN5_vngw.png" /><figcaption>The Source Code: <a href="https://github.com/DRIVENpol/bridge/blob/main/bot.js">https://github.com/DRIVENpol/bridge/blob/main/bot.js</a></figcaption></figure><p>Code explanation:</p><p><strong>Lines 1–2:</strong> We import the “ethers” and “dotenv” modules.</p><p><strong>Lines 5–15:</strong> We fetch the variables from the .env file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jhTzPkTL_qrlVYe1B9SO5A.png" /></figure><p><strong>Lines 18–21:</strong> We import the ABI (Application Binary Interface) for our smart contracts. You can find the files <a href="https://github.com/DRIVENpol/bridge/tree/main/JSON">there</a>.</p><p><strong>Line 24:</strong> The beginning of the main function.</p><p><strong>Lines 27–35:</strong> Connect our application to the hot wallet on both networks.</p><p><strong>Lines 38–44:</strong> Connect our hot wallet to the custom smart contract on both networks.</p><p><strong>Lines 47–53:</strong> Connect our hot wallet to the token smart contract on both networks.</p><p><strong>Lines 56–74:</strong> We create a function that calls the “sendTokens” method from our custom smart contract on BSC Testnet.</p><p><strong>Lines 77–95: </strong>We create a function that calls the “sendTokens” method from our custom smart contract on Polygon Mumbai.</p><p>And now,<strong> THE INTERESTING PART</strong></p><p><strong>Lines 98–129: </strong>We are listening to “Transfer” events that were emitted by our ERC20 smart contract, we query the data from that event and we check if the receiver is the custom smart contract — if this is the case, we send tokens from the smart contract.</p><p>Basically, if somebody wants to bridge your erc20 token from BSC Testnet to Polygon Mumbai, they need to send their tokens to the custom smart contract deployed on BSC testnet, while your script is running on a server or on your local machine.</p><p><strong>Require: In order for everything to work smoothly, you need to approve the smart contract to use the tokens that were sent to it (you can do that by calling the approve function from the ERC20 smart contract) and send tokens to the smart contract.</strong></p><p>The source code: <a href="https://github.com/DRIVENpol/bridge">https://github.com/DRIVENpol/bridge</a></p><p>If you want to deploy the bot, you simply need to:</p><ol><li>Deploy the ERC20 smart contract on both chains</li><li>Deploy the custom smart contract on both chains</li><li>Create a new folder and download the code from my GitHub</li><li>Open the terminal and navigate to the project’s directory. After that run <strong>npm install</strong></li><li>Create a .env file and change the variables</li><li>Run <strong>node bot.js</strong> in your terminal</li></ol><p>Voilà!</p><p>If you are looking for a team of developers for your DeFi project or if you need security audits for your smart contracts, don’t hesitate to contact me on Twitter at <a href="https://twitter.com/polthedev">https://twitter.com/polthedev</a> or by email: paul.socarde@drivenecosystem.com.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54a717f5263d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Subscription-Based
Smart Contract: UPDATE]]></title>
            <link>https://medium.com/@mainnetready/subscription-based-smart-contract-update-4605ba8be440?source=rss-6c02a3264b90------2</link>
            <guid isPermaLink="false">https://medium.com/p/4605ba8be440</guid>
            <category><![CDATA[solidity-tutorial]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[MainnetReady]]></dc:creator>
            <pubDate>Mon, 03 Oct 2022 14:35:43 GMT</pubDate>
            <atom:updated>2022-10-03T14:35:43.276Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ab2Z8dQhcj8iDYcYl0BNKg.png" /></figure><p>Back in April, I wrote an <a href="https://medium.com/@psocarde/subscription-based-smart-contract-ca89347a15d1">article</a> about how you can create a subscription-based smart contract that allows users to perform actions only if they paid a monthly fee in ERC20 tokens or in blockchain’s native tokens. After I got a lot of good feedback about it, I decided to make an upgraded version that can be inherited like <a href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol">Ownable.sol from OpenZeppelin</a>.</p><p><strong>The source code:</strong> <a href="https://github.com/DRIVENpol/Subscription-Smart-Contract/tree/main/NewVersion">https://github.com/DRIVENpol/Subscription-Smart-Contract/tree/main/NewVersion</a></p><p><strong>Examples:</strong> <a href="https://github.com/DRIVENpol/Subscription-Smart-Contract/tree/main/NewVersion/Examples">https://github.com/DRIVENpol/Subscription-Smart-Contract/tree/main/NewVersion/Examples</a></p><h3>Option 1: Accept payments in blockchain’s native token</h3><p><strong>Step 1:</strong> Import the smart contract directly from my Github</p><pre>import <strong>“https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/ETH_payment.sol&quot;;</strong></pre><p><strong>Step 2:</strong> Create your smart contract and inherite the imported one</p><pre>contract Example_SC <strong>is SubscriptionInEth</strong> {<br>}</pre><p><strong>Step 3:</strong> Call the wanted functions in the constructor (This is an optional step as you can call those functions after deployment)</p><pre>constructor() { </pre><pre>// We set the fee to 1 Ether (1 * 10 * 18) </pre><pre><strong>setEthFee(1000000000000000000); </strong></pre><pre>}</pre><p><strong>Step 4 :</strong> Use the “userPaid” modifier for your functions in order to allow access ONLY to users that paid their subscription.</p><p>In the following example, I will declare a uint256 variable and a function that increases it by 1.</p><pre>uint256 public c = 0;</pre><pre>// We use the “userPaid” modifier and we allow only users with valid subscriptions to call this function</pre><pre>function increaseC() public <strong>userPaid</strong> {</pre><pre>c++;</pre><pre>}</pre><p><strong>Example:</strong> <a href="https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/Examples/ETH_Payment_Example.sol">https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/Examples/ETH_Payment_Example.sol</a></p><p><strong>Library:</strong> <a href="https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/ETH_payment.sol">https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/ETH_payment.sol</a></p><h3>Option 2: Accept payments in ERC20 tokens</h3><p>The process is the same with a small additional thing: you need to add the address of the ERC20 token in which you will accept recurrent payments.</p><pre>constructor() { </pre><pre>// Set the address of the token used for payments // In this case: BUSD (BSC Mainnet) <strong>setErc20TokenForPayments(0x55d398326f99059fF775485246999027B3197955); </strong></pre><pre>// We set the fee to 1 BUSD (1 * 10 * 18) </pre><pre><strong>setErc20Fee(1000000000000000000); </strong></pre><pre>}</pre><p><strong>Example: </strong><a href="https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/Examples/ERC20_Payment_Example.sol">https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/Examples/ERC20_Payment_Example.sol</a></p><p><strong>Library:</strong> <a href="https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/ERC20_payment.sol">https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/ERC20_payment.sol</a></p><h3>Accept payments in both Blockchain’s native tokens and ERC20 tokens</h3><p><strong>Example: </strong><a href="https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/Examples/ETH_And_Erc20_Payment_Example.sol">https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/Examples/ETH_And_Erc20_Payment_Example.sol</a></p><p><strong>Library: </strong><a href="https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/ERC20_And_ETH_Payment.sol">https://github.com/DRIVENpol/Subscription-Smart-Contract/blob/main/NewVersion/ERC20_And_ETH_Payment.sol</a></p><p><em>If you have any questions don’t hesitate to text me on Twitter: </em><a href="https://twitter.com/polthedev"><em>https://twitter.com/polthedev</em></a></p><p>As well, if you see any errors/bugs or you feel like the implementation of this library can be better, just let me know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4605ba8be440" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EIP-4671 and ERC1238: The Non-Transferable Token (NTT) || Soulbound Tokens]]></title>
            <link>https://medium.com/@mainnetready/eip-4671-and-erc1238-the-non-transferable-token-ntt-soulbound-tokens-120aeadba6b2?source=rss-6c02a3264b90------2</link>
            <guid isPermaLink="false">https://medium.com/p/120aeadba6b2</guid>
            <category><![CDATA[eip]]></category>
            <category><![CDATA[solidity-development]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[MainnetReady]]></dc:creator>
            <pubDate>Fri, 23 Sep 2022 15:15:26 GMT</pubDate>
            <atom:updated>2023-01-30T16:02:29.553Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z0WMH2U6WBfXKqFnNuGFsw.jpeg" /><figcaption>From Unsplash, by <a href="https://unsplash.com/@coopery">Mohamed Nohassi</a></figcaption></figure><p><strong>My version of a SoulBond Token:</strong> <a href="https://github.com/DRIVENpol/SouldBoundToken/blob/main/SoulBoundToken.sol">https://github.com/DRIVENpol/SouldBoundToken/blob/main/SoulBoundToken.sol</a></p><p><strong>The Non-Transferable Tokens</strong> or <strong>Soulbound Tokens</strong> are the next big thing in the DeFi space. Why? Not because a lot of people will make huge amounts of money from them as we saw with the ERC721(NFTs) phenomenon, but because they bring <strong>real utility to the decentralized space and will boost the mass adoption of cryptocurrencies.</strong></p><p>NTTs are simply NFTs that can’t be transferable to any other address — they are tied to one blockchain entity (a wallet address).</p><p>There is a centralized (smart contract) authority that can emit and revoke them.</p><p>The protocol was proposed in May 2022 by <strong>Vitalik Buterin, Puja Ohlhaver, and E. Glen Weyl</strong> in order to create the base of a Decentralized Society (DeSo): <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763">https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763</a>, but Nicola (<a href="https://github.com/nicola">https://github.com/nicola</a>) suggested the ERC1238 standard in July 2018 (<a href="https://github.com/ethereum/EIPs/issues/1238">https://github.com/ethereum/EIPs/issues/1238</a>).</p><blockquote>Nicola’s definition of ERC1238: “A badge is a token that once assigned it cannot be transferred. Badges can be accumulated through time and put at stake. Simply speaking, badges are statements about a public key, they can be quantitative (e.g. reputation, experience) or qualitative (badges, titles).”</blockquote><p><strong>How can we implement NTTs in the real world?</strong></p><p>There are many utilities that can be linked to NTTs but the main one is <strong>AUTHENTICITY.</strong></p><p>For example, you are going to Harvard and getting your degree. Instead of giving you a diploma they can emit an NTT linked to your wallet. So every time somebody wants to check your achievement, they can simply look at your wallet address with an NTT emitted by Harvard (0xHARVARD for example).</p><p>We can have the same workflow for <strong>passports, IDs, official documents, proof of employment</strong>, etc.</p><p>By implementing this protocol in the real world, in a few years, your CV will be represented by your wallet.</p><p><strong>Now, what happens if you lose ownership of your wallet?</strong></p><p>Basically, nothing, because Souldbound tokens are not transferable.</p><p>But for your peace of mind, <strong>Vitalik</strong> proposed a solution to this possible problem: <strong>a social recovery model </strong>that works more like a DAO where people that have the same type of NTT in their wallet (your colleagues) and the “central authority” can vote so you can get your Soulbound token assigned to another wallet.</p><p>But for sure, this social recovery model has its own downsides — you need to keep a good relationship with both parties in order to keep your NTT.</p><p>Another problem with Soulbound Tokens is how can we block the bad actors to airdrop some shady NTTs in our wallet. We don’t know yet but I guess we will find out shortly.</p><p><strong>ERC1238</strong> is not officially on the EIP list (<a href="https://eips.ethereum.org/all">https://eips.ethereum.org/all</a>) but we have <strong>EIP-4671</strong>, proposed on 13 January 2022 by <a href="https://medium.com/u/c215fdc67eb">Omar Aflak</a>: <a href="https://eips.ethereum.org/EIPS/eip-4671">https://eips.ethereum.org/EIPS/eip-4671</a> which is more stable than ERC1238 and could have more implementations (again, only my personal opinion).</p><p>This article is a living document. I will update it while I will test both ERC1238 and EIP-4671.</p><p>As well, If you have any recommendations/additional notes for this article, just let me know.</p><p>Let’s connect on <a href="https://twitter.com/SolidityRealm">Twitter!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=120aeadba6b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Subscription-Based
Smart Contract]]></title>
            <link>https://medium.com/@mainnetready/subscription-based-smart-contract-ca89347a15d1?source=rss-6c02a3264b90------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca89347a15d1</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[MainnetReady]]></dc:creator>
            <pubDate>Sat, 09 Apr 2022 09:37:40 GMT</pubDate>
            <atom:updated>2022-10-03T14:37:01.501Z</atom:updated>
            <content:encoded><![CDATA[<h4>Create a subscription-based smart contract. Accept native token payments and ERC20 payments from your users.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sTeZBu9d18R-ad6Qupl1Rw.png" /></figure><p><strong>***DISCLAIMER: THIS IS AN OUTDATED VERSION. SEE THE NEW IMPLEMENTATION THERE:</strong> <a href="https://medium.com/@psocarde/subscription-based-smart-contract-update-4605ba8be440">https://medium.com/@psocarde/subscription-based-smart-contract-update-4605ba8be440</a></p><p><strong>Hello!</strong></p><p>My name is Paul Socarde and I am the founder of <a href="http://www.drivenecosystem.com/">DRIVENecosystem</a>. Welcome to my 3rd Solidity tutorial.</p><p>This article will show you how to create a subscription-based smart contract where users will need to pay a subscription fee, periodically (in native tokens or ERC20 tokens), in order to execute different actions.</p><p>Let’s start!</p><p>As you know, our first lines of code will declare the SPDX license, the Solidity version that we are using and will import the needed libraries.</p><pre><strong>// SPDX License</strong></pre><pre>//SPDX-License-Identifier: MIT</pre><pre><strong>// Version of solidity</strong></pre><pre>pragma solidity ^0.8.13;</pre><pre><strong>// Imports for mathematical operations</strong></pre><pre>import &quot;@openzeppelin/contracts/utils/math/SafeMath.sol&quot;;</pre><pre><strong>// Imports for ERC20 Payments</strong></pre><pre>import &quot;@openzeppelin/contracts/token/ERC20/IERC20.sol&quot;;</pre><pre>import &quot;@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol&quot;;</pre><h4>Initialize the smart contract and inherit the libraries.</h4><pre><strong>// Initialize the smart contract</strong></pre><pre><em>contract</em> Subscription {</pre><pre>using SafeMath for uint256;</pre><pre>using SafeERC20 for IERC20;</pre><pre>}</pre><h4><strong>General Variables</strong></h4><pre><strong>// Access variable</strong></pre><pre><em>address</em> <em>public</em> owner;</pre><pre><strong>// Action variable</strong></pre><pre><em>uint256</em> <em>public</em> forTesting;</pre><pre><strong>// ERC20 Object</strong></pre><pre><strong>// For payments made in ERC20 tokens</strong></pre><pre>IERC20 <em>public</em> secondaryTokenForPayment;</pre><pre><strong>// Manage the payment options</strong></pre><pre><em>uint256</em> <em>public</em> paymentOption; <strong>// 1 - Eth Payments &amp; 2 - ERC20 Payments</strong></pre><h4>Payment struct and the array of structs</h4><pre><strong>// Struct for payments</strong></pre><pre><em>struct</em> Payment {</pre><pre><em>address</em> user; <strong>// Who made the payment</strong></pre><pre><em>uint256</em> paymentMoment;<strong> // When the last payment was made</strong></pre><pre><em>uint256</em> paymentExpire; <strong>// When the user needs to pay again</strong></pre><pre>}</pre><pre><strong>// Array of payments</strong></pre><pre>Payment[] <em>public</em> payments;</pre><p><strong>Link the user’s address to its last payment</strong></p><pre><strong>// Link user to payment</strong></pre><pre><em>mapping</em> (<em>address</em> =&gt; Payment) <em>public</em> userPayment;</pre><p><strong>Analytics and fees</strong></p><pre><strong>// Fees</strong></pre><pre><em>uint256</em> <em>public</em> ethFee; <strong>// What&#39;s the fee in eth</strong></pre><pre><em>uint256</em> <em>public</em> erc20Fee; <strong>// What&#39;s the fee in Erc20 tokens</strong></pre><pre><strong>// Analytics</strong></pre><pre><em>uint256</em> <em>public</em> totalPaymentsEth;</pre><pre><em>mapping</em> (<em>address</em> =&gt; <em>uint256</em>) <em>public</em> userTotalPaymentsEth;</pre><pre><em>uint256</em> <em>public</em> totalPaymentsErc20;</pre><pre><em>mapping</em> (<em>address</em> =&gt; <em>uint256</em>) <em>public</em> userTotalPaymentsErc20;</pre><p><strong>“userTotalPaymentsEth”</strong> — store the total Eth payments made by a specific user;</p><p><strong>“userTotalPaymentsErc20”</strong> — store the total Erc20 payments made by a specific user;</p><h4>Constructor — initialize the values</h4><pre><strong>// Constructor</strong></pre><pre><em>constructor</em>() {</pre><pre>owner = msg.sender; <strong>// Owner = deployer</strong></pre><pre>forTesting = 1;<br></pre><pre>paymentOption = 1; <strong>// Payments in Eth by default</strong></pre><pre>totalPaymentsEth = 0;</pre><pre>totalPaymentsErc20 = 0;</pre><pre>ethFee = 1000000000000000000; <strong>// 1 Eth by default</strong></pre><pre>}</pre><h4>Modifiers</h4><pre>modifier onlyOwner {</pre><pre>require(msg.sender == owner, “You are not the owner!”);</pre><pre>_;</pre><pre>}</pre><pre><strong>// Check if user paid — modifier</strong></pre><pre><em>modifier</em> userPaid {</pre><pre>require(block.timestamp &lt; userPayment[msg.sender].paymentExpire, “Your payment expired!”);<strong> // Time now &lt; time when last payment expire</strong></pre><pre>_;</pre><pre>}</pre><h4>Allow the smart contract to receive Ethers</h4><pre><strong>// Allow the smart contract to receive ether</strong></pre><pre>receive() <em>external</em> <em>payable</em> onlyOwner {</pre><pre>}</pre><p>Functions to pay the subscription or to pay in advance</p><pre><strong>// Make a payment</strong></pre><pre><em>function</em> paySubscription(<em>uint256</em> <em>_period</em>) <em>public</em> <em>payable</em> {</pre><pre>if(paymentOption == 1) {</pre><pre>require(msg.value == ethFee.mul(_period));</pre><pre>totalPaymentsEth = totalPaymentsEth.add(msg.value); <br><strong>// Compute total payments in Eth</strong></pre><pre>userTotalPaymentsEth[msg.sender] = userTotalPaymentsEth[msg.sender].add(msg.value); <br><strong>// Compute user&#39;s total payments in Eth</strong></pre><pre>} else {</pre><pre>secondaryTokenForPayment.safeTransferFrom(msg.sender, <em>address</em>(this), erc20Fee.mul(_period));</pre><pre>totalPaymentsErc20 = totalPaymentsErc20.add(erc20Fee.mul(_period)); <strong>// Compute total payments in Erc20 tokens</strong></pre><pre>userTotalPaymentsErc20[msg.sender] = userTotalPaymentsErc20[msg.sender].add(erc20Fee.mul(_period)); <br><strong>// Compute user&#39;s total payments in Erc20</strong></pre><pre>}</pre><pre>Payment <em>memory</em> newPayment = Payment(msg.sender, block.timestamp, block.timestamp.add(_period.mul(30 days)));</pre><pre>payments.push(newPayment); <strong>// Push the payment in the payments array</strong></pre><pre>userPayment[msg.sender] = newPayment; <strong>// User&#39;s last payment</strong></pre><pre>}</pre><pre><strong>// Pay in advance</strong></pre><pre><em>function</em> payInAdvance(<em>uint256</em> <em>_period</em>) <em>public</em> <em>payable</em> {</pre><pre>if(paymentOption == 1) {</pre><pre>require(msg.value == ethFee.mul(_period));</pre><pre>totalPaymentsEth = totalPaymentsEth.add(msg.value); <strong>// Compute total payments in Eth</strong></pre><pre>userTotalPaymentsEth[msg.sender] = userTotalPaymentsEth[msg.sender].add(msg.value); <br><strong>// Compute user&#39;s total payments in Eth</strong></pre><pre>} else {</pre><pre>secondaryTokenForPayment.safeTransferFrom(msg.sender, <em>address</em>(this), erc20Fee.mul(_period));</pre><pre>totalPaymentsErc20 = totalPaymentsErc20.add(erc20Fee.mul(_period)); <strong>// Compute total payments in Erc20 tokens</strong></pre><pre>userTotalPaymentsErc20[msg.sender] = userTotalPaymentsErc20[msg.sender].add(erc20Fee.mul(_period)); <br><strong>// Compute user&#39;s total payments in Erc20</strong></pre><pre>}</pre><pre><em>uint256</em> newExpirationPeriod = userPayment[msg.sender].paymentExpire.add(_period.mul(30 days));</pre><pre>Payment <em>memory</em> newPayment = Payment(msg.sender, block.timestamp, newExpirationPeriod);</pre><pre>payments.push(newPayment);<strong> // Push the payment in the payments array</strong></pre><pre>userPayment[msg.sender] = newPayment; <strong>// User&#39;s last payment</strong></pre><pre>}</pre><p>For those functions, we use the <strong>_period argument</strong> which represents the number of months for which you want to pay the subscription. The total fee will be computed as follows: <strong>actual fee * period.</strong></p><p>The “payInAdvance” function acts like the “paySubscription” function but it modifies the expiration period of the last payment by adding <strong>_period * 30 days</strong>.</p><h4>Setters</h4><pre><strong>// Setters</strong></pre><pre><em>function</em> setEthFee(<em>uint256</em> <em>_newEthFee</em>) <em>public</em> onlyOwner {</pre><pre>ethFee = _newEthFee;</pre><pre>}</pre><pre><em>function</em> setErc20Fee(<em>uint256</em> <em>_newErc20Fee</em>) <em>public</em> onlyOwner {</pre><pre>erc20Fee = _newErc20Fee;</pre><pre>}</pre><pre><em>function</em> setNewOwner(<em>address</em> <em>_newOwner</em>) <em>public</em> onlyOwner {</pre><pre>owner = _newOwner;</pre><pre>}</pre><pre><em>function</em> setTokenForPayment(<em>IERC20</em> <em>_newToken</em>) <em>public</em> onlyOwner {</pre><pre>secondaryTokenForPayment = _newToken;</pre><pre>}</pre><pre><em>function</em> setPaymentOption(<em>uint256</em> <em>_paymentOption</em>) <em>public</em> onlyOwner {</pre><pre>require(_paymentOption == 1 || _paymentOption == 2, &quot;Invalid option!&quot;);</pre><pre>paymentOption = _paymentOption;</pre><pre>}</pre><p><strong>Getters</strong></p><pre><strong>// Getters</strong></pre><pre><em>function</em> lastPaymentOfUser(<em>address</em> <em>_user</em>) <em>public</em> <em>view</em> returns(<em>uint256</em>) {</pre><pre>return userPayment[_user].paymentMoment;</pre><pre>}</pre><h4>The important part</h4><pre><strong>// Action for testing</strong></pre><pre><strong>// Add your function instead</strong></pre><pre><em>function</em> doAction() <em>public</em> userPaid {</pre><pre>forTesting = forTesting.add(1);</pre><pre>}</pre><p>This function was used only for testing purposes. Whenever it’s called, will increment the “forTesting” variable by 1.</p><p>We are using the <strong>“userPaid” modifier</strong> in order to check if the last payment of the user expired or not.</p><p><strong>Source code:</strong> <a href="https://github.com/DRIVENpol/Subscription-Smart-Contract/tree/main">https://github.com/DRIVENpol/Subscription-Smart-Contract/tree/main</a></p><p><em>If you have any questions don’t hesitate to text me on Twitter: </em><a href="https://twitter.com/polthedev"><em>https://twitter.com/polthedev</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca89347a15d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>