Interact with & Test a Contract

Once you have deployed your contract through Loki.code, you may access its Playground. The Playground is a user interface that allows you to interact with your contract by making calls and transactions, and observing its state update in real time.

Prerequisites

Video Demonstration

Steps

From the Dashboard's left sidebar, click on "Projects," and then select the project that contains the contract you wish to interact with.

On that project's page, click on "Deploy" in the left sidebar. From here, you will see several different tabs to choose from. Click on the "Deployments" tab, which will display the history of all the contracts you have deployed through Loki.code.

Locate the deployed contract with which you wish to interact, and click on its respective "Playground" button in the bottom-right corner. You will be directed to your project's Playground, which should resemble the image below.

The first step is to connect your Ethereum wallet by clicking the "Connect Wallet" button at the top right, allowing you to interact with your contract. Ensure that your wallet is connected to the same network on which the contract was deployed.

On the left side, you will see the public and external functions from your contract, along with some basic information about each one. To call a function, click the "Try it" button, add any necessary arguments, and then click "Transact."

After clicking "Transact," your wallet will open a window for you to confirm the transaction.

As we invoked a write function in this example, it was necessary to pay ether to execute the transaction. However, if you call a read function, you can retrieve data from the blockchain network without incurring any costs.

In addition to the contract interaction section, the Playground's right-hand side offers JavaScript and TypeScript code snippets implemented via Web3, Ethers, and Viem. These snippets provide developers with quick access to the necessary code for integrating the function into their own applications, thereby expediting the development process.

Ultimately, the Playground offers users an effortless means to interact with deployed contracts, whether by calling functions, conducting tests, or integrating the contract into another application.

We have many more features planned for the Playground—stay tuned!

Last updated