Interaction UI

After you've managed to deploy your smart contracts module, along the line you will need to interact with it, maybe to customize its configuration, etc. If you're a developer, you can interact with the deployed contract with third-party tools like ethers.js, wagmi, and so on. But what happens with the non-technical users, that want to keep things as simple as possible and to be as headache-free as possible? Well, bunzz is the perfect tool for you, because it is coming with a feature specially designed to allow any user to interact with a smart contract regardless of its experience/technical level.

Open the module's accordion on the Dashboard page and you will see the module's functions.

The function's names are presented on buttons, by clicking on a button, you are calling the underlying function from the smart contract. There are 2 types of functions, functions that read data from the contract and those ones that do not cost any gas to call, and functions that update the storage of the blockchain, those ones cost gas to call because their result needs to be computed and the machines that do the computation needs to be paid.

Let's pay close attention to the following example to better understand how this thing works.

By clicking on the accordion button from the right side of the function "mint" it will provide me with a form for easier interaction with my smart contract.

The button for the function mint has the color orange, which means is a function that updates the storage of the blockchain, that makes sense, because that function will mint our tokens, so it will write in the blockchain storage, that address X has Y tokens. You can see what types of arguments the function expects by looking at the writing in grey color. In the case of mint are address type and uint256 type (uint256 it's a number).

Next, by clicking on the mint button, we get a pop-up from metamask to sign our transaction, if we click on "Confirm" (the blue button from right) we will sign the transaction and forward it to one of the blockchain nodes starting the minting process.

The minting can take a while, depending on what network you are.

After your transaction gets minted, you will be prompted with a button near the function name, in my case, the transaction was minted on the Ropstein Network because there is where the contract was deployed. So in circumstance, I will be redirected to the Ropstein explorer the see my transaction.

By clicking on that button I can visualize all my transaction details and I can see it was successfully minted.

Next, we will check our token balance, to see if our tokens increased after the minting process.

The balanceOf function button has the color blue, which means it is a function that just reads data from the blockchain state and there it will be no gas cost associated with it.

By inputting the argument, our address, and clicking on the button, we will call the function and be able to visualize our balance, the value should be 100 because we just minted 100 tokens.

After a few milliseconds, the response comes from blockchain and it can be visualized at the bottom of the form, in our case, it is 100, exactly the value we minted.

Payable Functions

The functions that update the blockchain storage can be payable or non-payable functions. Even if the names seem a little bit complicated, bear with me, it's very simple.

Basically payable functions are functions that update the state of the blockchain and also need to receive an ether amount ( or any other native currency, like MATIC for polygon network ). Non-payable functions are functions that update the state of the blockchain but do not accept any ether amount ( or any other native currency, like MATIC for polygon network ), if you attempt to send any value to it, it will revert the execution.

So what do they have in common? Both functions update the blockchain states

What is the difference between them? Payable function accept a value, non-payable function reverts the execution if a value is sent to it, so it does not accept any value.

In our Smart Contracts Interaction Dashboard, the only difference you will see is that you will have a small form to input a value of the numerical type.

The first input text field represents the value and the second one represents the unit measure, in this case wei is selected as a unit measure, which is the smallest unit measure, you can also select between gwei and ether as unit measures.

For any questions or feedback you may have, please feel free to contact us on Bunzz Discord Serverarrow-up-right.

Last updated