In the previous thread we saw that we can do basic transactions through different DLTs with simple Overledger API calls.
Today we are going to level Up a little bit and make some cool interactions with a SmartContract.
Follow me... 👉🏻 ....🚣🏻♂️ 🌊🌊🌊 🏰
First we should know what a smarcontract is.
Quite simple, its just a set of rules that are programmed into the blockchain. Imagine I want to create my new Shiba2000 token, I need a Smartcontract that allows me to Mint/Burn/Transfer/Rugpull those tokens.
That contract would have what are called functions:
- Mint function: This function just creates the amount of tokens that as the admin, I ask him.
- Burn: This function just burns/destroys the amount of tokens I tell him.
- Rugpull: This function steals all your money(DeFi vibes)
So every time we use tokens, transfer them, mint them or burn them, we are interacting with the functions that were programmed in the SmartContract.
EASY 😎
For this we need some things:
- A DLT: I have chosen AVAX, to give some honor to our latest news of Overledger Integrations.
- A Smartcontract with some functions, mint and burn for example. Of course it has to be deployed in the DLT.
If we enter in the link and checkout the Contract✅ section we would see the solidity code and some different taps.
- We click in the WRITE tap and look carefully 🧐
- We click in the mint section and see the different fields that have appear under it.
If we have clicked correctly in the mint section we should see the following:
- to (addres): This is the address that would recieve the minted tokens.
- amount(uint256): This is the amount of tokens that are going to be minted and given to the address.
If we click in the burn function section below the mint section, we would see the following:
- amount(uint256): The amount we want to burn
You can look into the other sections if you want, but today we are going to play just with these two 😁
Now we go to Overledger´s programming codes...
We are going to see what info we would give OVL through its API to make the magic happen 🪄
What I show you in this tweet´s image is what is called a JSON.
This contains the info that OVL needs to enroute our mint petition to the AVAX DLT.
We can see the following:
- "urgency": How fast we want our tx to be validated (Slow/normal/fast)
- ResquestDetails:
- "overledgerSigningType": The library we would use to sign.
- Origin: The address of the account is sending the tx (In this case its my address)
- Function:
- "name" : The name of the function we are calling (mint)
- InputParameters:
- "value": This is the address that would recieve the minted tokens.
- "value": This is the amount of tokens to mint (1 token)
We ignore the payment section, but remember we are in Avalanche, the native token is AVAX.
- DestinationID: The address of the smartcontract (SWITFBURGUER)
- "Technology": As Avalanche is a EVM based DLT, we choose Ethereum.
- Network: The Avalanche Fuji Tesnet
- type: As we want to invoke a contract function we choose this, but it can also be (Payment/Credit/Contract Invoke...)
Nice, now we call the API and look the results...
1 - Overledger Transaction Request, literally this is the JSON we were talking about. The info that OVL needs to make his work.
2 - The whole package is signed with my private key, using the overledger signing library we talked earlier.
3 - The signed transaction is sent through OVL to the correspondent DLT, and we get an answer of how has gone. testnet.snowtrace.io/tx/0x369f6416f…
The analog case would be to do it with the burn function.
Now lets try to imagine a possible use case for what we learned today.
-STORY TIME-
We are a fast food Franchise.
We decided to create a loyalty points system that works like the ones of McDonalds or Burguer King.
The difference is ours work with DLTs, our loyalty points would be tokens that are stored in the client wallets.
I present you my friend Ronel McVerdian 👋🏻
Ronel McVerdian loves the smash $QRC-burguers we make.
He decides to take a fast break and have one just before coming back to the EBAday Summit (In Madrid) with his SWFIT collegues.
He prepares his loyalty points app 📱 and chooses his favourite smash burguer 🍔. He shows the QR of his account to the vending machine and makes the checkout.
He´s loyalty point have gone and he now has his burguer.
But how this worked in the back?🧐
Easy, the tokens have been burned just like we saw some tweets before.
Interesting, isn´t it?
Now Ronel McVerdian is happy with his burguer, without even realising what happened.
Thanks for reading this thread.
Hope you have learned something new, and had some laughs with me 😁😁😁
Give some love if you liked it, and tell me in comments if you prefer smash burguers or the normal ones !!!
Keep rocking guys🔥
• • •
Missing some Tweet in this thread? You can try to
force a refresh
This guy was testing some kind of CrossChain-swap smartcontract. So I started looking for transactions to see how he was interacting with it. This is what I found In the payload:
Here we can see that this SC it the Ethereum side of a two phase bigger program that end in Hyperledger Fabric. But if we scroll more...
Firstly, I want to make this clear, I'm not a professional programmer, just a Telecommunications Student that has been interacting and playing with the programming material Quant has given us.
LET’S BEGIN 👇🏻
- QUANT SDK -
Not many people know that Quant has a GitHub profile, where they show publicly some programming stuff they have designed for us to interact with.