Skip to Content

πŸ‘¨πŸ»β€πŸŽ“ Register for live classes

Interacting with a smart contract already published on network

Imagine it’s another day and you would like to see your smart contract Name. You closed Remix and opened it again, your smart contract does NOT appear in the section Deployed Contracts in Deploy and run transactions.

It is possible to interact with a smart contract previously published!

To interact with a published smart contract, you must have 2 informations:

  1. Contract address
  2. ABI - Application Binary Interface

Contract address

I hope you have already saved the address of your smart contract Name.

If you haven't saved it, you can get it by following these steps: 1- Go to RSK explorer 2- Search the address of your wallet 3- In the list of transactions, look for a line that has contract created or contract deploy 4- Click on the transaction to see its details 5- In the transaction, copy the value of Contract Address

Search the address of your wallet on RSK explorer

explorer search

Localize the transaction line where you smart contract was created:

explorer search address

For example, this is the address of my wallet:

0xa63375173ffa44725b5cde4dcfde7d6ccf5fffaa

This is the transaction of the creation of my smart contract Name:

0x5d1b6be07f981b6068de686439cb876fd34007de6671aeeabf29fc55399a113f

This is the address of my smart contract Name:

explorer search contract created

0xb3210016baa0Eb6D99646a86aE9D74B3336866af

You can use it for testing :)

ABI - Application Binary Interface

The ABI is the standard way to interact with contracts, both from outside the blockchain and for contract-to-contract interaction.

The ABI contains all public information on the smart contract:

  1. public variables
  2. public functions

The smart contract Name contains the following information at ABI:

  • getName - public function defined in the smart contract
  • owner - public variable, which is the address that published the smart contract, that is, the address of your wallet.

Which appears as the blue buttons on the Remix terminal:

Name buttons

If you know the ABI, you don't need to know the source code of the smart contract. But, if you already have access to the smart contract source code, you can automatically generate the ABI. In another module you will learn how to use ABI directly.

Using Remix, we will use the smart contract source code, which we already know.

Interacting with the smart contract Name on Remix

  1. On the 2nd button on the left - file explorer, open the file Name.sol, created earlier in the lesson [Create your first smart contract: name] (/ courses / dev / 02 / smart-contract-name)

  2. Then go to Deploy and run transactions, In Environment, select the option Injected Web3.

  3. Paste your smart contract address in the field next to the At Address button.

  4. Click the At Address button.

  5. It will appear in the section Deployed Contracts.

At address

You will be able to interact with it in the same way as you have done previously.

Name buttons

Make sure you have the RSK testnet network selected in your wallet.

Final considerations

Congratulations!

Now you know how to interact with any smart contract in Remix.

In the next lesson, your smart contract will be validated by another smart contract, called MasterName.

With MasterName you will learn how your smart contract can interact with others :)