{"id":805,"date":"2019-07-02T09:45:04","date_gmt":"2019-07-02T09:45:04","guid":{"rendered":"\/blog\/?p=805"},"modified":"2024-04-25T14:55:04","modified_gmt":"2024-04-25T14:55:04","slug":"coding-smart-contracts-tutorial-part-i","status":"publish","type":"post","link":"\/blog\/2019\/07\/coding-smart-contracts-tutorial-part-i\/","title":{"rendered":"Coding Smart Contracts \u2013 Tutorial Part I"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">How to Write, Deploy and Test a Smart Contract<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2019\/07\/Natallia-Martchouk-trimplement-portrait.png\" alt=\"Natallia Martchouk, co-founder of trimplement, the fintech enabler\" class=\"wp-image-829\" width=\"314\" height=\"315\" srcset=\"\/blog\/wp-content\/uploads\/2019\/07\/Natallia-Martchouk-trimplement-portrait.png 556w, \/blog\/wp-content\/uploads\/2019\/07\/Natallia-Martchouk-trimplement-portrait-150x150.png 150w, \/blog\/wp-content\/uploads\/2019\/07\/Natallia-Martchouk-trimplement-portrait-300x300.png 300w, \/blog\/wp-content\/uploads\/2019\/07\/Natallia-Martchouk-trimplement-portrait-60x60.png 60w, \/blog\/wp-content\/uploads\/2019\/07\/Natallia-Martchouk-trimplement-portrait-24x24.png 24w, \/blog\/wp-content\/uploads\/2019\/07\/Natallia-Martchouk-trimplement-portrait-48x48.png 48w, \/blog\/wp-content\/uploads\/2019\/07\/Natallia-Martchouk-trimplement-portrait-96x96.png 96w\" sizes=\"auto, (max-width: 314px) 100vw, 314px\" \/><figcaption>Natallia Martchouk, co-founder of trimplement, explains how to develop Ethereum smart contracts.<\/figcaption><\/figure><\/div>\n\n\n\n<p>In this article, I will give you a smart contract tutorial. It will tell you how to quickly write, test and deploy Ethereum smart contracts. My motivation is to help people to make the first steps. There are several good tutorials which helped me to get started. But I missed kind of a \u201ccookbook recipe\u201d for the entire journey, starting with the installation of tools and frameworks and ending with deployment to Ethereum and usage out of an application. <\/p>\n\n\n\n<p>And so, I decided to write down all the steps involved and hope that you will find it helpful!<br><\/p>\n\n\n\n<p>I\u2019m working on a Mac, but I\u2019ll provide links to the documentation of all tools and frameworks so that you\u2019ll be able to find fitting instructions for your personal environment.<br><\/p>\n\n\n\n<p><strong><em>Today we will:&nbsp;<\/em><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Setup an environment that&nbsp; allows you to write production-ready smart contracts<\/li><li>Write a simple smart contract<\/li><li>Test security and style guide issues with <em>solhint<\/em><\/li><li>Write unit tests with a <em>Truffle<\/em> framework<\/li><li>Deploy the contract on the <em>Rinkeby<\/em> testnet using <em>MetaMask<\/em> and <em>Remix<\/em><\/li><li>Execute calls on the deployed smart contract<\/li><\/ul>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\">1. Prepare<\/h3>\n\n\n\n<p>Before you start you will need the following tools, frameworks, and resources.&nbsp; Some of them need to be installed, some of them are available online. Once you have the full setup, you are good to go. This setup is also the starting point for my second tutorial, where you will learn to use the smart contract from a java application.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.npmjs.com\/get-npm\">npm \/ Node.js<\/a> for software package management<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.trufflesuite.com\/\">Truffle suite<\/a> for writing tests for your smart contract<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted wp-code\">npm install -g truffle<br><\/pre>\n\n\n\n<p><strong><em>Verify installation:<\/em><\/strong><br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted wp-code\">truffle version<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/solidity.readthedocs.io\/en\/v0.5.9\/installing-solidity.html\">Solidity compiler<\/a><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted wp-code\">brew update<br>brew upgrade<br>brew tap Ethereum\/Ethereum<br>brew install solidity<br><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/web3j.io\/\">Web3j<\/a> for generation of <em>Solidity<\/em> smart contract function wrappers and interaction with Ethereum clients like parity or geth (we will use parity) from our java application<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">brew tap web3j\/web3j<br>brew install web3j<br><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.parity.io\/ethereum\/\">Parity<\/a>, an <em>Ethereum<\/em> client that maintains a local copy of the <em>Ethereum<\/em> testnet, alternatively you can use <em>geth<\/em> or even <em>infura<\/em> &#8211; a centralized <em>Ethereum<\/em> client<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/metamask.io\/\">MetaMask Browser Extension<\/a> for easy management of your Ethereum accounts and deployment of smart contracts on a non-local environment. When developing locally you can use <em>Remix<\/em>&nbsp;+ your local parity instance (as Web3J provider), but for non-local deployment, I\u2019d recommend to use <em>Remix<\/em> + <em>MetaMask<\/em> (select Environment: Injected Web3 in <em>Remix<\/em>) so that you don\u2019t need to make parity available to the outside world while allowing access for <em>Remix<\/em>. In this case, we simply separate contract deployment (<em>Remix, MetaMask)<\/em> and contract usage (<em>java, web3j, parity<\/em>).<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/remix.ethereum.org\/#\">Remix<\/a> for developing, deploying and testing your smart contract.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/protofire.github.io\/solhint\/\">Solhint<\/a> is helpful to quickly verify you smart contract code and check security and style guide issues.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">npm install -g solhint<br><\/pre>\n\n\n\n<p><strong><em>Verify installation:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">solhint -V<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><em>Rinkeby<\/em> Ethereum testnet <a href=\"https:\/\/www.rinkeby.io\/#explorer\">explorer<\/a> and <a href=\"https:\/\/www.rinkeby.io\/#faucet\">faucet<\/a> to get some test ETH<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. Write the Smart Contract Code<\/h3>\n\n\n\n<p>Let\u2019s start with writing a simple smart contract code. For testing purposes we will just deploy a very simple smart contract <em>Ownable<\/em> which has knowledge of its owner address and defines a couple of functions that we can use for testing:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pragma solidity ^0.5.0;<br><br>\/**<br>* @title Ownable<br>* @dev A basic contract for all contracts that need to be administered by the contract owner.<br>* It provides a function modifier 'onlyOwner' that can be used in<br>* the derived contracts for functions executable only by the <br>* contract  owner.<br>*\/<br>contract Ownable {<br><br>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Keeps the owner of the contract<br>&nbsp;&nbsp;&nbsp;&nbsp;address private contractOwner;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;\/\/ C'tor<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor() public {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contractOwner = msg.sender;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;modifier onlyOwner() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require(msg.sender == contractOwner);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;\/**<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* @dev determine if this address is the owner of this contract<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* @return bool<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<br>&nbsp;&nbsp;&nbsp;&nbsp;function isContractOwner(address _address) view public returns (bool) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return _address == contractOwner;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;\/**<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* @dev returns the address of the owner of this contract<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* @return address<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/<br>&nbsp;&nbsp;&nbsp;&nbsp;function getContractOwner() view public returns (address){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return contractOwner;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br><\/pre>\n\n\n\n<p>You can copy and paste this code into a file and name it <em>Ownable.sol.<\/em> Please create a directory <em>myproject\/ (<\/em>which we will use as the main directory) and a subdirectory <em>contracts\/ <\/em>to store the file (<em>myproject\/contracts\/<\/em>). Now you can quickly check with <em>solhint<\/em> whether the contract has some issues. <em>Solhint<\/em> expects to find a config .json file in the directory.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cd myproject\/contracts\/<br>$ vi .solhint.json<br><\/pre>\n\n\n\n<p><strong><em>Insert:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{<br>\"extends\": \"solhint:default\"<br>}<\/pre>\n\n\n\n<p>And save the .solhint.json file.<\/p>\n\n\n\n<p>Check the contract:<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ solhint Ownable.sol<br><\/pre>\n\n\n\n<p>Ideally the output of solhint should be empty. Here is an example of how the solhint would report a formatting issue:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><br>$ solhint Ownable.sol&nbsp;<br><br>Ownable.sol<br>37:7&nbsp; error  Expected indentation of 8 spaces but found 6&nbsp; indent<strong><br><br>\u2716 1 problem (1 error, 0 warnings)<\/strong><br><\/pre>\n\n\n\n<p>If the output is empty, there is nothing more to do in this step. If not,&nbsp; you will need to fix the issues pointed out by solhint and then continue.<br><\/p>\n\n\n\n<p>Let\u2019s develop some tests with <em>Truffle<\/em>.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Write the Truffle Tests<\/h3>\n\n\n\n<p>With the <em>Truffle<\/em> framework you can easily develop and run tests for your smart contract locally. Actually, <em>Truffle<\/em> allows you to compile and run tests on different blockchains (testnets or the livenet) using configuration in truffle-config.js. See <a href=\"http:\/\/truffleframework.com\/docs\/advanced\/configuration\">http:\/\/truffleframework.com\/docs\/advanced\/configuration<\/a> for more detailed documentation.&nbsp;<br>I\u2019m going to show you how to use the truffle\u2019s built-in development blockchain. For this, you won\u00b4t need to configure anything, the <em>truffle-config.js<\/em> shall exist, but can remain empty:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">module.exports = {<br><br>&nbsp;&nbsp;\/\/ See &lt;http:\/\/truffleframework.com\/docs\/advanced\/configuration&gt; for more information<br>&nbsp;&nbsp;\/\/ We can use truffle to compile and deploy contracts to different networks and chains<br>&nbsp;&nbsp;\/\/ To be configured<br><br>};<br><\/pre>\n\n\n\n<p>Create a<em> truffle-config.js<\/em> and store it in your main directory <em>myproject<\/em>\/.<br><\/p>\n\n\n\n<p>Now let\u2019s write a simple test for our contract Ownable.sol.<br><\/p>\n\n\n\n<p>Create a subdirectory test in <em>myproject<\/em>\/, create a file called <em>OwnableTest.js <\/em>there.<br><\/p>\n\n\n\n<p><strong><em>Add some tests:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ The contract to test<br>const Ownable = artifacts.require(\"Ownable\");<br><br>\/\/ Start with a clean test state<br>contract('Ownable', accounts =&gt; {<br><br>\t\/\/ Keep Ownable instance<br>\tlet OwnableContract;<br>\t\/\/ Keep the account of the contract owner<br>\tlet Owner;<br>\t\/\/ Keep the address of the first account that was created by truffle for you<br>\tconst Account1 = accounts[1];<br><br>\/\/******************************************************************<br>\/\/ Test cases for the isContractOwner method<br>\/\/******************************************************************<br><br>\t\/\/ Test for the isContractOwner method - true<br>\tit(\"IsContractOwner should return true\", () =&gt; {<br>\t\treturn Ownable.deployed()<br>\t\t.then(function(instance) {<br>\t\t\tOwnableContract = instance;<br>\t\t\t\/\/ Get contract owner<br>\t\t\treturn OwnableContract.getContractOwner.call();<br>\t\t}).then(function(resultOwner) {<br>\t\t\tOwner = resultOwner;<br>\t\t\t\/\/ Call isContractOwner for the returned owner address<br>\t&nbsp; \treturn OwnableContract.isContractOwner.call(Owner);<br>\t\t}).then(function(resultIsOwner) {<br>\t\t\t\/\/ Check that the result is true<br>\t&nbsp; \tassert.equal(resultIsOwner.valueOf(), true, \"Expected the result to be true\");<br>\t&nbsp; \treturn true;<br>\t\t}).catch(function(e) {<br>\t\t\t\/\/ We don't expect any error here<br>\t\t\tconsole.log(e);<br>\t\t});<br>\t});<br><br>\t\/\/ Test for the isContractOwner method - false<br>\tit(\"IsContractOwner should return false\", () =&gt; {<br>\t\treturn Ownable.deployed()<br>\t\t.then(function(instance) {<br>\t\t\tOwnableContract = instance;<br>\t\t\t\/\/ Call isContractOwner for the non-owner address<br>\t&nbsp; \treturn (OwnableContract.isContractOwner.call(Account1));<br>\t&nbsp; }).then(function(resultIsOwner) {<br>\t\t\t\/\/ Check that the result is true<br>\t&nbsp; \tassert.equal(resultIsOwner.valueOf(), false, \"Expected the result to be true\");<br>\t&nbsp; \treturn true;<br>\t\t}).catch(function(e) {<br>\t\t\t\/\/ We don't expect any error here<br>\t\t\tconsole.log(e);<br>\t\t});<br>\t});<br><br>});<br><\/pre>\n\n\n\n<p>Now, we need to deploy our contract to the chain where we are going to perform the testing. For this, <em>Truffle<\/em> needs to know what contracts have to be deployed. Create a subdirectory <em>migrations\/<\/em> in <em>myproject<\/em>\/and place 2 files in there:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1_initial_migration.js<br>2_deploy_ownable.js<br><\/pre>\n\n\n\n<p>Content of the <em>1_initial_migration.js<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var Migrations = artifacts.require(\".\/Migrations.sol\");<br>module.exports = function(deployer) {<br>&nbsp;&nbsp;deployer.deploy(Migrations);<br>};<br><\/pre>\n\n\n\n<p>Content of the<em> 2_deploy_ownable.js<\/em><br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\/\/ <\/strong>Define contracts to be deployed<br>var Ownable = artifacts.require(\"Ownable\");<br><br>\/\/ Deploy contracts<br>module.exports = function(deployer) {<br>&nbsp;&nbsp;deployer.deploy(Ownable);<br>};<br><\/pre>\n\n\n\n<p>These files will be picked up by truffle when you run the migrate command and executed in the order how they are prefixed: 1_, 2_&#8230;<br><\/p>\n\n\n\n<p>Now we need to add a <em>Migrations<\/em> smart contract for truffle, that is referenced in the <em>1_initial_migration.js<\/em>. The <em>Migrations<\/em> contract keeps track of what migrations (as listed in the migrations\/ directory) were done on the current network.<br><\/p>\n\n\n\n<p><strong><em>Go to contracts\/, create and store a Migrations.sol file there:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><br>pragma solidity ^0.5.0;<br><br>contract Migrations {<br><br>&nbsp;&nbsp;address public owner;<br>&nbsp;&nbsp;uint public last_completed_migration;<br><br>&nbsp;&nbsp;modifier restricted() {<br>&nbsp;&nbsp;&nbsp;&nbsp;if (msg.sender == owner) _;<br>&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;constructor() public {<br>&nbsp;&nbsp;&nbsp;&nbsp;owner = msg.sender;<br>&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;function setCompleted(uint completed) public restricted {<br>&nbsp;&nbsp;&nbsp;&nbsp;last_completed_migration = completed;<br>&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;function upgrade(address new_address) public restricted {<br>&nbsp;&nbsp;&nbsp;&nbsp;Migrations upgraded = Migrations(new_address);<br>&nbsp;&nbsp;&nbsp;&nbsp;upgraded.setCompleted(last_completed_migration);<br>&nbsp;&nbsp;}<br>}<br><\/pre>\n\n\n\n<p>At the end you should have the following structure in your main directory myproject\/:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">myproject<br>\t\u251c\u2500\u2500 contracts<br>\t\u2502 &nbsp; \u251c\u2500\u2500 Migrations.sol<br>\t\u2502 &nbsp; \u2514\u2500\u2500 Ownable.sol<br>\t\u251c\u2500\u2500 migrations<br>\t\u2502 &nbsp; \u251c\u2500\u2500 1_initial_migration.js<br>\t\u2502 &nbsp; \u2514\u2500\u2500 2_deploy_ownable.js<br>\t\u251c\u2500\u2500 test<br>\t\u2502 &nbsp; \u2514\u2500\u2500 OwnableTest.js<br>\t\u2514\u2500\u2500 truffle-config.js<br><\/pre>\n\n\n\n<p>To run the tests with the built-in blockchain, do the following in your main directory <em>myproject<\/em>\/:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Start truffle built in development blockchain:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">$ truffle develop<\/pre>\n\n\n\n<p>This will start a test environment and create a couple of accounts for you which you can easily reference in your tests (see the test example above).<br><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Compile your contracts<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">truffle(develop)&gt; compile<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Run migrations if your contracts have changed: <em>migrate<\/em><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">truffle(develop)&gt; migrate<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Run the tests:<strong> <\/strong><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">truffle(develop)&gt; test<\/pre>\n\n\n\n<p><strong><em>You should see the following output:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">truffle(develop)&gt; test<br>Using network 'develop'.<br><br>Compiling your contracts...<br>===========================<br>&gt; Everything is up to date, there is nothing to compile.<br><br>&nbsp;&nbsp;Contract: Ownable<br>&nbsp;&nbsp;&nbsp;&nbsp;\u2713 IsContractOwner should return true (54ms)<br>&nbsp;&nbsp;&nbsp;&nbsp;\u2713 IsContractOwner should return false (50ms)<br><br>&nbsp;&nbsp;2 passing (137ms)<br><br><\/pre>\n\n\n\n<p>Hooray!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Deploy to Testnet (<em>Rinkeby<\/em>)<\/h3>\n\n\n\n<p>Now you have written and tested your smart contract locally and you are ready to deploy it on the testnet. For this, I will be using <a href=\"https:\/\/www.rinkeby.io\/#explorer\"><em>Rinkeby<\/em><\/a>, but you are free to choose any other testnet.<br><\/p>\n\n\n\n<p>First of all you will need to create an Ethereum account on <em>rinkeby<\/em> and get some test coins to be able to deploy your smart contract to the testnet.<br><\/p>\n\n\n\n<p>We are going to use <a href=\"https:\/\/metamask.io\/\"><em>MetaMask<\/em><\/a><em> <\/em>to create and manage your accounts, and <a href=\"https:\/\/remix.ethereum.org\/\"><em>Remix<\/em><\/a><em> <\/em>to deploy and test the contract.<br><\/p>\n\n\n\n<p>Use <em>MetaMask<\/em> to create an account. You will be provided with an Ethereum address and you will also be allowed to switch between different networks (test networks or mainnet). To get some test ETH go to the <a href=\"https:\/\/www.rinkeby.io\/#faucet\">rinkeby faucet<\/a> and follow the instructions.<br><\/p>\n\n\n\n<p>The following instructions only apply to the old <em>Remix<\/em> interface.<\/p>\n\n\n\n<p>Compile your contract in <em>Remix<\/em>. Add your file with the <em>Solidity<\/em> code (<em>Ownable.sol<\/em>). Go to the Compile tab of <em>Remix<\/em>, select the appropriate compiler version (in your case it will be 0.5.0). Push Start to compile button.<br><\/p>\n\n\n\n<p>Now you are ready to deploy the contract. Select <em>Rinkeby<\/em> as the network in MetaMask, go to <a href=\"https:\/\/remix.ethereum.org\/#\"><em>Remix<\/em><\/a> Run tab, and choose Injected Web3J as environment option. <em>Remix<\/em> will pick up your <em>MetaMask<\/em> account automatically and show your balance in ETH. Now you can choose your compiled contract and deploy it to the <em>Rinkeby<\/em> testnet. You will need to confirm the deployment transaction in <em>MetaMask<\/em>.<br><\/p>\n\n\n\n<p><strong><em>You will see a similar output in the remix console:<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">creation of Ownable pending...<br><a href=\"https:\/\/rinkeby.etherscan.io\/tx\/0x936c531caaa06a97c4416f4daa91d44287d1c30f6316c7807eff33d28a9a3832\">https:\/\/rinkeby.etherscan.io\/tx\/0x936c531caaa06a97c4416f4daa91d44287d1c30f6316c7807eff33d28a9a3832<\/a><br><\/pre>\n\n\n\n<p>Once the transaction was successfully executed and recorded on the blockchain, you will get something like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[block:4622611 txIndex:3] from:0x4cc...ed751 to:Ownable.(constructor) value:0 wei data:0x608...e0029 logs:0 hash:0x936...a3832<\/pre>\n\n\n\n<p>A click on<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">block:4622611 txIndex:3<\/pre>\n\n\n\n<p>will provide detailed information about the transaction.<\/p>\n\n\n\n<p>Your contract can now be seen under Deployed contracts and can be tested by calling getContractOwner and isContractOwner.<br><\/p>\n\n\n\n<p>Voil\u00e0!<br><\/p>\n\n\n\n<p><em><a href=\"https:\/\/trimplement.com\/blog\/2019\/08\/coding-smart-contracts-tutorial-part-ii\/\">In Part II of this smart contract tutorial<\/a>, I will show how to use a deployed contract from a java application.<\/em><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Write, Deploy and Test a Smart Contract In this article, I will give you a smart contract tutorial. It will tell you how to quickly write, test and deploy Ethereum smart contracts. My motivation is to help people to make the first steps. There are several good tutorials which helped me to get [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":815,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[162],"tags":[171,165,172,164,25,163],"class_list":["post-805","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-development-tutorials","tag-coding","tag-ethereum","tag-programming","tag-smart-contracts","tag-software-development","tag-tutorial"],"_links":{"self":[{"href":"\/blog\/wp-json\/wp\/v2\/posts\/805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"\/blog\/wp-json\/wp\/v2\/comments?post=805"}],"version-history":[{"count":22,"href":"\/blog\/wp-json\/wp\/v2\/posts\/805\/revisions"}],"predecessor-version":[{"id":1467,"href":"\/blog\/wp-json\/wp\/v2\/posts\/805\/revisions\/1467"}],"wp:featuredmedia":[{"embeddable":true,"href":"\/blog\/wp-json\/wp\/v2\/media\/815"}],"wp:attachment":[{"href":"\/blog\/wp-json\/wp\/v2\/media?parent=805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/wp-json\/wp\/v2\/categories?post=805"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/wp-json\/wp\/v2\/tags?post=805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}