Table of contents
Let’s look at how to interact with your smart contract on Binance smart chain. Hopefully, you have had a chance to create your smart contract here. This is a continuation of that article, so please check it out before proceeding.
How To Interact With Your Smart Contract On Binance Smart Chain
Step I
Scroll down on the newly created contract and click on the token dropdown, You will see something like this.
Step II
Getting the address
Copy the address listed on your Account by clicking the copy button
- Paste the address on the balanceOf field
- Click on `balanceOf` and obseerve the results on the debug console
- Our balance is now 50000 PETER as we anticipate!!
Well done for making it this far! Let’s now look at how to transfer your coins to some other account.
Step III – Sending to another address
Choose a new address on your Metamask and copy the address.
We will transfer our PETER tokens to that address
Step IV
Paste the newly copied address in the transfer method, also put a comma and the amount you wish to transfer. In my case I input
<address******>, 1000
This means I wish to transfer 1000PETER from my main address to the new address. Click transfer and confirm the Metamask popup that comes up.
Step V
- Note the successful transfer of PETER coin after confirming the transaction.
Confirming the transfer!
In order to confirm the transfer, we need to check that our tokens have actually been transferred to the new wallet address.
First, we need to add our token contract to our Metamask. To do this, copy your token address as shown below.
Step VI
- Copy the address of where our contract is deployed by checking the debug logs
Step VII
Select the new address on Metamask that we just sent the tokens to.
Click import tokens on Metamask
Click “Add Custom Token” after pasting the token address
Click Import Token on the next page
Confirm that your token has a new value!!
Well done! Now, lets check whether our main account has less amount after doing the transfer!
Step IX
- Copy and Paste the address of the main account on the balanceOf field
- Click on `balanceOf` and obseerve the results on the debug console
- Our balance is now 49000 PETER as we anticipate!!
Conclusion
- You could even play around with the new methods we created and see that the contract works as expected.
- See the screenshot, you should see something similar to that
Wow! Good job if you followed this to the end! Hope you enjoyed this!
You might be interested in how to start buying crypto.