How to interact

You can use any libraries to interact with smart contracts deployed from Bunzz.

If you want to interact with a deployed contract directly, you can use the Interaction UI.

In this tutorial, let's see a simple example of interacting with your smart contract.

1) Install the package to your project

npm install --save ethers

2) To interact with a deployed smart contract, please copy the contract's address and the ABI from the Bunzz dashboard.

3) First, you need to create a contract object.

4) Once you have created an object of the contract, you can call its functions using the contract.functioName() syntax. For example, if the contract has a function named getValue that returns the value stored in the contract, you can call it like this:

You can also call a function to update state of the contract that requires signing. For example, if the contract has a function named setValue, you can call it like this:

Here is the complete code example:

To learn details and advanced usage of ethers.js, read the official document arrow-up-rightor google "ethers.js" since there are a lot of great articlesπŸ‘

Last updated