Build a DApp on Polkadot using Acala EVM with On-chain Automatic Scheduler - Bryan Chen
Ethereum Denver·Sat, Oct 9, 2021, 12:00 AM
This talk is from ETHDenver & ColoradoJam , the world’s largest Web3 BUIDLathon and Community Gathering. ETHDenver’s content is crypto and blockchain focused. Learn more: ethdenver.com Subscribe to our channel to learn more + connect on Twitter: https://twitter.com/EthereumDenver. Speaker: Bryan Chen, Acala This talk was recorded Saturday, February 6th 2021. ETHDenver 2021’s content themes included DeFi & Money Legos, NFTs & the Creator Economy, ColoradoJam & the Next Frontier of Statehood, Protocols & Interoperability, Open Source & Public Goods, The Ownership Economy & Digital Orgs, Usability Design & Adoption and Legal, Privacy & Identity. Industry experts also weighed in on topics like decentralization, privacy, identity, non-fungible tokens, scaling, governance, diversity, and arts and culture in blockchain technology. The 2021 event was February 5-12 and hosted virtually in 2021 with 5000+ blockchain enthusiasts, developers and community members from 80 countries and 50 U.S. states. 🔴 SUBSCRIBE ETHDenver’s YouTube https://www.youtube.com/channel/UCgz9NU06t_FkT0Py1Vadczw 💡 LEARN ETHDenver’s Official Website https://www.ethdenver.com/ 👋 CONNECT ETHDenver Twitter https://twitter.com/EthereumDenver 📖 READ ETHDenver News on Medium https://medium.com/ethdenver 🛍️ SHOP ETHDenver Official Merchandise bufficorn.com 💬 CHAT Telegram https://t.me/Ethdenver Discord https://discord.gg/AxFmNdCVnU 📱 FOLLOW LinkedIn https://www.linkedin.com/company/ethdenver Instagram https://www.instagram.com/ethdenver/ Facebook https://www.facebook.com/ETHDenver/
Transcript
brian is brian with us brian from akala network hello everyone hey ryan good to see you so you're ready are you ready to get on with automatic schedulers yup all right cool floor is yours sucks hi everyone so um this is brian from kala so today i'm going to present you how to um build the depth using uh within the academy and we're going to show you the on-chain scheduler feature they have implemented in the akala evm so let's get started so firstly uh we have uh we had a qualcast about talking about the istanbul event the bounties and more details so you can also check out our characters on youtube for more details so a quick uh intro about akala so we're a divine hub of polka dot um so we're going to be a pocket approach and offering become a d5 platform so we have built a few primitive services which including a stable calling protocol a staking liquidity protocol as well as decentralized exchange and amn style exchange and we also have obviously other things like governments and the ebay platform as well so we have tested um live so you can just try things there architecture is basically where build on top of pocket doors so pocono offers the share security and all the questions messaging stuff and as well as all the other bridgings and other ecosystems and we have built a virus of d5 parameter protocols and one of the is the smart contract platform the ebn platform and then the developers the d5 and other solidarity developers will be able to deploy your solidarity projects um into the akala ebm and leveraging all of the d5 parameters that we have provided to the akala evm so just another thing um even with not trying to be 100 compatible with ethereum because obviously there are already quite a few um ethereum layer 2 solutions or other smart control platform they are 100 compatible with ethereum so we figure there's no need to have another one so instead instead of trying to build another ethereum node uh to make our blockchain though become if they don't know that we're doing something else different we depo we developed a js and sdk we called it so that is basically taking the pokestore extension rapid make it looks like webster provider so your existing eso js scrap or an app steps will be able to use the vody js and we'll be able to use the pokedot extension and for the signing and other stuff and then our bodygs underlying the hood is using the poke.js to talk with our blockchain nodes and some other servers for um for example we have indexers to create historical events etc so this allows us to do and enable some quite unique ux and enable a few special features that cannot be done otherwise so for the bounties we have two bounties um again all these things we have talked to us in the chromecast before but just quick recap so and the first one is basically build a depth and deploy get and deploy in aka evm should be very simple the second one is i would like for you to use the on-chain um scheduler feature so this is the unique feature of that car even and hopefully this can solve a lot of trouble stick cannot be what will be very hard took down um in other ethereum capital platforms um so we have provide a hiker guide so in our wiki page so they should have all the resource documents etc that you'll need to feel free to download in the akala channels and we'll be providing help there well then um let's start hacking so before i start hacking um just show you some of the tools and things they will support so so as i have mentioned before we are not trying to be 100 ethereum compatible so we don't right now support all your existing ethereum development tools but we do support waffle and remix so hopefully this should cover um a lot chunk big chunk of the projects out there and we also have the ebay and playground so there is a simple ui i'm going to show you uh soon so you can upload your countries and call your countries there connecting to our public destiny or connecting to your local testing so that's just another command to help you to run the node so you can either just build from the source build around a color node from source code or you can just uh run with the token image and we have also examples in the akala ebn and even examples we have repo so which should have all the codes i'm going to show you today so uh another few things so well i kind of even we have a academy we have a few unique uh features so first thing is we're trying to inherit all the goodness from ethereum or the community the developers the existing uh libraries and the ecosystem but ethereum is well it's a old project in a blockchain time so you have a few legacy decisions so we have to want to avoid those things as well um but if we're trying to become 100 capable compatible with ethereum that would just that means we need to inherit all the legal citizens from there like for example if if they don't have a bug then to be 100 comfortable we need to have exactly the same bug to not break smart contracts which is well uh not a nice thing for a new blockchain platform so one example would be guest tokens well some people say it's featured some people say spark but um it's not a good thing for the um the whole thing i think so with not it's not something we would like to make it possible on akala ebm and so to highlight a few unique features of aqualivia so here we have mirror token scheduler we also have oracle gateway so those are the things we have implemented and ready to try in our testnet and in the future also also implement a lot more apis so if you will have some apis for the question iterations so you will be able to send your tokens to um other paratrends of the pokedoll or you can even send and interact with thoughts on the polkadot i also are going to provide a lot more the runtime api of a color so for example we will going to provide the staking protocol uh the staking director protocol i was we're going to offer the apis on of the stable calling quadco as well so those are um still working progress so hopefully we'll be available soon so um let me talk more about the metro token so meta token is somewhat similar to the rob token so on ethereum you you probably already use wrap ease before but to to make roughness you need to like wrap it mint it and then to come convert it back to east you need to redeem it by the mirror token there's no wrapping required uh all the native tokens of akala will be exposed to even rcrc20 and there is is they're sharing the same underlying storage so if you anything change on the balance of the um the account of the native balance the change will be reflected on the essay 20 token representation immediately as well so uh let me just uh show you it's a quick demo so this is a color ibn um so currently connecting to our test net um so we have a few smart countries and so those are the building smart countries so you can see we have they say our native token which is will be the easing in our platform so we have a few um much more other tokens which are our native tokens and as well as a few question tokens as well like the thought will be in the question dot nx btc with equestrian btc or the ram bbc so um well so it's this is a native um akai is a negative token let me take the door pass example will be better so i can for example just query the balance of the test account so i have this many dots and if i connecting to the public test net and i can't um query the balance so this is the console so it's uh the development tool for the polkadot or substrate um project so you uh if you only deal with the evm platform you probably doesn't need to use this one at all but um let me see extension so i want to check my balance so you can see all my balance here so um they say it just means there's a unit uh with 18 decimals so you can see the balance of thought and match through here and then i can just try to make a transfer uh i need to find the address to transfer so let me find another account oops let me just go right this way so this is the finding the ebay account because um a color is built with substrate so every substrate address will have uh needs to bind the ebay account because the substrate address is using a different account format with event so in order to make sure um like the subject account can be used to sign even transition we need to do the combining so that's how you how to bind them together so then i can send some thoughts to this account just using the transfer uh just enter some value sign the transition so this is done let me check the balance again the value i entered is way too small so let me make a slightly larger number so it will oops wrong one yes so you can see the dot panel has changed here so even transition making the dot balance changes here um so go back to the next feature and so uh so those are the smart smart country address of all of the merit token of the native token so because well they are the system smart countries so we can pick the address so there's also another benefit is by looking at the address itself you will know they are the official smart country address and they are not just some other people deploy some other tokens name take a name of the usd for example um so next feature i would like to highlight is the scheduler so let's allow the smart contracts to schedule a call after a number of blocks um so basically let's say i want to say um pay someone every month then i can just write a smart contract schedule call and make a payments for my account every month or from my from the smart control every month so there's no need to have run the sum of train server or have some keepers uh sending a transition to trigger the transition summit sending things on on the blockchain every month so this saves a lot of things make a lot much easier there's no need to run so many options servers and the fees for the upcoming course are reserved upfront and then when the call when the schedule call get called the fee will be consumed and of course the remaining one will be rebound after call so this is the uh smart country address for the scheduler again this is accessing contract so you can just looking at how many sales area so this is the interface so let me just bring up the code so um yeah so this is the okay so this is a scheduler uh so it's very easy to use basically just pass the country address the address that you want to uh i want to be called in the future uh the value uh well this well that's basically how much native token you want to send along with the code and the guest limit and the social storage limit so this is a um also unique thing of a car even so we have implemented storage rent unless it's not enabled on a test net currently so you just you can just pass a large number now later when the store trend is enabled this can limit how much storage additional storage usage can be uh used in the call there's a minimum number delay so um for the code to be called in the future so uh just one small thing so this one is so if you're passing zero this means uh the call will be scheduled in the next block uh so if i see one this call will be scheduled in the two blocks after the current block and this is also not guaranteed to be executed of course because otherwise people can potentially schedule way too much code in the same block so there's only a certain amount of blocks ex space is reserved for the scheduled code and if there are too many schedule calls then they will be delayed to the later block infusion also going to implement some option mechanisms allow people to bid for the executions to simulate some kind of like guest price embedding so uh if you want to make sure your core gets scheduled scheduled on time then you'll need to pay a bit more money but otherwise you can just pay as low as possible so the call is only called when the block blockchain itself is have a lot of free spaces and then you pass the input data so that's basically the selectors the arguments etc and it will return the task id so this basically the block the schedule will be called and the id so in the future we'll also provide apis to cancel or reschedule a scheduled task using this task id so this is a this is the code to use the schedule so there are two ways to invoke so this is one way so basically you have a constructor taking bunch parameters so this is making implement the requirement recruiting payment so let's say i have 10 native tokens i want to do some budgeting things i don't i don't want to them i don't want myself can spend often on a day one so i can set uh the smart countries only say the period will be 10 uh sorry period will be one day uh what's the number of blocks this account will be 10 amount will be 10 uh amount will be one so the payable will be myself and then send 10 native hook tokens along with this constructor and this will basically well then the smart country will pay me one tokens every day so well then to use the schedule is very easy so just passing the address just passing the pay so be using less to pay back um the value is actually zero here and this is the guest limit and storage limit the period so uh the schedule feature is that only support one um like one time task so you need you'll need for the recurring uh course you'll need to just reschedule it again uh in the next one so save all the parameter to the storage and after the period so let's pay a court and you want to make sure the other people cannot just uh trigger this maliciously so you can just ensure the sender is from the smart country itself and then you can just transfer the token reduce the remain account and schedule another one or if it's the last one then you can be a nice citizen to free up this no longer useful smart contract just self-destruct will also at the same time send all the remaining tokens to the tool destination so this is basically how to use a scheduler so it should be very easy so this is another example so instead of dealing with the native token this is using uh the yasi tanki token so this resource i might make it a slightly different format than the other one so um basically i can deploy this token and off make a scheduler service and everyone can use this smart contract to do the recruiting payments for any erc20 so you'll notice the all the parameters encode with the input data instead of the storage of the smart contract so everyone can use the same recording payments so just run this i'm going to use the ui the evm pay one first so this is a command to start the test net so i can make this connecting to the local technique so first i can upload the smart contract oh sorry first i will need to build a smart country and upload the json file build from waffle so it's just a pretty standard api file so i already have uploaded here so you can just deploy it i'll need to use the building div account which is account actually have money so the block time is 4 seconds so hopefully it should be executed soonish yep so that it's deployed now so uh i need to take the smart country address i need to approve it so you can take my money so i'm taking the tokens example so i'm going to approve this account with uh just get few more zeros so this is now proof so go back to um the recording payment so i can use the schedule so i like to schedule the transfer box uh like every four block so i pass three five stages every four blocks here uh the count will be less through five times the amount will be uh so that should be one dot um i don't know just make it to myself so i can execute so you can see now this is scheduled and go back to the blockchain explorer here you guys i can see all the events here so uh 28 so i've seen this already scheduled a task um yeah you can see on the box 28 there is a the task so even on the 32 uh there's no smart country score here there's no one triggering the scene our blockchain itself is triggered with the uh by the scheduler so you can see there's a dot transfer from a smart contract to alice with one dot and there's also the ebn transfer events which is slightly hard harder to decode so there's also schedule event um yeah so this is basically um the schedule is running and sending files every four blocks so let's say 36 there's some schedule and approach 40 there's another schedule so next one is 44 so next one is 48 you can see here so this is basically scheduler running in action so yeah so with this we can implement a lot of interesting um things like this you can just for example every month taking some track of the second reward liquidate them or you can just another common invest strategy is total cost averaging so you can just deposit or you don't even need to deposit anything upfront you can just deploy a smart contract just using the dex to buy a certain amount of thoughts every month or so and you don't need to have all the money available up front it will just try to buy every month so you just have your salary deposit your smart contract something like this so yeah so this is basically how to um use the schedule so um next one so the next feature of our color is the oracle gateway so this allows us smart contracts to access the price data from the academic gateway so we have built a stable coin protocol so itself will need some oracle data we need some pricing data for oracles so we don't build oracle ourselves so we are working with different oracle providers for example central chain link the band protocol and a few others as well so they'll be feeding the price data for dots btc and other coins into the arcade platform but that just means so this means we will have some high quality price data so we can make that available to everyone as to all the developers as well so that's why we implement this oracle api so you can just um very simple it just this is the country address and just call this get price on this country address and you can get the oracle price and then later we'll provide a more detailed api so you can get for example the price for a particular oracle provider so for example if if you only want to use trending you can do so just get only the price folder generally so just to show show you the oracle so this is the oracle smart contract so i'm currently committing for public test net so we do have actually have the oracle running so of course um so i can just get price for the dot so you can see uh stock price is currently 20 dollars each so that's the timestamp so let's show you when the last upgrade price feed is coming so you can decide if this data is recent enough okay it's also korean three will be bitcoin yeah so this is the bitcoin price uh seems high for sure um yes so that is what this is how easy to use the oracle gateway um yeah so those are the unique features of academia so we also have a few more other features will be available soon or actually they have implemented i'll have disabled in the testnet to just to keep the capability by later on so one thing is the state rent so on ethereum we have the like the storage is huge with a lot of issues like the smart countries just deployed no one actually free up the smart contracts because white border um but there's no one actually deletes that the no longer useful data from a smart contract so this is fine for it's nice and easy for the developers but it's causing a lot of um like increase the storage usage and increasing the cost of the node providers and offer infrastructures so would like to solve that so we have to implement a very simple version of the state rate mechanism so the smart contract developers will need to consider how much storage they use they need to make sure they don't uh write too many data or they need to pay for the data that view they have the incentive to free up the unused data or destroy the smart contracts when it's no longer used but of course this will come with capability issues when we're involved state renting because well you're not your smart contractors will need to have some money uh might need to have some money to in order to cause some other calls another issue of the ethereum is the dust account so we have so many accounts that only have a tiny tiny bit of either they're just impossible to spend especially given the current gas price it just doesn't make sense to spend money on those accounts so the account will just sit there does nothing use the storage in forever so that doesn't make sense so that's why i would have the accenture deposit feature so this is uh not actually implemented feature this is the portfolio uh or the structural implements feature about when making it available to ebay as well so of the native tokens they say token thoughts question tokens etc they have extension deposit so if the balance drop below the certain threshold um the banks will be wiped um the dust will be sent to treasury so this is just another expat thing for the smart countries so when you are writing smart countries there's something if you want to deploy or call it ebay this is something needs to be worried about but unless it's not enabled for the public test net so you don't have to worry about for now another feature we have is the deployment pipeline so this will allow um so right now in ethereum many people just kind of test on production deploy a smart contract there is public forever to use and see if that works and folks announce it but this can sometimes come with issues that you you don't really want people to try your unordered unfinished smart country but you don't you probably don't want to implement some permission control thing just for uh just make sure people cannot try your smart contract before you um so that's what we have implemented so we have implemented some features the smart contract by default when deployed uh they'll be in kind of private state so only um a small set of people will be able to interview smart countries and to do some beta testing basically and when it's ready then you can make it public and open for business and everyone can start using your smart contract so it's something similar to a test fly if you are ios developer and also join the private phase you can also to upgrade your the code of your smart contract you don't actually need to implement all the communicator migration uh upgradability things you can just using the later feature of archive to upgrade code of smart countries but of course when you make it public everything will become immutable again so you can no longer modify the smart countries like we saw people notice it but if oh you just cannot no longer modify the smart countries and so those are uh all the unique features of la cabin so um yeah seems that we are almost up to time so thank you i'm not sure if you anyone have any questions so uh ryan that was awesome thank you very much sex yeah it's cool to see what's uh becoming possible now with a lot of these new blockchains like like polka dot uh cosmos it's going to get really interesting here soon so yeah if you have questions for brian uh jump in there i'm sure he'll be eager to to answer any queries you have and thanks again
Automatic transcript — names and jargon may be misspelled.