<?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 Bouzaiene Chemseddine on Medium]]></title>
        <description><![CDATA[Stories by Bouzaiene Chemseddine on Medium]]></description>
        <link>https://medium.com/@bouzaiene.ch?source=rss-67e7b7786dc4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*myZlYNREeMfFPJWbeTd2tQ.jpeg</url>
            <title>Stories by Bouzaiene Chemseddine on Medium</title>
            <link>https://medium.com/@bouzaiene.ch?source=rss-67e7b7786dc4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 04:56:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bouzaiene.ch/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[Build An Etheruem Bridge -Part 1]]></title>
            <link>https://medium.com/swlh/build-an-etheruem-bridge-part-1-b97c8eae0d9e?source=rss-67e7b7786dc4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b97c8eae0d9e</guid>
            <category><![CDATA[truffle]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Bouzaiene Chemseddine]]></dc:creator>
            <pubDate>Mon, 07 Oct 2019 15:01:03 GMT</pubDate>
            <atom:updated>2019-10-14T13:08:56.323Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*ktoph8x8Gzreiy8Xh0fdqw.png" /></figure><h3>Introduction :</h3><p>Blockchain is one of those technologies that is getting too much attention in the last few years thanks to cryptocurrencies and the hype around them. More developers are interested in this new technology and started building their own Blockchain-based projects, which is exactly why we need a developer-friendly blockchain environment. One of the most popular ones is the Ethereum Blockchain, and for a good reason, it provides a set of tools that makes it easier for even beginners and has its own object-oriented programming language: Solidity. It is getting a lot of support from the blockchain community, from small startups to big enterprises to keep improving the work of the system. But like everything else, there are some drawbacks, since Ethereum is a public Blockchain, and so many businesses, enterprises, and even individuals rely on it, one major issue as a consequence is the effect on the transaction’s processing speed. In fact, you can state that the number of verified transactions per second is relatively low, which leads in numerous cases to hours of waiting to treat the user’s request. we should also mention the gas fee that can get quite expensive. Some of these problems could be solved through compromising a certain level of decentralization, by migrating toward a private blockchain. This way the treating and processing transactions will be way faster, more secure and the gas fee will be significantly lower.</p><p>In this tutorial, we will be guiding you to showcase how we can build an Ethereum bridge a Nodejs microservice as a side chain oracle to connect two blockchains a public and a private one But first, let’s talk about why we need an Ethereum bridge and discusses it’s use cases.</p><h3>Use Case :</h3><p>Ethereum bridge is necessary when we need to utilize the potential market of ETHER, privacy, and speed of a private configurable Ethereum blockchain like implementing a double token system, let’s take an example. let’s say we want to build a simple gambling game; a decentralized application on the Ethereum blockchain. we will have too many interactions in the game, and for every interaction the player has to wait for an average of 15s to validate the transaction. Each time he will have to pay for gas , which will eventually cost too much for the players.</p><p>One solution is to use a private blockchain. This way, the player can play the game for free , no gas and nearly instantaneous block time. Once the game finishes and it’s time to settle payments, the bridge will interact with the public blockchain and add or take money from each player’s account depending on the game’s outcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*YDiLhB5jOrMqRZZrpWnYFg.png" /><figcaption>The Dapp Flow</figcaption></figure><p>In our case, to make it simple, we will be deploying two smart contracts to the Ethereum blockchains and linking them using an Oracle built with NodeJs. The private blockchain smart contract will be composed of two main functions : one which saves each interaction of the user with the Dapp and the second will be a function to withdraw money when the game finishes and the public blockchain’s smart contract will be composed of a function that will change the player balance after it receives his result from the Ethereum bridge, it’s simple right? I know it may seem complicated right now but stick with us and you will get the picture, now let’s get technical.</p><h4><strong>Tools we will need :</strong></h4><ul><li>Ganache</li><li>Node JS</li><li>Truffle</li><li>Metamask</li><li>Solidity Compiler</li><li>Any code editor</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/0*xLkKD4yNkIcDumzr" /></figure><p>The perfect private Ethereum blockchain which you can use to run tests, execute commands, and inspect state while controlling how the chain operates.</p><p>you can consider ganache as your personal Blockchain it is a part of truffle’s ecosystem where you can develop Dapps (decentralized apps) and deploy your contracts and test them. Since writing to the blockchain requires gas fees, Ganache gives you ten accounts containing fake ethers that you can use to pay for your tests. since it’s only a local blockchain you won’t need to pay actual money, therefore, fake ethers will do the job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mw5eBV7_ylU4u-RI" /></figure><p><strong>Installation :</strong></p><p>Download Ganache <a href="https://github.com/trufflesuite/ganache/releases/tag/v2.1.0">https://github.com/trufflesuite/ganache/releases/tag/v2.1.0</a></p><blockquote>$ chmod a+x <a href="https://github.com/trufflesuite/ganache/releases/download/v2.1.0/Ganache-2.1.0.AppImage">Ganache-2.1.0.AppImage</a></blockquote><blockquote>$ ./ganache-1.3.0-x86_64.AppImage</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*XzIn6WokP4tiQtP97jygBg.png" /></figure><p>NodeJS will be our development environment for the Oracle and Truffle requires NodeJS v8.9.4 or later (at the time of writing), so the next step will be to install NodeJS from the Ubuntu 18.04 distribution repository.</p><p><strong>Installation :</strong></p><blockquote>$ sudo apt update</blockquote><blockquote>$ sudo apt install nodejs npm</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/136/1*djIQh500ZW0k2xfEitYCdw.png" /></figure><p>Once npm is installed, you can install Truffle with this command, Truffle will be our development environment for smart contracts :</p><blockquote>$ sudo npm install -g truffle</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/205/1*cGaTUi-SjgZMRtLv-bsm0Q.png" /></figure><p>Metamask is a fundamental and very powerful tool for ethereum development. So in a nutshell, it allows you to transform your regular chrome browser into a blockchain one, therefore you will be able to run ethereum Dapps directly on your browser without the need to run a full ethereum node. it will be basically a bridge not only to the main ethereum blockchain but to many other blockchain test nets including Ganache and Ropsten on which we will be working throughout this tutorial. You may also make your own blockchain and connect to it through it. this extension is very simple to install and use, this tutorial will guide you through it. Make sure to save your Metamask seed phrase somewhere safe.</p><p>Link how to setup <a href="https://blog.wetrust.io/how-to-install-and-use-metamask-7210720ca047">MetaMask</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*EyiYd69LTaKg5yQHfbIvkw.png" /></figure><p>We will be using Solidity programming language for our Ethereum smart contract, solidity is the language used for the ethereum development, it is a high-level language that is object-oriented as many other languages you might have used. In case you have some javascript knowledge, solidity won’t be that much different, but even if you don’t then you will find here a great and fun way to learn Solidity. <a href="https://cryptozombies.io/en/course">CryptoZombies</a></p><p>install the compiler using this command :</p><blockquote>npm install -g solc</blockquote><p>we will be using visual studio code as my editor, feel free to download some extensions that will make it a little bit easier, some of my personal favorites are Solidity, Prettier to format your code.</p><h3><strong>Step 1: Setup the project :</strong></h3><p>1- Creating the folder structure :</p><p>Create a Bridge folder under that folder create three folders</p><p>Oracle / Private / Public</p><p>Bridge</p><p>├── Oracle // this folder will contain the bridge API</p><p>├── Private // this folder will contain Truffe Private Smart contract</p><p>└── Public // this folder will contain Truffe Public Smart contract</p><p>2- Add ganache RPC SERVER ( IP ) address to Metamask :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GFCwBmkcW55dWV8c" /></figure><p>3 — Create Infura account :</p><ul><li>sign up to Infura <a href="https://infura.io/register">here</a></li><li>save your Infura API key</li></ul><h3><strong>Step 2: Deploying the private blockchain smart contract</strong></h3><p>In order to deploy the private blockchain Dapp in this example, it’s just a simple smart contract that saves the transaction, first start a new truffle project, under the private folder instantiate truffle project through this command.</p><blockquote>$ truffle init</blockquote><p>Once we make a truffle project we’ll have a few folders and files already made that we will want to personalize.</p><p>So let’s go through this architecture element by element, we will first notice the contracts folder</p><p>contracts: this is where we will be writing our smart contracts, but what exactly is a smart contract As the name suggests, smart contracts are similar to real-life contracts, but in this case, they are completely digital. it is where we can find all the business logic of our application, so basically where we are going to write all the code that will write or read from the ethereum blockchain. the best way to understand them might be through the words of the ethereum-Blockchain Co-founder himself, Vitalik Buterin <a href="https://www.youtube.com/watch?v=r0S4qIMf4Pg">here</a></p><p>migrations : if you are familiar with web development and frameworks such as dotNet then you most likely created migrations to change your database. in our case they are javascript files that will allow us to deploy our smart contracts on the ethereum blockchain since while doing so we’re actually creating a transaction on the blockchain, therefore altering its state, similar to changing our database. So as we write further code or modify them we will be creating new migrations to follow our project’s evolution, so they are basically a group of steps that we followed while building our application allowing us to have a history of the changes we made. we run these migrations simply through the command line.</p><blockquote>$ truffle migrate</blockquote><p>more details about migrations <a href="https://www.sitepoint.com/truffle-migrations-explained/">here</a></p><p>truffle-config.js (or truffle.js): this file is meant to execute your personal configurations such as the network you will be deploying your project on…</p><p>Build folder :</p><p>After compiling your contracts, you will find artifacts under the build/contracts folder (that will be created if it didn’t exist when you first made the project) these artifacts such as migrations.json and YourSmartContract.json.. that contain important information (Abi..) that will allow us to successfully deploy our application , therefore we should not change these files ourselves, they will be automatically overwritten as the project changes.</p><p>Test folder :</p><p>truffle offers a way to make testing your contracts easier through providing tools such as <a href="https://mochajs.org/">Mocha</a> testing framework and <a href="https://www.chaijs.com/">Chai</a> for assertions in order to execute the tests and make sure that everything is working correctly.</p><p>now create a new file inside the contracts folder name it PrivateQueue.sol and copy this smart contract code into it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee477f1ebad1a666620d391dd82aebd5/href">https://medium.com/media/ee477f1ebad1a666620d391dd82aebd5/href</a></iframe><p>Now we have to configure the truffle-config file and add a new migration file inside the migrations folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3edae79b0f7943d316271baf8c0415d7/href">https://medium.com/media/3edae79b0f7943d316271baf8c0415d7/href</a></iframe><p>in every migration, we should have the deployer object passed as the first parameter in the module.exports() function, this is crucial to successfully deploy our smart contract.</p><p>this will be explained in more detail in the truffle documentation that you will find <a href="https://www.trufflesuite.com/docs/truffle/overview">here</a>.</p><ul><li>truffle-config.js</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/413768c7157d94bcedd594cba2154022/href">https://medium.com/media/413768c7157d94bcedd594cba2154022/href</a></iframe><p>Since we will be working on a private blockchain we must then define the network we will be interacting with. First, we will configure our private network which is our local one, Ganache. In the truffle-config.js (or truffle.js depending on your project) file we start by declaring the first network inside the networks brackets, we need to state the port number, the network id which will be both written on the top bar of your Ganache interface, the host address will be our localhost.</p><p>In order to run our migration we need to specify each time which network we want to run, we can do that by simply adding its name after truffle migrates as so :</p><blockquote>$ truffle migrate — network private</blockquote><p>Now that our smart contract is deployed on the blockchain we can proceed and check the build files but first, let’s explain what just happened.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yHSjSXJMqSMWfUjvP-eTdw.png" /></figure><p>Truffle started by compiling PrivateQueue.sol and Migrations.sol under the contracts folder into the build folder. We could have done this step first using the “truffle compile” command. Since we didn’t do it, “truffle migrate” did it for us.</p><p>Next, it deployed the 2 contracts to the ganache network. We got the transaction and contract addresses for each contract deployed. The number of transactions could be verified in ganache.</p><p>But why exactly we are deploying this migration.sol smart contract and paying gas for that ? to put it simply because the migrations smart contract keep track of the number of smart contracts deployed on the blockchain so when we upgrade a smart contract or add a new one we don’t have to redeploy every contract the migration will track which contract it should deploy</p><p>Now everything is set up for the private blockchain to check that our smart contract is deployed we can check the ganache interface and we will notice new blocks had been created and that the account balance has decreased due to deployment gas fee that we paid.</p><p>Now we will move on to the public blockchain setup and smart contract in this guide will be using Ropsten testnet.</p><h3><strong>Step 3: Deploying the public blockchain smart contract</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98c8b74bf3295da41ed9f4dc4fe10882/href">https://medium.com/media/98c8b74bf3295da41ed9f4dc4fe10882/href</a></iframe><p>Repeat the same process of building the private blockchain smart contract :</p><p>1- pass truffle init cmd under the public folder</p><p>2- create a new file “PublicQueue” under contracts folder copy the code above init</p><p>3-add a new migration file 2_public_migration.js under migrations</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11377d89122c47d32a912eb5906ec3c3/href">https://medium.com/media/11377d89122c47d32a912eb5906ec3c3/href</a></iframe><p>4-before deploying the smart contract we need to prepare the truffle config file this time we are going deploy to Ropsten public blockchain so the config is different.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe84d49e698c911591c39787b2dc0646/href">https://medium.com/media/fe84d49e698c911591c39787b2dc0646/href</a></iframe><p>5 -Deploying the contract :</p><p>We must keep in mind that writing to the blockchain always costs gas fees, so in order to deploy our smart contract we need to pay for our transactions to pass, but since we are working on Testnet and not the main Ethereum network we won’t be needing real money.</p><p>In order to deploy on the Ropsten network we can simply get fake ethers by just providing your Ropsten account on Metamask address <a href="https://faucet.ropsten.be/">here</a> and it will give you ethers to pay for your gas fees.</p><p>After having your smart contract and migrations ready to be compiled and deployed, run the truffle migrate command and precise your network:</p><blockquote>$ truffle migrate — network ropsten</blockquote><p>To check if your transaction has passed you can simply copy your transaction address and see if it exists on <a href="https://etherscan.io/">Etherscan</a>, don’t forget to switch to the Ropsten blockchain</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AAoSzo4VzY8F_dQU" /></figure><p>5 — Now just pass this command inside the public blockchain folder :</p><blockquote>$ truffle migrate — network ropsten</blockquote><p>Now after deploying our two smart contracts We will build the bridge that links the two smart contracts in the next article very soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b97c8eae0d9e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/build-an-etheruem-bridge-part-1-b97c8eae0d9e">Build An Etheruem Bridge -Part 1</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>