---
description: >-
  In this section we will use Remix to call the functions we defined in our
  Smart Contract
---

# Interact with already published smart contracts

Now that we have deployed our smart contract, we will want to actually run the functions that we defined in our **Register.sol** smart contract outlined in [create-compile-and-publish-your-first-smart-contract](create-compile-and-publish-your-first-smart-contract "mention")

We will first navigate to the **Deploy & Run Transactions** section of the the Remix IDE where we have our Pinned Smart Contract that we deployed.

We see two buttons that have names that correspond to functions we have defined in our Register smart contract. The first being the **getInfo** function:

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FqJ7ae6JO73mjoGrW6ir7%2Fimage.png?alt=media&#x26;token=9b9fd315-84c9-49bd-81a9-f3e2434e9091" alt=""><figcaption><p>getInfo deployed contract</p></figcaption></figure>

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2Fer0JmJ2DWP2iwfHJ3gkV%2Fimage.png?alt=media&#x26;token=aff39ac0-e0a3-4a9a-ab2f-4d8b675dda5f" alt=""><figcaption><p>getInfo function code in our smart Contract</p></figcaption></figure>

And the **setInfo** button

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FL9K8KnWETstTuPdD3ngp%2Fimage.png?alt=media&#x26;token=0614ec85-2592-44f8-9fbe-fe07962d4bc0" alt=""><figcaption><p>setInfo deployed contract</p></figcaption></figure>

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FlPDn5vU051uaaDPMmIpa%2Fimage.png?alt=media&#x26;token=9015cb6a-189f-4356-9d90-c71c21fbe4ae" alt=""><figcaption><p>setInfo function code in our smart contract</p></figcaption></figure>

We will explain why these buttons have different colours soon.

{% hint style="info" %}
The Contract Application Binary Interface (ABI) is the standard way to interact with contracts in the Ethereum ecosystem, both from outside the blockchain and for contract-to-contract interaction. Data is encoded according to its type, as described in this specification. The encoding is not self describing and thus requires a schema in order to decode.
{% endhint %}

{% embed url="https://docs.soliditylang.org/en/latest/abi-spec.html" %}

When we select the buttons on the left side of the IDE we are executing the functions of our Register contract that was deployed to the blockchain. The IDE knows this since it has both the functional definitions (known as Application Binary Interfaces \[ABI]) that we got from compiling the code (and now exists in the JSON files in our workspace), and the Address that the smart contract was deployed to that we found on etherscan.

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FXqRVVkZ0y11GrEGpbBeF%2Fimage.png?alt=media&#x26;token=3c5612d7-dc77-4083-a26c-e9e22e91e236" alt=""><figcaption><p>Register compiled ABIs and Pinned Contracts</p></figcaption></figure>

### Running getInfo

We can click the button labeled **getInfo** to fetch the default value of our **info** variable that we defined in the contract (note, that since it has no default value the return from the contract should be an empty string "").

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2Fzd5se9IrPxJQxrbLkBZs%2Fimage.png?alt=media&#x26;token=dd9f21df-20f5-4a97-9959-0f6d4cc3030b" alt=""><figcaption><p>example default value</p></figcaption></figure>

If we want to set this value to something specific, we need to use the **setInfo** method. Using the other button and the text box you can set the string to whatever you would like. I will use "Smart Contracts are fun!". Since this function initiates a state change, you will be required to pay the gas fee to the blockchain in the same way we paid to deploy the contract.  Also, because this interaction costs gas and changes the data stored on the blockchain, it is marked as an orange button! Blue buttons do not change the data stored on a chain -- they're "read only" interactions.  When we change data on a blockchain (or a hard disk!) we are "writing" data to the storage service.

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FIt2dM6noRq44quOLRQIl%2Fimage.png?alt=media&#x26;token=acd83a8e-aab4-471c-8b0c-a0dab112e329" alt=""><figcaption><p>Example setInfo Method</p></figcaption></figure>

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FOUn4oLupwSUUHV7Hz6Y1%2Fimage.png?alt=media&#x26;token=79c7009b-7622-4ca2-b660-d46b7acb12ec" alt=""><figcaption><p>Example variable set</p></figcaption></figure>

After confirming the transaction, you will receive another update in the terminal window of Remix indicating the status of the transaction, this time specifically for the Register.setInfo state change.

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FNQASEhc2s04ohfblISlc%2Fimage.png?alt=media&#x26;token=8f8ed8ae-9638-47d7-abde-26b64c1e312c" alt=""><figcaption><p>Example output for setInfo request</p></figcaption></figure>

Now if we return to our getInfo button and click it, Remix will "read" the latest data from the blockchain.  We will see that value held in the variable **info** has changed to be the string that we specified in the **setInfo** method. Congrats! You've made an immutable change to the blockchain ledger!

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2F8RHwJYZUcg5JjRkT7mpZ%2Fimage.png?alt=media&#x26;token=1197c605-1721-4152-80c9-e9cbf92a29f3" alt=""><figcaption><p>Example output for getInfo after setInfo</p></figcaption></figure>
