<?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[Interfacing with an Ethereum Blockchain - Medium]]></title>
        <description><![CDATA[Sharing Experiences with Smart Contract Development - Medium]]></description>
        <link>https://medium.com/interfacing-with-a-blockchain?source=rss----d813e788a310---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Interfacing with an Ethereum Blockchain - Medium</title>
            <link>https://medium.com/interfacing-with-a-blockchain?source=rss----d813e788a310---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 10:29:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/interfacing-with-a-blockchain" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Communicating with an Ethereum Smart Contract via Android]]></title>
            <link>https://medium.com/interfacing-with-a-blockchain/communicating-with-an-ethereum-smart-contract-via-android-24ee0dd2c115?source=rss----d813e788a310---4</link>
            <guid isPermaLink="false">https://medium.com/p/24ee0dd2c115</guid>
            <category><![CDATA[infura]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[web3j]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <dc:creator><![CDATA[Ebenezer Ackon]]></dc:creator>
            <pubDate>Fri, 01 Feb 2019 04:19:48 GMT</pubDate>
            <atom:updated>2022-10-19T02:14:08.825Z</atom:updated>
            <content:encoded><![CDATA[<p><em>— UPDATED OCTOBER 18th, 2022</em></p><p><strong>This article aims to show you how to:</strong></p><ol><li>Generate a contracts ABI and binary files from a solidity file.</li><li>Use <strong>web3j</strong> libraries to generate java wrapper classes from a smart contract’s methods.</li><li>Use <strong>Infura</strong> to host an Ethereum node remotely that allows us to complete transactions and interact with the blockchain.</li><li>Verify a transaction was made via the Etherscan blockchain explorer.</li></ol><h3><strong>Necessary Tools</strong></h3><ol><li><a href="https://github.com/web3j/web3j"><strong>Web3j</strong></a><strong><br></strong>Web3j is a lightweight, highly modular, reactive, type safe Java and Android library for working with Smart Contracts and integrating with clients (nodes) on the Ethereum network. This allows you to work with the Ethereum blockchain, without the additional overhead of having to write your own integration code for the platform. <a href="https://www.youtube.com/watch?v=ea3miXs_P6Y">Here</a> is a 30minute video from the creator of the library explaing it’s usecase.</li><li><a href="https://infura.io/"><strong>Infura</strong></a><strong><br></strong>Infura allows us to host our very own node on the blockchain remotely. Infura provides the infrastructure so that we can send transactions and communicate with other nodes as if we have the blockchain downloaded on our local machine.<br><strong>Note: Infura is not necessary if you are running your own node and not interacting with a smart contract that’s already deployed.</strong></li><li><a href="https://solidity.readthedocs.io/en/"><strong>Solidity</strong></a><strong> Command Line Interface (solc)<br></strong>Solidity is an object-oriented programming language for writing smart contracts. Solc is the command line compiler we will use to generate our contract binary and <a href="https://solidity.readthedocs.io/en/develop/abi-spec.html">A</a>BI.</li><li><a href="https://developer.android.com/studio/"><strong>Android Studio IDE</strong></a><strong><br></strong>Android Studio is the official Integrated Development Environment (IDE) for Android app development, based on IntelliJ IDEA . On top of IntelliJ’s powerful code editor and developer tools, Android Studio offers even more features that enhance your productivity when building Android apps. Android Studio is the recommended way to start developing android apps (as of Feb 2019).</li></ol><p><strong>Note: This article does not explain how to set up the Android Development Environment, so make sure you can at least run a basic hello world.</strong></p><p><strong>Note: I recommend using terminal when following along, window users are encouraged to use Powershell or something similar.</strong></p><h3><strong>Lets Start</strong></h3><ol><li>Check if solidity cli is installed:</li></ol><p>solcjs --version</p><p>If it’s not installed, install it globally.</p><p>npm install -g solc</p><p>Then check again.</p><p>2. Check if web3j is installed:</p><p>web3j -v</p><p>If it’s not installed,</p><p>Mac:</p><p>Install it using this command</p><pre>curl -L get.web3j.io | sh &amp;&amp; source ~/.web3j/source.sh</pre><p>Note: If any issues occur in regards to openjdk, please download the latest jdk from <a href="https://www.oracle.com/java/technologies/javase-downloads.html">https://www.oracle.com/java/technologies/javase-downloads.html</a></p><p>Windows:<br>Download the zip.</p><pre><a href="https://github.com/web3j/web3j/releases/tag/v4.1.1">https://github.com/web3j/web3j/releases/tag/v4.1.1</a></pre><p>3. Find a contract to communicate with, the contract i’m using is my very own <a href="https://github.com/EbenezerGH/Greeter-Contract">Greeter contract</a> which I verified and deployed <a href="https://medium.com/interfacing-with-a-blockchain/deploy-and-verify-ca9dcf9e6cd3">last article</a>. The public address of my contract is <a href="https://rinkeby.etherscan.io/address/0x8394cdf176a4a52da5889f7a99c4f7ad2bf59088">0x8394cdf176a4a52da5889f7a99c4f7ad2bf59088</a>. <br><a href="https://rinkeby.etherscan.io/address/0x8394cdf176a4a52da5889f7a99c4f7ad2bf59088">Contract on Etherscan</a></p><p>Contract code:</p><pre>pragma solidity ^0.4.23;<br><br><br><br>contract Mortal {<br>    /* Define variable owner of the type address */<br>    address owner;<br><br>    /* This function is executed at initialization and sets the owner of the contract */<br>    constructor() public { owner = msg.sender; }<br><br>    /* Function to recover the funds on the contract */<br>    function kill() public {<br>        if (msg.sender == owner) <br>            selfdestruct(owner); <br>    }<br>}<br><br>contract Greeter is Mortal {<br>    /* Define variable greeting of the type string */<br>    string greeting;<br><br>    /* This runs when the contract is executed */<br>    constructor(string _greeting) public {<br>        greeting = _greeting;<br>    }<br><br>    /* change greeting */<br>    function changeGreeting(string _greeting) public {<br>        greeting = _greeting;<br>    }<br>    <br>    /* Main function */<br>    function greet() public view returns (string) {<br>        return greeting;<br>    }<br>}</pre><p>4. Create an account with Infura, in your dashboard:<br>a) Whitelist your contract address.<br>b) Specify the correct network (Rinkeby, mainnet, etc.).<br>c) Copy and save your endpoint address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7Jg9TmoNireFualkJ-h4Q.png" /><figcaption>Infura Dashboard</figcaption></figure><h3><strong>Now For the Android Part:</strong></h3><ol><li>Create a new project and add web3j’s core and infura libraries to your app module build.gradle.</li></ol><pre>// dependencies for contract interaction<br>implementation &#39;org.web3j:infura:3.3.1-android&#39;<br>implementation &#39;org.web3j:core:3.1.1-android&#39;</pre><p>2. Generate your bin and ABI by first copying the solidity file somewhere into your project directory. Type in the following command into your command line.</p><p>solc &lt;contract&gt;.sol — bin — abi — optimize -o &lt;output-dir&gt;/</p><p>My line of code looked like:</p><pre>solc Greeter.sol — bin — abi — optimize -o /Users/e/Documents/programming/android/projects/GreeterApp/app/src/main/java/iwd/props/com/greeterapp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YFKjCRcbTS0HndxEaJ4fCA.png" /><figcaption>IDE after typing commands</figcaption></figure><p>The Contract ABI and binary should be generated in the output directory. I have an ABI and Binary for Greeter and Mortal generated because my Greeter.sol code extends Mortal.sol.</p><p><strong>Note: If you already have the contract’s binary and ABI, then you don’t need to use web3j to generate it. Just get those values and create the classes, then use them on the next step.</strong></p><p>3. Now it’s time to generate your Java code using</p><pre>web3j solidity generate -b /path/to/&lt;smart-contract&gt;.bin -a /path/to/&lt;smart-contract&gt;.abi -o /path/to/src/main/java -p com.your.organisation.name</pre><p>My command looks like:</p><pre>web3j solidity generate -b iwd/props/com/greeterapp/Greeter.bin -a iwd/props/com/greeterapp/Greeter.abi -p iwd.props.com.greeterapp -o /Users/e/Documents/programming/android/projects/GreeterApp/app/src/main/java/iwd/props/com/greeterapp</pre><p>After running this command, a Greeter.java file is generated that extends Contract.</p><p>My full generated class is <a href="https://github.com/EbenezerGH/Greeter-Android-App/blob/master/app/src/main/java/iwd/props/com/greeterapp/Greeter.java">here</a>.</p><p><strong>Note: the following code is written in Kotlin</strong></p><p>4. In your kotlin class, define some important variables. You can do this in your MainActivity.</p><pre>// contract address<br>val contractAddress = &quot;0x8394cDf176A4A52DA5889f7a99c4f7AD2BF59088&quot;</pre><pre>// endpoint url provided by infura<br>val url = &quot;https://rinkeby.infura.io/v3/01eb8f7b5e514832af8e827c23784d23&quot;</pre><pre>// web3j infura instance<br>val web3j = Web3jFactory.build(InfuraHttpService(url))</pre><pre>// gas limit<br>val gasLimit: BigInteger = BigInteger.valueOf(20_000_000_000L)</pre><pre>// gas price<br>val gasPrice: BigInteger = BigInteger.valueOf(4300000)</pre><pre><em>// create credentials w/ your private key<br></em>val credentials = Credentials.create(&quot;f9319fe162c31947c0ca8fd649a536b7ca311b5f210afdc48b62fd7d18ce53e4&quot;)</pre><p>After these variables are set, you will be able to load your contract with:</p><pre>val greeter = Greeter.load(contractAddress, web3j, credentials, gasLimit, gasPrice)</pre><p>5. We are now able to interact with the classes that my Greeter.java class provides (greet(), changeGreeting()). We can could also interact with some default web3j functions like isValid(). This allows us to do a quick sanity check and make sure that our contract was generated correctly.</p><p>Check Contract Validity</p><pre>// check contract validity<br>Log.d(TAG, &quot; ${greeter.<em>isValid</em>}&quot;)</pre><p>Read from Contract</p><pre>// read from contract<br>val greeting: Future&lt;String&gt;? = greeter.greet().sendAsync()<br>val convertToString: String? = greeting?.get()<br>Log.d(TAG, &quot;greeting value returned: $convertToString&quot;)</pre><p>Write to Contract</p><pre>// write to contract<br>val transactionReceipt: Future&lt;TransactionReceipt&gt;? = greeter.changeGreeting(&quot;Greeting changed from an Android App (ಠ_ಠ) &quot;).sendAsync()<br>val result = &quot;Successful transaction. Gas used: ${transactionReceipt?.get()?.<em>blockNumber</em>}  ${transactionReceipt?.get()?.<em>gasUsed</em>}&quot;<br>Log.d(TAG, result)</pre><p>Transaction results on etherscan:</p><p><a href="https://rinkeby.etherscan.io/tx/0x9e6add7138f7d0b0488be727010b783dd227f8498d9e00fc139e19e89c9f978d#decodetab">https://rinkeby.etherscan.io/tx/0x9e6add7138f7d0b0488be727010b783dd227f8498d9e00fc139e19e89c9f978d#decodetab</a></p><p><strong>Conclusion:</strong></p><p>The completed project is on <a href="https://github.com/EbenezerGH/Greeter-Android-App">Github</a>.</p><p><strong>Sources:</strong><br><a href="https://github.com/EbenezerGH/Greeter-Android-App">https://github.com/EbenezerGH/Greeter-Android-App</a><br><a href="https://github.com/EbenezerGH/Greeter-Contract">https://github.com/EbenezerGH/Greeter-Contract</a><br><a href="https://infura.io/docs/gettingStarted">https://infura.io/docs/gettingStarted</a><br><a href="https://rinkeby.etherscan.io/">https://rinkeby.etherscan.io/</a><br><a href="https://github.com/web3j/web3j">https://github.com/web3j/web3j</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24ee0dd2c115" width="1" height="1" alt=""><hr><p><a href="https://medium.com/interfacing-with-a-blockchain/communicating-with-an-ethereum-smart-contract-via-android-24ee0dd2c115">Communicating with an Ethereum Smart Contract via Android</a> was originally published in <a href="https://medium.com/interfacing-with-a-blockchain">Interfacing with an Ethereum Blockchain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to set up your Ethereum development environment for MacOS]]></title>
            <link>https://medium.com/interfacing-with-a-blockchain/how-to-set-up-your-ethereum-development-environment-for-macos-cac42af966fd?source=rss----d813e788a310---4</link>
            <guid isPermaLink="false">https://medium.com/p/cac42af966fd</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain-education]]></category>
            <category><![CDATA[truffle]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Ebenezer Ackon]]></dc:creator>
            <pubDate>Fri, 11 Jan 2019 05:52:18 GMT</pubDate>
            <atom:updated>2019-01-16T01:02:58.850Z</atom:updated>
            <content:encoded><![CDATA[<p>I will introduce the proper tooling and show you how to prepare your PC for writing smart contracts and interfacing with the Ethereum blockchain.</p><h3>Necessary Tools</h3><ol><li><a href="https://brew.sh/"><strong>Homebrew</strong></a><br>Homebrew is a package manager for macOS.</li><li><a href="https://code.visualstudio.com/"><strong>Visual Studio Code</strong></a><br>Visual Studio Code is my code editor of choice when it comes to writing smart contracts. It’s super lightweight, full of extensions created by the community, and has powerful debugging tools. Obviously opinions may differ when it comes to which code editor or IDE to use. The final decision is yours.</li><li><a href="https://github.com/ethereum/go-ethereum/wiki/geth"><strong>Geth</strong></a><strong> (Go Ethreum)</strong><br>Geth is the the command line interface for running a full Ethereum node implemented in Go. It allows you the ability to do practically anything you would need to do on the blockchain (commands listed <a href="https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options">here</a>).</li><li><a href="https://truffleframework.com/ganache"><strong>Ganache</strong></a><strong><br></strong>Ganache is a blockchain emulator that allows you to run tests, execute commands, and inspect state while controlling how the blockchain operates. Ganache was called Test RPC in the past, but the developers learned from Android that tasty dessert names are more appealing. The blockchain you create is personal, has user friendly UI, and runs quickly in memory.</li><li><a href="https://www.w3schools.com/whatis/whatis_npm.asp"><strong>NPM</strong></a><strong><br></strong>NPM is a package manager for Node.js. We’ll be using this to download dependencies like Truffle.</li><li><a href="https://truffleframework.com/"><strong>Truffle</strong></a><strong><br></strong>Truffle is an awesome tool that makes the developers job much easier. It’s provides a testing framework, smart contract compilation, linking, deployment, and much more. It also handles a lot of boilerplate for you when you get into the realm of using <a href="https://truffleframework.com/boxes">boxes</a>.</li></ol><h3>Lets Start</h3><ol><li>Install Homebrew by asting the following command into the terminal.</li></ol><pre>/usr/bin/ruby -e &quot;$(curl -fsSL <a href="https://raw.githubusercontent.com/Homebrew/install/master/install">https://raw.githubusercontent.com/Homebrew/install/master/install</a>)&quot;</pre><p>Go through the the installation and when you see <strong>Installation Successful</strong> you’re done!</p><p>Type brew update</p><p>2. Install Visual Studio Code .zip from <a href="https://code.visualstudio.com/docs?dv=osx"><em>https://code.visualstudio.com/docs?dv=osx</em></a>. Go through the installation process.</p><p>After Downloading and opening you will need to download the solidity extension to allow you to write in that language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mkga9qx8TgocyBEay0D5IA.png" /></figure><p>Type ‘Solidity’ in the search bar and get the extension with the information listed below, It should be the first one suggested.</p><blockquote>Name: solidity<br>Id: juanblanco.solidity<br>Description: Ethereum Solidity Language for Visual Studio Code<br>Version: 0.0.49<br>Publisher: Juan Blanco<br>VS Marketplace Link: <a href="https://marketplace.visualstudio.com/items?itemName=juanblanco.solidity">https://marketplace.visualstudio.com/items?itemName=juanblanco.solidity</a></blockquote><p>3. Install Geth (Go-Ethereum)<br>We’re going to use homebrew to connect to the Geth repository. We will need to access <a href="https://github.com/ethereum/homebrew-ethereum"><em>https://github.com/ethereum/homebrew-ethereum</em></a> to download the Ethereum client. In your terminal type in the following commands.</p><p>a)brew tap ethereum/ethereum<br>b)brew install ethereum<br>or brew update ethereum if geth is already installed on your machine.</p><p>4. Install Ganache<br><a href="http://truffleframework.com/ganache/"><em>http://truffleframework.com/ganache/</em></a></p><p>5. Install NodeJS and the NPM package manager</p><p>a) brew install node<br>sanity check that all is well by checking their versions<br>b) node -v<br>c) npm -v</p><p>6. Install Truffle now that we have node installed. To avoid complications we’ll do a truffle uninstall first. Truffle can get finicky if the installation detects traces of it elsewhere on your computer.</p><p>npm uninstall -g truffle<br>npm install -g truffle</p><p><strong>DONE!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*X2bF8TTAd_KFzl-GfQcJYg.png" /><figcaption>version check</figcaption></figure><h3>The Final Test</h3><ol><li>Get Balance From one of our generated accounts</li><li>Convert that Balance From Wei to Ether</li></ol><p>Our Sources:<br><a href="https://web3js.readthedocs.io/en/1.0/web3-utils.html?highlight=fromwei#fromwei"><em>https://web3js.readthedocs.io/en/1.0/web3-utils.html?highlight=fromwei#fromwei</em></a></p><p><a href="https://web3js.readthedocs.io/en/1.0/web3-eth.html"><em>https://web3js.readthedocs.io/en/1.0/web3-eth.html</em></a></p><p>In Terminal type in</p><p>a) truffle init<br>b) truffle migrate<br>c) truffle develop</p><p>After a list of the 10 generated accounts are shown, you can select any of the public addresses and use the web3 command to get its balance. All of the generated test addresses will have a balance of 100 Ether, but it will be shown in wei unless we convert it.</p><pre>web3.eth.getBalance(“[Address]”)</pre><p>this command prints out the Address’ balance in wei. To convert it we will take the result and specify it’s conversion type.</p><pre>web3.utils.fromWei(`[wei value]`, &#39;ether&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*67FOtRCDtQsMe7ROgrqoDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*PBVd1d291FilGFazvwAUrg.png" /></figure><h3>Conclusion</h3><p>You’re setup and ready to start writing contracts. I recommend filling in any loopholes in your knowledge at</p><ol><li><a href="https://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html">https://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html</a></li><li><a href="https://www.bitdegree.org/learn/solidity-introduction/">https://www.bitdegree.org/learn/solidity-introduction/</a></li><li><a href="https://web3js.readthedocs.io/en/1.0/web3-eth.html">https://web3js.readthedocs.io/en/1.0/web3-eth.html</a></li></ol><p><a href="https://medium.com/interfacing-with-a-blockchain/deploy-and-verify-ca9dcf9e6cd3">Here</a> is another article I wrote that demonstrates publishishing smart contracts to the testnet or mainnet, check it out!</p><h3>Sources</h3><p><a href="https://brew.sh/">https://brew.sh/</a><br><a href="https://github.com/ethereum/go-ethereum/wiki/geth">https://github.com/ethereum/go-ethereum/wiki/geth</a><br><a href="https://web3js.readthedocs.io/en/1.0/web3-eth.html">https://web3js.readthedocs.io/en/1.0/web3-eth.html</a><br><a href="https://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html">https://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html</a><br><a href="https://www.ethereum.org/cli">https://www.ethereum.org/cli</a><br><a href="https://github.com/ethereum/go-ethereum/wiki/geth">https://github.com/ethereum/go-ethereum/wiki/geth</a><br><a href="https://code.visualstudio.com/docs">https://code.visualstudio.com/docs</a><br><a href="http://truffleframework.com/">http://truffleframework.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cac42af966fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/interfacing-with-a-blockchain/how-to-set-up-your-ethereum-development-environment-for-macos-cac42af966fd">How to set up your Ethereum development environment for MacOS</a> was originally published in <a href="https://medium.com/interfacing-with-a-blockchain">Interfacing with an Ethereum Blockchain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy and Verify a Contract to the Rinkeby Testnet]]></title>
            <link>https://medium.com/interfacing-with-a-blockchain/deploy-and-verify-ca9dcf9e6cd3?source=rss----d813e788a310---4</link>
            <guid isPermaLink="false">https://medium.com/p/ca9dcf9e6cd3</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ether]]></category>
            <category><![CDATA[ethereum-wallet]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Ebenezer Ackon]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 05:46:18 GMT</pubDate>
            <atom:updated>2019-01-14T02:39:27.380Z</atom:updated>
            <content:encoded><![CDATA[<h3>Deploy and Verify a Contract to the Rinkeby Testnet — The Easy Way</h3><p><strong>This article aims to show you how to:</strong></p><ol><li>Create a wallet and fill it with testnet Ether.</li><li>Deploy a smart contract to the Rinkeby testnet.</li><li>Verify the contract on Etherscan.</li><li>Interact with and send transactions to the blockchain via the published contract.</li></ol><h3><strong>What is Deploying, why Verify?</strong></h3><p><strong>Deploying</strong> is the process in which a smart contract (solidity file) is written to the blockchain. It will stay there forever unless the code has a function that allows it to self destruct. Everyone can see this contract and interact with it once it has been deployed. The deployed contract is also immutable, meaning that it is impossible for it to be changed once it has been added to the blockchain. After deploying a contract, the next step is to verify it.</p><p><strong>Verifying</strong> a contract is the process of checking if the generated bytecode actually matches the source code that was written. This is necessary for the community to trust the contract and to ensure that the code will do exactly what it claims to do. Security and transparency are the most important features when it comes to utilizing the blockchain. Once verified, the contract’s source code can be seen and publicly checked by anyone. A trusted site used to verify contracts is Etherscan.io.</p><h3><strong>What is the Rinkeby Testnet?</strong></h3><p>The <a href="https://bitfalls.com/2018/05/31/what-is-an-ethereum-testnet-and-how-is-it-used/"><strong>Testnet</strong></a> is an alternative from the main blockchain, to be used for testing. Testnet Ether coins are separate and distinct from actual Ether coins, and are never supposed to have any value. This allows application developers or Ethereum testers to experiment, without having to use real tokens or worrying about breaking the main Ethereum blockchain. There are many different types of testnets that differ mostly by <a href="https://hackernoon.com/a-hitchhikers-guide-to-consensus-algorithms-d81aae3eb0e3">Consensus Algorithm</a>. The testnet we will be deploying to is Rinkeby.</p><p><a href="https://www.rinkeby.io/#stats"><strong>Rinkeby</strong></a> is an Ethereum Testnet. Rinkeby uses a PoA <a href="https://blockonomi.com/proof-of-authority/">(proof-of-authority</a>) algorithm to achieve consensus. Rinkeby is run by centralized nodes that could be shutdown at anytime. This is one reason why it’s only used for testing. Balances do not get transferred from one network to another. You cannot send Ether from the mainnet to testnets, the balance does not carry over.</p><h3><strong>Obtaining a Contract</strong></h3><p>I’ll be using my very own <a href="https://github.com/EbenezerGH/Greeter-Contract">Greeter Contract</a>. The Greeter contract allows those interacting with it to change the original string, read the current string that’s set, and kill the contract if necessary. You can access the greeter via cloning or downloading the zip.</p><p><strong>Clone: </strong>git clone <a href="https://github.com/EbenezerGH/Greeter-Contract.git">https://github.com/EbenezerGH/Greeter-Contract.git</a> <em><br></em><strong>Download Zip: </strong><a href="https://github.com/EbenezerGH/Greeter-Contract/archive/master.zip">https://github.com/EbenezerGH/GreeterContract/archive/master.zip</a><br><strong>Source Code: </strong><a href="https://raw.githubusercontent.com/EbenezerGH/Greeter-Contract/master/flattened/Greeter_flat.sol">https://raw.githubusercontent.com/EbenezerGH/Greeter-Contract/master/flattened/Greeter_flat.sol</a></p><h3><strong>Create a Wallet with Metamask on the Rinkeby Testnet</strong></h3><p><a href="https://metamask.io/"><strong>Metamask</strong></a><strong> </strong>is a bridge that lets you run dApps from your computer. It injects a script from a javaScript library called <a href="https://docs.web3j.io/">web3.js</a> which allows you to read and write requests to the blockchain from your browser. Web3 was written by the Ethereum core team so it is consistent with the already existing protocol. It also works as an <a href="https://coinsutra.com/hd-wallets-deterministic-wallet/">HD wallet</a>, a user can create and store wallet information with Metamask if they choose to do so.</p><ol><li>First we will need to download the official Metamask browser extension.<br><a href="https://metamask.io/">https://metamask.io/</a>.</li><li>After downloading the extension, the fox icon should appear in your extensions tab. Click on it and go through the process of creating a password, accepting the terms of use, etc.</li><li>Once that process is complete, change from <strong>Main Ethereum Network</strong> to <strong>Rinkeby Test Network, </strong>it’s time to get some Ether.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*fngyNcJ4UCck00m5ODwBiQ.png" /><figcaption>Metamask Chrome extension</figcaption></figure><h3>Request Ether from the Rinkeby Faucet</h3><p>Since testnet Ether doesn’t really hold any real monetary value, it’s possible to request Ether in increments. You give a public key to a <strong>faucet</strong> and it will distribute Ether to that address as long as you verify a social media profile. Verification of a social media profile is used as a method to prevent spam. My go-to Rinkeby faucet is <a href="https://www.rinkeby.io/#faucet">https://www.rinkeby.io/#faucet</a>.</p><ol><li>On a social media profile of your choice, make a post with your public address. <strong>MAKE SURE THE POST CONTAINS YOUR PUBLIC ADDRESS, NOT YOUR PRIVATE KEY.</strong></li><li>Copy and paste the URL to this post inside of the <em>Give me Ether</em> Field.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0DIwFK4tCzs_MdYolf0CHg.png" /><figcaption>Google Plus post</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2lo-ZscxN3JAteHpfINgrQ.png" /><figcaption><a href="https://plus.google.com/105649615752602866498/posts/9PusqoCKHXN">https://plus.google.com/105649615752602866498/posts/9PusqoCKHXN</a></figcaption></figure><p>3. Confirm that the transaction went through by checking your public address on the Rinkeby Etherscan page <a href="https://rinkeby.etherscan.io/">https://rinkeby.etherscan.io/</a> . It may take some time depending on how congested the network is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x9kzsw7duQnOL1oqJSNCzQ.png" /></figure><h3><strong>What is Etherscan?</strong></h3><blockquote>Etherscan is the leading BlockExplorer for the Ethereum Blockchain. A BlockExplorer is basically a search engine that allows users to easily lookup, confirm and validate transactions that have taken place on the Ethereum Blockchain. We are independently operated and developed by a team of individuals who are truly passionate and excited about the kinds of decentralized information and infrastructure applications that Ethereum makes possible.</blockquote><blockquote>And just like you, we are “users” of the Ethereum Blockchain. Etherscan is not funded, operated or managed by the Ethereum Foundation but instead exists as an independent entity. The Ethereum Blockchain has a public ledger (like a decentralized database) which Etherscan.io indexes and then makes available this information through our site. Our mission is to facilitate Blockchain transparency by indexing and making searchable all transactions on the Ethereum Blockchain in the most transparent and accessible way possible.</blockquote><blockquote>Etherscan is not wallet service provider, we do not store your private keys and we have no control over the transactions that take place over the Ethereum network.</blockquote><blockquote>In addition, we also provide a set of load balanced robust API Services that can be used to either build decentralized applications or to serve as data feeds for Ethereum Blockchain information.</blockquote><p><a href="https://etherscancom.freshdesk.com/support/solutions/articles/35000022140-what-is-etherscan-"><strong>Source</strong></a></p><h3><strong>Now, We can Deploy the Contract!</strong></h3><p>We will use <a href="https://github.com/ethereum/remix"><strong>Remix IDE</strong></a><strong> </strong>to deploy our contract.</p><p><strong>Remix</strong> can be used as a browser-based compiler and IDE. It enables users to build Ethereum contracts with Solidity language and to debug transactions.</p><p>Head to <a href="http://remix.ethereum.org/">http://remix.ethereum.org</a> and copy and paste the source code of the Greeter_flat.sol into the window. You can delete any code that’s already in the IDE window.</p><p><strong>Note: </strong>It is important to copy the source file exactly as is. Any changes to the code (even a whitespace) can cause for an error when verifying the byte code later on. <br><a href="https://raw.githubusercontent.com/EbenezerGH/Greeter-Contract/master/flattened/Greeter_flat.sol">Source Code</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_v9WV_QI0UsfYO_DIg8XAQ.png" /><figcaption>source code pasted into window</figcaption></figure><p>There are many different compile versions, but I recommend picking one closest to the solidity file’s pragma level. My pragma version is pragma solidity ^0.4.23 . So I will pick a version that does not exceed 4.23. version:0.4.23+commit.124ca40d.Emscripten.clang .</p><p>Looks like my code compiled with only 3 warnings now it’s time to run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*Rn1Ji8-KD6fuxXaKpgD4qg.png" /><figcaption>Compile Successful</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*yWpSmBG9dHr7fH2RBkCbfw.png" /><figcaption>Ready to deploy</figcaption></figure><p>Most of the information should be filled out on the run screen. Metamask Automatically Injects a web3 script that contains your wallet information into the browser. The 3000000 gas limit is the max amount that I am willing to pay for the transaction. A standard Ethereum transaction costs 21000. The more computational work that needs to be done, the more you should raise your gas limit.</p><p><strong>Note: </strong>We will opt out of enabling optimizations for this tutorial.</p><p>Click <strong>Deploy, </strong>we will add a string when we’re sending transactions later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*T_UTdGBUyic-cUrGHz042g.png" /><figcaption>Confirmation Dialog</figcaption></figure><p>You should then see a confirmation screen. <strong>Confirm</strong> the transaction then check the logs in the IDE.</p><p>When you send tokens, interact with a contract, send ETH, or do anything else on the blockchain, you must pay for that computation. That payment is calculated in <a href="https://kb.myetherwallet.com/gas/what-is-gas-ethereum.html"><strong>Gas</strong></a> and gas is paid in ETH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9eNjZE2w7opcJpRdN9MtGg.png" /><figcaption>Logs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QiIvPacjeXDm7O992uRBhw.png" /><figcaption><a href="https://rinkeby.etherscan.io/tx/0x7ae390e12364bbd6da1d337b143f212368b66e22f24681e54194b9767abbafaa">https://rinkeby.etherscan.io/tx/0x7ae390e12364bbd6da1d337b143f212368b66e22f24681e54194b9767abbafaa</a></figcaption></figure><p>The contract has been successfully deployed on the testnet. Going to the URL in the log redirects to the transaction hash. You can see your transaction information on Etherscan. Before we can interact with the contract, we need to verify it.</p><h3><strong>Verify The Contract</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WlnDwuRNUU-qTdED3Y0w-Q.png" /><figcaption>Unverified contract</figcaption></figure><p>Search your public address on Etherscan and go to the transaction that deployed the contract. Under the code tab you’ll see <em>Verify and Publish. </em>Click and it will redirect you to the screen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BjgDEY7RGwRoFtbZ-bSGFQ.png" /><figcaption>Verification</figcaption></figure><p>Copy and paste the whole flattened solidity file exactly as it is written. Fill in the name of the parent contract for contract name, and specify the compiler that was used. We did not add any libraries so we can scroll to the bottom and verify.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fQwuK40d40Bym-KcP05xng.png" /><figcaption>Verified contract information</figcaption></figure><p>The <a href="https://docs.web3j.io/abi.html"><strong>ABI</strong></a><strong> </strong>is basically how you can encode Solidity contract calls for the EVM.</p><p>The <strong>Bytecode</strong> is the low level representation of the solidity file that was written.</p><h3><strong>Write to the Contract</strong></h3><p>Go back to the contract and click Address and you should see new tab options. <strong>Transactions, Code, Read Contract, Write Contract, Events.</strong></p><p>Go to Write Contract and click <em>Connect with Metamask</em>. Write a greeting string, confirm the transaction and you’re done!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NatTw4dcVy5Ze7FByF4wvA.png" /></figure><p>Unless you can read hexadecimal I recommend you select <em>decode input data. </em>You should see your message displayed in plain text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XqdXoTuC2WEJ0kcEc5IrOA.png" /><figcaption><a href="https://rinkeby.etherscan.io/address/0xf4f6c2c246c08d4a1d7c8dbd7051a4c0555fe8e2#readContract">https://rinkeby.etherscan.io/address/0xf4f6c2c246c08d4a1d7c8dbd7051a4c0555fe8e2#readContract</a></figcaption></figure><p>View the transaction from the below link.</p><p><a href="https://rinkeby.etherscan.io/address/0x8394cdf176a4a52da5889f7a99c4f7ad2bf59088">Rinkeby Accounts, Address And Contracts</a></p><h3><strong>Conclusion</strong></h3><p>The only difference between publishing from the mainnet and testnet is real Ether. Using Metamask and Etherscan, you can just select a different network other than Rinkeby. I enjoy using Metamask and remix because they are super lightweight tools and I don’t have to download the whole blockchain. They’re both powerful and capable of much more than was demonstrated.</p><p>There are many other ways to deploy a contract to the blockchain. There are also many more intricacies that vary per use case. I tried to be as general as possible and use a very simple contract. I also chose not to change too many optional parameters.</p><p>In my next article I will demonstrate how to use <a href="https://github.com/web3j/web3j"><strong>Web3</strong></a> and <a href="https://infura.io/"><strong>Infura</strong></a> to interface with the Greeter contract we just verified. The code is already complete <a href="https://github.com/EbenezerGH/Greeter-Android-App"><strong>here</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca9dcf9e6cd3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/interfacing-with-a-blockchain/deploy-and-verify-ca9dcf9e6cd3">Deploy and Verify a Contract to the Rinkeby Testnet</a> was originally published in <a href="https://medium.com/interfacing-with-a-blockchain">Interfacing with an Ethereum Blockchain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to set up your Ethereum development environment for PC]]></title>
            <link>https://medium.com/interfacing-with-a-blockchain/how-to-set-up-your-ethereum-development-environment-for-pc-f6caf6eb8017?source=rss----d813e788a310---4</link>
            <guid isPermaLink="false">https://medium.com/p/f6caf6eb8017</guid>
            <category><![CDATA[truffle]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Ebenezer Ackon]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 05:38:54 GMT</pubDate>
            <atom:updated>2019-01-16T01:03:42.528Z</atom:updated>
            <content:encoded><![CDATA[<p>A huge portion of the blockchain community are using MacOS or Linux systems. It’s easy for a Windows user to feel neglected. In this article, I will introduce the proper tooling and show you how to prepare your PC for writing smart contracts and interfacing with the Ethereum blockchain.</p><h3>Necessary Tools</h3><ol><li><a href="https://github.com/PowerShell/PowerShell"><strong>Powershell</strong></a><br>Powershell is a very powerful tool that should be installed by default on your windows computer (at least if you’re using windows 8 and above). We’ll use it mainly as a terminal to accept unix commands and to install packages. As mentioned previously, most of the community uses unix based systems and command prompt won’t cut it. Being able to adapt will save a lot of headache in the long run.</li><li><a href="https://code.visualstudio.com/"><strong>Visual Studio Code</strong></a><br>Visual Studio Code is my code editor of choice when it comes to writing smart contracts. It’s super lightweight, full of extensions created by the community, and has powerful debugging tools. Obviously opinions may differ when it comes to which code editor or IDE to use. The final decision is yours.</li><li><a href="https://github.com/ethereum/go-ethereum/wiki/geth"><strong>Geth</strong></a><strong> (Go Ethreum)</strong><br>Geth is the the command line interface for running a full Ethereum node implemented in Go. It allows you the ability to do practically anything you would need to do on the blockchain (commands listed <a href="https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options">here</a>).</li><li><a href="https://truffleframework.com/ganache"><strong>Ganache</strong></a><strong><br></strong>Ganache is a blockchain emulator that allows you to run tests, execute commands, and inspect state while controlling how the blockchain operates. Ganache was called Test RPC in the past, but the developers learned from Android that tasty dessert names are more appealing. The blockchain you create is personal, has user friendly UI, and runs quickly in memory.</li><li><a href="https://www.w3schools.com/whatis/whatis_npm.asp"><strong>NPM</strong></a><strong><br></strong>NPM is a package manager for Node.js files. We’ll be using this to download dependencies like Truffle.</li><li><a href="https://truffleframework.com/"><strong>Truffle</strong></a><strong><br></strong>Truffle is an awesome tool that makes the developer’s job much easier. It’s provides a testing framework, smart contract compilation, linking, deployment, and much more. It also handles a lot of boilerplate for you when you get into the realm of using <a href="https://truffleframework.com/boxes">boxes</a>.</li></ol><h3><strong>Lets start</strong></h3><p>1. Make sure Powershell is on your computer. If not, installation instructions will vary by system. Install it from the official Microsoft <a href="https://docs.microsoft.com/en-us/skypeforbusiness/set-up-your-computer-for-windows-powershell/download-and-install-windows-powershell-3-0">webpage</a>.</p><p>2. Install Visual Studio Code .zip from <em>code.visualstudio.com/docs/?dv=win</em> . Go through the installation process.<br><br>After Downloading and opening you will need to download the solidity extension to allow you to write in that language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3q_ayfkLAn4-Ac-Rf7HR0Q.png" /><figcaption>Add Solidity Extension to Code Editor</figcaption></figure><p>Type ‘Solidity’ in the search bar and get the extension with the information listed below, It should be the first one suggested.</p><blockquote>Name: solidity<br>Id: juanblanco.solidity<br>Description: Ethereum Solidity Language for Visual Studio Code<br>Version: 0.0.49<br>Publisher: Juan Blanco<br>VS Marketplace Link: <a href="https://marketplace.visualstudio.com/items?itemName=juanblanco.solidity">https://marketplace.visualstudio.com/items?itemName=juanblanco.solidity</a></blockquote><p>3. Download Geth <br><a href="https://geth.ethereum.org/downloads"><em>https://geth.ethereum.org/downloads</em></a>.</p><p>close and reopen powershell and confirm geth is installed by checking the version.</p><pre>geth version</pre><p>4. Install Ganache<br><a href="http://truffleframework.com/ganache/"><em>http://truffleframework.com/ganache/</em></a></p><p>5. Install NodeJS and NPM<br><a href="https://nodejs.org/en/">https://nodejs.org/en/</a></p><pre>node -v</pre><pre>npm -v</pre><p>6. Install Truffle from Powershell.</p><p>npm uninstall -g truffle<br>npm install -g truffle</p><p>It’s best to do a sanity check and uninstall to avoid complications at first. Powershell often has some dependencies already installed but just out of date.</p><p><strong>DONE!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*Td4Vl9MbhilpCTer0LgzvA.png" /><figcaption>Check Version of Tools</figcaption></figure><h3><strong>The Final Test</strong></h3><ol><li>Get Balance From one of our generated accounts</li><li>Convert that Balance From Wei to Ether</li></ol><p>Our Sources:<br><a href="https://web3js.readthedocs.io/en/1.0/web3-utils.html?highlight=fromwei#fromwei"><em>https://web3js.readthedocs.io/en/1.0/web3-utils.html?highlight=fromwei#fromwei</em></a></p><p><a href="https://web3js.readthedocs.io/en/1.0/web3-eth.html"><em>https://web3js.readthedocs.io/en/1.0/web3-eth.html</em></a></p><p>In Powershell type in</p><p>truffle develop</p><p>After a list of the 10 generated accounts are shown, you can select any of the public addresses and use the web3 command to get its balance. All of the generated test addresses will have a balance of 100 Ether, but it will be shown in wei unless we convert it.</p><pre>web3.eth.getBalance(“[Address]”)</pre><p>this command prints out the Address’ balanace in wei. To convert it we will take the result and specify it’s conversion type.</p><pre>web3.utils.fromWei(`[wei value]`, &#39;ether&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s5a9jO73cHfMMhEFd38AVQ.png" /><figcaption>powershell implementation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XmJKUdWSf2bHIydw16WY9w.png" /><figcaption>Ganache connected to same rpc server</figcaption></figure><h3><strong>Conclusion</strong></h3><p>You’re set up and ready to start writing contracts. I recommend filling in any loopholes in your knowledge at</p><ol><li><a href="https://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html">https://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html</a></li><li><a href="https://www.bitdegree.org/learn/solidity-introduction/">https://www.bitdegree.org/learn/solidity-introduction/</a></li><li><a href="https://web3js.readthedocs.io/en/1.0/web3-eth.html">https://web3js.readthedocs.io/en/1.0/web3-eth.html</a></li></ol><p><a href="https://medium.com/interfacing-with-a-blockchain/deploy-and-verify-ca9dcf9e6cd3">Here</a> is another article I wrote that demonstrates publishishing smart contracts to the testnet or mainnet, check it out!</p><h3><strong>Sources</strong></h3><p><a href="https://github.com/ethereum/go-ethereum/wiki/geth">https://github.com/ethereum/go-ethereum/wiki/geth</a><br><a href="https://web3js.readthedocs.io/en/1.0/web3-eth.html">https://web3js.readthedocs.io/en/1.0/web3-eth.html</a><br><a href="https://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html">https://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html</a><br><a href="https://www.ethereum.org/cli">https://www.ethereum.org/cli</a><br><a href="https://github.com/ethereum/go-ethereum/wiki/geth">https://github.com/ethereum/go-ethereum/wiki/geth</a><br><a href="https://code.visualstudio.com/docs">https://code.visualstudio.com/docs</a><br><a href="http://truffleframework.com/">http://truffleframework.com/</a><br><a href="https://www.youtube.com/watch?v=YjmGKnQmKYY">https://www.youtube.com/watch?v=YjmGKnQmKYY</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6caf6eb8017" width="1" height="1" alt=""><hr><p><a href="https://medium.com/interfacing-with-a-blockchain/how-to-set-up-your-ethereum-development-environment-for-pc-f6caf6eb8017">How to set up your Ethereum development environment for PC</a> was originally published in <a href="https://medium.com/interfacing-with-a-blockchain">Interfacing with an Ethereum Blockchain</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>