Smart Contract: EOSIO vs EVM | Lesson-3
Define an Interface
Hi everyone,
After a long time, I finally got some time to pen down bit of tech thoughts. So, here I am with lesson-3
of the 2 most powerful & popular blockchain protocols’ comparo series.
- EOSIO chains: EOS, WAX, Telos, FIO, Ultra, …
- EVM chains: Ethereum, BSC, Polygon, Fantom, Avalanche C-chain, …
Please do read the previous lessons, if you haven’t already:
Smart Contract: EOSIO vs ETH | Lesson-1
Smart Contract: EOSIO vs ETH | Lesson-2
Let’s start…
Have you ever come across a situation where you need to use a function of Smart Contract (SC) A from inside a function of another SC B?
The steps are as follows:
- Define interface
- Call/use interface with address/account_name
Below is the code snippet for defining the interface:
where,
mytoken
— the name of the EOSIO contract
transfer
— function/action of token contract on EOSIO, EVM chains.
Below is the code snippet for calling the contract with the defined function:
The interface just shows the input & output parameter of a function present in the SC code. But, operation is compiled as per the code deployed in the given contract address.
where,
in the case of EOSIO SC, the permission_level
is defined & the caller of the function (in SC-B) should have permission for calling the function (in SC-A).
token_contract_ac
— initialized inside the constructor of scb.cpp
file.
— — — — — — — — — — — — —
And the same is applied to EVM SC in a different way syntactically.
tokenSCAddr
— initialized inside the constructor of SCB.sol
file.
That’s all about defining an interface for an SC.
See you on my next article.
Thanks for giving me time to read through it.
Follow me on:
Email — dalvath3700@gmail.com
Github — https://github.com/abhi3700
Telegram — https://t.me/abhi3700
Steemit — https://steemit.com/@abhi3700
LinkedIn — https://www.linkedin.com/in/abhi3700/
Twitter — https://twitter.com/abhi3700
Medium — https://medium.com/@abhi3700
Fiverr — https://www.fiverr.com/abhijitroy294
Facebook — https://www.facebook.com/abhi3700