{"id":20072,"date":"2022-10-02T18:24:02","date_gmt":"2022-10-02T18:24:02","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=9194"},"modified":"2022-10-02T18:24:02","modified_gmt":"2022-10-02T18:24:02","slug":"interacting-with-deployed-contract","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/10\/02\/interacting-with-deployed-contract\/","title":{"rendered":"Interacting with Deployed Contract"},"content":{"rendered":"\n<p>Now, you are ready to interact with the contract that you have deployed. Go back to MyEtherWallet desktop and click on the \u201cInteract with Contract\u201d tab as shown in the screenshot below \u2212<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tutorialspoint.com\/ethereum\/images\/interact_with_contract.jpg\" alt=\"Interact With Contract\"\/><\/figure>\n\n\n\n<p>Paste the contract address that you previously copied in the&nbsp;<strong>\u201cContract Address\u201d<\/strong>&nbsp;field. You also need to paste the&nbsp;<strong>\u201cABI \/ JSON Interface\u201d<\/strong>&nbsp;of the contract on the above screen.<\/p>\n\n\n\n<p>To get the&nbsp;<strong>ABI<\/strong>, go to the&nbsp;<strong>Remix<\/strong>&nbsp;window and click on the&nbsp;<strong>ABI<\/strong>&nbsp;button as shown in the screenshot below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tutorialspoint.com\/ethereum\/images\/abi_button.jpg\" alt=\"ABI button\"\/><\/figure>\n\n\n\n<p>The ABI \/ JSON interface will be copied to the clipboard. Paste this in your favorite editor to examine the generated interface, which is shown below \u2212<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ABI \/ JSON Interface\n&#91;\n   {\n      \"constant\": false,\n      \"inputs\": &#91;\n         {\n            \"name\": \"newDeposit\",\n            \"type\": \"uint256\"\n         }\n      ],\n      \"name\": \"send\",\n      \"outputs\": &#91;],\n      \"payable\": false,\n      \"stateMutability\": \"nonpayable\",\n      \"type\": \"function\"\n   },\n   {\n      \"inputs\": &#91;\n         {\n            \"name\": \"initialAmount\",\n            \"type\": \"uint256\"\n         },\n         {\n            \"name\": \"initialValue\",\n            \"type\": \"uint256\"\n         }\n      ],\n      \"payable\": false,\n      \"stateMutability\": \"nonpayable\",\n      \"type\": \"constructor\"\n   },\n   {\n      \"constant\": true,\n      \"inputs\": &#91;],\n      \"name\": \"getAmount\",\n      \"outputs\": &#91;\n         {\n            \"name\": \"\",\n            \"type\": \"uint256\"\n         }\n      ],\n      \"payable\": false,\n      \"stateMutability\": \"view\",\n      \"type\": \"function\"\n   },\n   {\n      \"constant\": true,\n      \"inputs\": &#91;],\n      \"name\": \"getBalance\",\n      \"outputs\": &#91;\n         {\n            \"name\": \"\",\n            \"type\": \"uint256\"\n         }\n      ],\n      \"payable\": false,\n      \"stateMutability\": \"view\",\n      \"type\": \"function\"\n   }\n]<\/code><\/pre>\n\n\n\n<p>After you paste this JSON in the&nbsp;<strong>MyEtherWallet<\/strong>&nbsp;interface, you will notice that the ACCESS button below the JSON interface is now activated, as shown below \u2212<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tutorialspoint.com\/ethereum\/images\/my_ether_wallet.jpg\" alt=\"My Ether Wallet\"\/><\/figure>\n\n\n\n<p>Click&nbsp;<strong>Access<\/strong>&nbsp;button to access the contract.<\/p>\n\n\n\n<p>Upon clicking the&nbsp;<strong>Access<\/strong>&nbsp;button, the contract address and function selection dropdown will appear on the screen like in the Remix editor. This is shown in the screenshot below \u2212<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tutorialspoint.com\/ethereum\/images\/access_button.jpg\" alt=\"Access button\"\/><\/figure>\n\n\n\n<p>You may check the various functions of the contract as in the case of Remix deployment. Note that the contact is now deployed on an external Ganache Blockchain. Check the&nbsp;<strong>getAmount<\/strong>&nbsp;function; you will get the Amount value of zero and the&nbsp;<strong>getBalance<\/strong>&nbsp;will show a balance of 1000.<\/p>\n\n\n\n<p>Now try sending some money. It will present you a&nbsp;<strong>textedit<\/strong>&nbsp;control for entering the amount. When you write the contract, some \u201cgas\u201d would be used and you will be asked to confirm the transaction before writing it to the Blockchain. The transaction would be executed in a short while depending on the mining timing set by you on the Ganache server. After this, you can reexamine the&nbsp;<strong>value<\/strong>&nbsp;and the&nbsp;<strong>amount<\/strong>&nbsp;fields of the contract to verify that these are indeed modified.<\/p>\n\n\n\n<p>You may now examine the Ganache desktop to view the transactions that you have performed so far. A sample output is shown below \u2212<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.tutorialspoint.com\/ethereum\/images\/sample_output.jpg\" alt=\"sample output\"\/><\/figure>\n\n\n\n<p>So far, you were both the contract creator and the contract executor. This does not make much sense, as you expect others to use your contract. For this, we will create another client for our Ganache Blockchain and send some money from the newly created account # 2 to the contract creator at account # 1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now, you are ready to interact with the contract that you have deployed. Go back to MyEtherWallet desktop and click on the \u201cInteract with Contract\u201d tab as shown in the screenshot below \u2212 Paste the contract address that you previously copied in the&nbsp;\u201cContract Address\u201d&nbsp;field. You also need to paste the&nbsp;\u201cABI \/ JSON Interface\u201d&nbsp;of the contract [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/20072"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=20072"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/20072\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=20072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=20072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=20072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}