ZK Hack Lisbon: Privacy on Polkadot via XCM - Moonbeam
20 Apr 2023 · 56:08
Recorded at ZK Hack Lisbon, this session from the Moonbeam team covers building cross-chain privacy on Polkadot using XCM, cross-consensus messaging. It was part of the first in-person ZK Hack hackathon, where builders worked hands-on with zero-knowledge tools and domain-specific languages alongside teams from across the zero-knowledge ecosystem.
Topics
Transcript
foreign [Music] thank you for coming so yeah we're going to start sort of a brief explanation on on Moonbeam and the workshop that we've put together this is jointly with Manta which is another parachain on polka dot but less sadly they could not be here so um yeah the idea is that if you're not familiar with how polka dot works is that moomim is a smart contract parachain on polka dot but it doesn't have privacy built into it right it's just a smart contract platform but the idea is that in polka
dot you can have is this a pointer oh it's a pointer I'm not sure anyways um the idea is that you can have para chains like Manta which can provide a privacy layer but they're a separate blockchain completely right and you can communicate these two blockchains via a protocol collection and so that's why we call it privacy and polka dot vixcm so um yeah we need to talk about polkadot right because um polka dot is basically where everything is happening and so polka dot basically the idea is that you don't have one blockchain to rule them all but you have an ecosystem of blockchains that are secured by the same core layer or layer 0 which is called the relay chain which is actually what
polka dot is polka dot is it's a blockchain for other blockchains basically and the role of polka dot is basically two things generally speaking first it it actually secures these blockchains providing consensus to them but because of this architecture you can actually have them interoperate under the same consensus umbrella right so you're asking uh one blockchain or parachain to send a message to another parachain creating State changes but these State changes are going to be governed or verified by the same consensus in both cases and so you create an ecosystem of blockchains which each provide something unique to the entire ecosystem right so you have moving bean and hearing
compatible smart contract pair chain you have Manta Bean a privacy layer based on CK technology and then you have other other parity inside storage identity Bridges oracles Etc right and like I said before the key technology that it's it's used to communicate these pair of jeans is called Axiom xcm is a very generic term but it's what allows this participants to communicate with each other so um let me explain briefly how developers can interact with Moonbeam right um if you think about ethereum compatibility you can for sure see a person that's called the person Bob um or Alice and then that person can interact with Moonbeam using the
ethereum API right that that's like ether JS hard hat metamask remix all the tools that you're familiar with even a larger device through a wallet or whatever um that is what allows you to build solidity smart contracts and and not having to change anything of what you're familiar with if you are but on the other side mummy meets build on substrate if you're not familiar with substrate it's like an SDK generally speaking to build blockchains and it's very customizable you can do a lot of things but it also provides another interface right a separate set of interface in which you can do staking governance xcm or other things that are not native to the evm right so you can do Native staking or native governance
or native stuff that it's outside of the evm realm let's say and so the way that we actually allow evm Developers for solidity developers to to tap into that complex interface that is not known by the evm is through pre-compiled contracts okay the idea of pre-compiled contracts is that there are interfaces evm interfaces right now we have them in solidity but we could have them in Viper or whatever in which you can access functions that are going to do a lot more complex stuff under the hood because they're going to do substrate things right so you can for example send an axiom message using metamask or
signing with metamask you can a stake you can do governance you can do batch transactions to one single transaction so in in as a summary you can do things that are not standard evm interactions through like an evm or ethereum-like interface or experience which is which is what's really cool about moomim that it's not just another evm chain it has special things special features so that's why I say that pre-compiles are like having The Best of Both Worlds because if you're familiar with solidity ether is hard hat you can still use that and I brought adapt as an example that you're just going to use metamask but you're doing much more complex things so
um this Workshop this this idea is the presentation is going to be somewhat brief and the idea is to show you adapt that you can use as a baseline for the Bounty because you know it's like 3 P.M or 2 30 p.m and you have like 12 hours to build and so I've done a lot of work to help you guys get started and get you interested in the Bounty but let's talk first about xcm and especially remote transact what is it okay so at a very high level this is super simplified because as developers you know it's like if you want to build and you have to learn opcodes which is a great thing to know but you don't really necessarily need to know up codes to build smart contracts um at a very generic level what Axiom is it's a message with instructions right
and it's a combinations of instructions that actually do something so one instruction can be stand up by itself it doesn't mean anything but if you have a combination of instructions like stand up walk to the left and flick the switch three instructions you're going to have a meaningful action okay so at a very high level that is what xcm is it's it's a message that has instructions and it's directed to another chain it could be within the polka dot ecosystem it could be outside of the polka the ecosystem soon because they're they're doing upgrades to enable that okay and so as an example I brought here a series of XM instructions that actually do something really do
something unknown so one use case of xcm which is very famous is token transfers that's the first thing that Everyone likes to do I guess um and once again there's a combination of vaccine instructions that result in tokens being transferred and the one that we're going to focus today is remote execution okay so the idea of com combining Axiom instructions so that you can execute code on another para chain using xcm and that's what's really important here because if you think you know one of the first slides is that movie it's an application layers it's an application blockchain and then Manta provides privacy layer on top of it right so imagine you build your application on Moonbeam but you want to privatize certain aspects like payroll
you know you could build that privacy layer on Manta via xcm and so this is how remote transact or remote execution works at a very high level once again you have Alice on polkadot I should have used Moomin to be honest but yeah I had this example from before you have Allison polkadot and she's going to send an axiom message with a few instructions like I said you don't need to understand the instructions for now to mumbi and what's going to happen is that when the xcm is processed on Moonbeam there's going to be a new origin a new dispatcher okay that's going to be created automatically by the protocol and this dispatcher is going to be known as multi-location derivative account you're going to put that thing
on your brain because I'm going to be referencing to it quite a lot MDA multi-location derivative account however you want to like it call it but basically this dispatcher all right which is it could be a message sender in the solidity environment um it's derived it's basically calculated from the origin on polkadot and I'm going to show you briefly how and so now this dispatcher is going to actually execute the xcm world it's going to be the message sender of the xcm and then you're going to call some bytes on the runtime that are going to do a certain action and this is once again at a very high level how remote execution works on xcm what you need to know is what bytes are you calling on
the target chain okay that could be call this smart contract and do this called the staking module and do that so that's what you need to know the bytes that you're targeting on the on the destination parent chain okay and if you if you think about it the other way around so if Alice would be on mumbim and this would be Manta right on mum you can create the xcm message through this pre-compiles that I've mentioned before so you can actually do this you know from a smart contract or sign this message from metamask and so on so the multi-location derivative account is basically calculated uh with a hash right so that way you know that it's a
one-way operation um and then it's the hash of something called the multi-location and I'm going to explain multiplications in a little bit more detail later but as a as a sort of introduction to multi-locations this is a way to reference things on polka dot in a generalized way you have an ecosystem of blockchains an ecosystem of users of tokens and so multi-locations is a way that you can represent anything that you can think of inside of this huge ecosystem so in this case there is a multi-location that is specific to Alice on polkadot you don't really care what account ID Alice has what hashing they use or what cryptography they use on polkadot you don't really care even if it's ethereum
compatible right but a number once you get that multi-location you can hash it we use that mechanism and we're actually proposing this to be a standard in polka dot you can hash it and then you can guarantee because you're cutting 20 bytes you can guarantee that this is 160 bit long long or 20 bytes uh the hashing doesn't really matter I mean as long as a one-way hash it's it's strong enough and then you can guarantee that it's ethereum compatible because 20 byte addresses are ethereum compatible um yeah so this is multi-location derivative accounts it's a way that you if you think about the example I was saying before you can actually control another account on another Opera chain or another blockchain without having to
move to that blockchain right so this is actually the example that we're going to do later and I actually have a tutorial on the movement documentation when I'm doing uni swap V2 swaps on Moonbeam where I'm actually initiating the swap on polka dot so I don't even have to have metamask or anything I'm just doing everything via xcm and this multi-location derivative accounts all right so so keep that term in your head because we're going to refer to it later in a demo so this is at a lower level now how how the remote transact works and this is important because even though you don't really need to understand it at a very high detail you still need to know a few terms and terminologies because you know
you're going to be configuring a little bit of this xcm messages what's really important is what happens on the destination chain on the Axiom messages and remember that I said that xcm at our series of instructions right these are the instructions that normally are received by the destination uh blockchain okay in this case Moonbeam or Manta the first one is basically what creates this multi-location derivative account okay so it's basically that this is what you're saying this is Alice on polka dot or Alice on Moonbeam or whatever the second one it's going to take funds out of this multi-location derivative account and it's going to put them in something called the holding registry the way that I like to say it is that you know I take money out of my my pocket and I put it on the table just
just to put it there because we're going to use it by another instruction right remember that an instruction by itself doesn't mean anything but a combination actually results in something the next instruction is actually you're going to grab some of the money on the table and you're going to buy executional with it you're gonna buy blog space or execution time however you want like to refer it right and so you're saying I am paying so that I can execute stuff and the last one is basically I want to grab these bytes that represent something in your blockchain and execute them please okay and so some parameters that you can think of that you need to configure is how much money I had to take out how much execution time I want to buy in seconds basically and how much
execution I want to buy for the transact right so let's say I it's a gas limit you can think of as a gas limit right I want to buy 10 million gas units and then I want to use 5 million of those gas units for the Transat basically okay this is like an analogy on ethereum cool so multi-locations um like I said before this is a way that you can sort of represent anything on polka dot with a single representation the way that I like to see it is like folder paths right I mean maybe it's a good idea maybe not but um basically it's it's uh you define a target from An Origin right if you're in you know your user folder and you want
to Target another you would just go CD blah blah blah and get to it um it's relative to an origin it could be absolute as well but to be honest it's a lot easier to understand um multi-location so if you think it from a relative perspective um and like I said you can represent everything everything with two simple uh things parents which I like to see it as as hops to an upper level like an open folder like a parent folder that's why probably called parent and in interior which is a way that you can represent what it's on that current level okay so let's go through some examples let's say you're in polka dot and you want to Target um an account you want to Target polka
dot itself this is how you represent polka dot in parents zero because you're still in the same level and they're interior here that's like a type of interior they're like many types of Interiors you just they're predefined basically okay um if you want to Target Bob on poker that you would say parents zero but then interior I would put X1 I only need one field basically to represent Bob it's about yeah and it's basically the account type of Bob which in polka dot is called account id32 because there are 32 bytes sorry if you want to Target another pair chain you would actually just use one field inside interior called parachain ID which is like chain ID
and you would just put the perishing ID which in this case I use takala and it's 2000. and if you want to Target Alice inside of akala you would actually use two Fields right because you need to go to the pair chain and then you need to go to the account which is another account id32. in the case of moomim is very similar the main difference is that we use ethereum style accounts so you would put account ID 20 right and and there's also a way to represent this like complex multi-locations in in like solidity smart contracts but basically you need to know that they're like different account types and then you can also represent assets by adding more fields and more fields and so on really briefly if you now the origin is
now Moonbeam right um You can get to well now inside movie you need to put parents right and you need to put uh X2 now because you're inside boombeam but if you want to get to polkadot you have to use parents one you're moving to an upper level in the folder and if you wanted to go from Moonbeam to another parent chain you have to use parents one because you're moving to an upper level but now you have to then keep everything else the same all right this is quite simple and like I said I brought examples and everything to to help you guys all right so building multiplications from pre-compiles on solidity right so this is how if you're gonna interact with xcm on Moonbeam using the
pre-compiles this is what how do you actually build it so the way that we actually do it is basically it's an it's an object as you can see the first element of the object is that you wouldn't basically sorry as a Boolean or you say you went actually which in this case is only zero and one but it's not a Boolean it's a unit and you know you can put zero if parents is zero one if parents is one because we're targeting another parachain right from mumbim you know think about the folders and so now you have to put one for the the other part of the Interior the X X1 X2 X3 it's the size of the array and then basically if you want to Target down another pair of chain I in the documentation there's a list of how
you build it but basically you have to put a selector which is in this case for to to provide a parachain ID is zero zero and then you would have to put the perishing ID which is more or less a chain ID in hexadecimal and it's in four bytes so that's why it's zero zero I think I do have it here so 0 0 for the selector and then zero zero zero zero zero and then the peritone ID in in hexadecimal okay and this would be actually maybe this is actually Manta sparitin idea I might be I might have confused myself a little bit here but the the important thing is a structure right basically this is the the multi-location when you want to Target another pair of chain from a solidity uh perspective
if you want to Target another account look that it's it's fairly similar you have parents as one um oh there you go anyways you have parents as one and now you have the area needs to be X2 because we need two fields to Define it the parent chain ID and the account right and so you could see that the parent chain ID is the same as before and then the account is filled with this complex uh structure which is basically zero one zero zero as para genes ID 0 1 it's an account key 32 an account id32 which is the polka dot style accounts and then we provide the account which is this 64 bytes or 32 sorry 32 by 64 hexadecimal
number and then we have the network type any which is those two zeros at the end these two zeros you can always keep it like that so basically the important thing here is 0 1 as a account ID 32 and then the account itself in this case it's the multi-location derivative account because that's the account that we're targeting for example to send tokens to or whatever you want to do this might you know make a lot more sense when we're actually doing it in the in the DAP example okay but just keep in mind that you know this is X2 because the array is size two uh and then you have the zero one account and then zero zero cool um and then this is the part where you
can actually think and and this is where you can do whatever you want and this this part you can do exactly whatever you want because this is the bytes that you want to use in the transact so this is the bytes that you want to execute on the on the target chain right so if you're building privacy applications on Manta you can say hey I want to call this palette privacy blah blah and then mint a private asset or whatever okay so in here you can do anything that you want and the example that I brought I'm going to do a simple balance transfer because you know you guys got to do a little bit also like on the Privacy layer but as an example it was just a simple balance transfer and so if you're unfamiliar with polka dot this might ring a bell which is basically
we're creating an API provider this is similar to like the web 3 provider in ethers or web3 JavaScript and then once we have the API provider created and the like the last or the the one before the line uh you can see that I'm calling the function with the destination address and the amount that I want to do and then the call data I get it basically by using method to hex so basically here you can say whatever function that you want and then if you add this method to hex you're going to get the call data right so that that can be anything like I said it could be what it's called a system remark it could be call the private palette and then whatever method right so this is where
you can get creative and and do like you know weird applications on top of manta for example so um this is the demo app that I I worked um uh for you guys to show you more or less uh by the way at the end there's going to be a QR code with like the the slides and then so you can get access to all of it right so um this is the app that I I created for this purpose you don't have to use it but like you know like I said you have like 12 hours to finish it up so this is like a good start if you want to start building on the Bounty so yeah let me show it to you because um yeah it took a while to be honest I'm I'm not a programmer by the way so this
is a very simple UI this is not pretty but it works which is which is helpful um I'm gonna step actually let me take the mic with me hopefully there we go so basically um the DAP it's super simple uh you need to provide the websocket endpoint of the parenting that you want to Target in this case it's mantas mantas pair chain inside of our test then so we do have like a polka dot we have a moon beam and we have a manta this is basically the token um I didn't explain this because of complexity but when you're doing xcm someone has to pay for it right I mean it's not free and so basically the way that it works is that we have a manta token representation on Moonbeam which is an erc20 like token and this is the
contract of that erc20 Manta okay basically okay and I left the addresses here so that you can use it as a reference as well and then this is basically the I'm going to do a balance transfer as a demo and so for me when I was trying this application it was really helpful just to type it out here so I can just copy and paste all right but you know if you want to try it yourself you can put your address that doesn't really matter when I connect I mean I can do it from scratch but for the sake of time I connected metamask to it so I have metamask connected to my amazing decentralized application this is the account that I have on Moonbeam and you can see that uh the application actually calculates the
multi-location derivative account and it's displayed right here all right this is my super long multi-location derivative account on Manta which I control via xcm on Moonbeam okay I I don't know the private key of this account I have no clue what it is but I know that I can control it using xcm and so um I've put a lot of URLs right a lot of click here click here so you can check the code and use it yourself because I feel this is helpful for you guys if you want to build an application but basically this is how you calculate the multiplication derivative account you click here and you get into the code on GitHub I wanted to put it on the page but I I finished this 2 am last night so
um and then you have three simple buttons the first one is we're going to send a token transfer from Moonbeam to to Manta to my multi-location derivative account okay why because when we actually execute the transact on Manta this account is going to pay for for the gas fees let's call it gas fees uh on Manta right so it needs to have funds because if it doesn't have funds who's going to pay for it it's going to fail on execution and so this this action right here is necessary so we can fund our our next section okay if you do it one time with the million dollars you have to you can forget about funding it multiple times
but in the demo that I brought this actually for example funds it with 1.5 tokens or something like that and this balance transfer is for like one token and so it's very on the limit on purpose and remember when I told you that in mum you have a lot more than just a simple evm and this is one of the beauties that we have that it's not it's still quite used by developers to be honest but it's it's a way that you can badge multiple transactions into one transaction that you sign on metamask that exists on ethereum right now via multi-call but the difference is that you got to do it through a smart contract right so the caller is the Smart contract but on moomi you can have
a way that uh a new way a user with metamask Ledger whatever can sign a single transaction and then do multiple calls in one single transaction the Beautiful the beauty of it is that in this particular scenario right imagine that you have to ask a user to sign four or five that's a terrible user experience that's terrible and we got to start thinking about user experience right it's it's not great when you're like oh yeah I'm gonna play a game and then you have like bam five pop-ups six bubbles you have to sign sign-in transactions with the batch pre-compile which you have the code here of how you can bash actions you can just have one action and that's it you know and you can batch as many as you can fit in a single transaction per gas limit okay
so let me show you a little bit of the experience of the DAP and then we're going to go into the code uh just just a little bit because you know I don't want to bother with bother you with code but I'm going to do it manually and then I'm going to do it with a batch so if I click here you know again metamask I am going to sign it and then I'm going to go to if you have ever done polka dot stuff this is like your second home um this is polka.js apps substrate portal whatever they want to rename it to but this is basically like a Blog Explorer and like an a an interface for like polka dot based blockchains so you can see that I I have a message an xcm message being sent and then I transfer
some tokens to another parachain that is what this is showing me even though you know you just have to trust me on this basically so now um I am sending Alberto is sending some tokens you can see that this is the multi-location I am sending it to basically Manta and then down here you will see that I'm actually putting an account as well and then if I go on Manta I'm going to have basically an event which is basically saying hey you have deposited it this amount of tokens because I sent 1.1 but I have to pay for for fees um you have sent 1.1 tokens to this multi-location derivative demo right so this is the account that is derived from
Alberto on mumbim and only I can control it via xcm and I have funded it with tokens okay the next step in the DAP is to click this button here and then I am going to control that account right which I don't know the private key I'm going to control it uh basically from mumbim I just signed a metamask transaction and then what's going to happen is that you're going to see that this account that I have here which has 1.09 Manta tokens it's going to transfer one token out of it all right and it's going to get killed basically because of with something called existential deposit but what I want to show you is that I'm doing this completely remotely I am I didn't go into Manta and I executed the
balance transfer and do this this from right so if you if you build an application just think about what that means for your user experience it's a lot cleaner right so you can see once again in my Explorer here that I what I've done is basically I have withdrawn this for fees and then my multi-location derivative account transfer one token to another account that I had here it's called Alberto test and yeah and I did that from mumbi right and so once again moving can be the application layer and then Manta can be the execution for privacy stuff you don't have to do a balance transfer you can do a lot more than a balance transfer there I think I mentioned that I had a uni swap V2 swap you know from another chain and I also had and we also
have another example which is remote staking right so you can do anything that you can do on Manta itself you can actually do it from another another blockchain okay so now let me show you the experience of doing everything in just one transaction I mean it's not going to be mind-blowing because you already know what's going to happen but it's a single call you can see that I'm now calling us a different contract address which is a batch pre-compile and what this is doing is saying okay so I I know that I have to do this first and this second and I'm going to send two xcm messages on the same block which are going to get to months are going to be executed in that order order is important here because if I try to transfer without having the funds it's going to fail and then we're
going to have the exactly same effect but everything wrapped into one block a better user experience you know it's more efficient as well from from an application you know waiting time perspective of however you want to call it yeah we already have it here so this is basically the Axiom message maybe we can look into it just to understand that there were actually two xcm Majesty executed but yeah there should be two xcm messages executed we have the first one here and the second one here and at the end of the day it was basically the same the the same one this is a token transfer and this is a balanced transfer one as you can see okay um you can batch as many as you want I think we have no limit right now the only limit is the gas that you can you
can get and as you can see the application estimates like the the the the the tech let's say estimated gas for you right I mean where can I see this Market Advance edit you can see the gas limit here maybe too small but it's it's 107 000 gas units right so it's already estimated for you you don't have to worry about the gas limit that you're doing on this call all right um oops probably because I rejected it let's go a little bit into what part of the codes are we using here this is basically what happens when you click on the button X tokens right so this button
that it's sending the um token transfer from Moonbeam to uh to Manta right remember that this token lives on as an erc20 token but you're not going to call an an erc20 token method you're going to call what is called the X tokens pre-compile is is that the pre-compile that allows you to send tokens to other chains okay and so a lot of this code is going to be very familiar because this is all ether.js I didn't use any particular library or anything in particular I basically create a a an instance of the of the contract in another function you can go and check it out but it's nothing special using ether's contract blah blah blah passing the address ABI and bytecode and everything then I call this
function that I'm going to show you this is to get the call data so the inputs of the function I just put it for a cleaner sort of perspective I put it somewhere else and then I do a typical you know I have the contract instance here I just call the function with the inputs that are required the inputs are basically the the erc20 address or the the X what we call xc20 address the amount of tokens that you're transferring the multi-location that I showed you before is this like object that has parents and interior and everything and then you have the weight which is like the gas that you need for the call but in polka dot we use a term called weight which is instead of being opcode by op code it's like the execution time that it takes you can use
the one that I use as a standard if you were in transfer tokens it should work which is 4 billion picoseconds okay and then as any other ether.js thing you just grab the method you'll wait for it and that's it and you would actually get I didn't print it to be honest but you would get an ethereum transaction hash you can check it in moonscan which is etherscan on Moonbeam and everything would work as an ethereum you know experience if you go to the X tokens called Data you can see here that to get the amount I basically um call the the decimals function of a near C20 just to get the number of decimals
I had to do this like this because for whatever reason big numbers were not working for me last night so I had to do it like this which I'm just saying you know 1.1 times 10 to the decimals just to get you know the number and the way units or however you want to call it and then this is the amount that this is the weight this is like the gas limit that I was mentioning before you can use this as a constant and then here is how we calculate the the multi-location you can see that this is all comments me explaining how to do it but the actual multi-location is this which is parents all right this is a selector like I was explaining before parachain ID and then just four zeros plus the parenting ID to hexadecimal with a path star just to
make sure that I add the extra zero here and then this is the the second element of the vector which is an X2 which is zero one plus the contract multi-location derivative account and then the zero zero at the end right so you can use this as a reference it is explained there I'll be there outside if you have any questions or anything on how to build this multi-location uh in in in in JavaScript or typescript or solidity the next element I want to show you and it's very very similar is a transact right so the the button that actually executes the bytes of data in the in the other blockchain so once again it's very similar we get the instance of the contract we call excuse me we call a function just to get the elements that
we need to the actual you know function that we're calling on the smart contract and then we are wait for the transaction very similar to any ether.js deployment scripts or transaction interaction script this is where the meat is basically once again we need to get the amount this amount to basically how much money we're gonna put into uh buying execution right so we're buying execution to actually uh you know be able to to execute some functions and then these values you can use basically these values you can reuse that's that's completely fine these are going to work if it doesn't let me know but where the important part is is basically on the multi-location here here right this is
how you are saying hey I am targeting Manta as as where I'm I'm going to transact but also this is the the very very important part this is the call that you're doing on Manta in my case it was basically a balanced transfer a destination an amount and then you need to like I said before wrap it up in this method so that it it gets you bytes that you can execute okay so this is where you can get creative and do like I said before privacy stuff uh so that you can also do the the Manta Bounty basically but yeah um you don't have to do you don't have to get the call data like this this is not necessary Manta provides an SDK called Manti CK which actually return the bytes as well for you and it's
easier to use if that is something that you who you you would prefer this is just a way that I I do it but you know there's multiple ways of doing it okay uh let me see what I have here oh this is the batch so if you're interested in using it I feel it's great it's not super complicated at the end it's almost similar as the one before um we basically get uh the call data so we create the instances of the three contracts we create the call data of X tokens which is the one to send tokens we get the call data of the transactor which is a one to remote execute and then basically we use the same old same old like ether JS code where you can actually get the call data of of the
function so the data that you're trying to execute using encode function data providing the function name and the inputs and you do this for for both for the the one to transfer tokens and they want to to remote the transact and that's it basically then the batch is another contract you can see there's another smart contract in which you call the batch all function and then the batch all function it's it's basically has inputs right as as a smart contract normal smart contract nothing special okay but yeah um sorry if some of the comments have don't make sense I didn't check on them too much to be honest hopefully they do um so yeah this is how you basically batch transactions on moomim and it's
fairly fairly simple it's fairly easy and this is how you calculate the multi-location derivative account in this case in this case it's from a Moonbeam origin right so I have to be the origin has to be Moonbeam this is how you calculate it and this is how you basically return it it's it's all there in case you want to check it out like I said it's an on in the application that I built um let's go a little bit on on the bounties I think this information was shown yesterday but you know because we have time we can show it to you guys so yeah you can see a description of what movie Miss what Manta is but I think here is is what's important um the general purpose of the bounty is to create a privacy focused application that you utilize this movie as a
baseline application blockchain and uses Manta as a privacy layer okay um you can on the Manta you can use Manta pay the Mantis SDK around soul-bounded nfts so you know anything that uses privacy on Manta will will work um from moving perspective we'll judge sort of like how the application is built on Moonbeam and from the Manta perspective they will actually check the Privacy part of it okay um yeah the general judging guidelines is that we won originally an innovation user experience that's why I showed you guys the batch pre-compile provide a clean user experience I know that you have 12 hours but you know just just focus you know focus on that as
well technical complexity and level of completion because you know it might be not complete but anyways and you have a lot of like documentation because I'm here to be honest I would focus on the documentation on Manta right so Manta SDK Manta signer and how you can get this this month a call data I can help you guys on the Moonbeam side if you have any questions I am Alberto by the way if you arrive a little bit uh before after I started I'm Alberto and this is my telegram if I'm not around I you can ping me on Telegram and I I should get to you quite quite quick um so yeah I think at this point I don't have anything else oh yeah by the way okay so you might ask yourself how do you get
deaf tokens def is the is the token of our test net so it's like you know girly whatever RS called Dev token and you might ask yourself how do you get Manta tokens right because you need to pay for execution on Manta so I basically I think I have it on the yeah in the application forget about this error here but in the application at the bottom this might be too small for you guys but there's uh a faucet link here and then this link here will take you to a unit 12 V2 Fork that we created some time ago and then there's a pair of Dev tokens and Manta tokens so you know if you get some
tokens on the faucet and then you just say hey Alberto I want to say hey swap I want to put one Dev token you're going to get two Manta tokens I'm a whale so if you guys need anything I can shoot you as well so I mean that's fine this is just this is just in case it's like three in the morning I'll probably hopefully be sleeping and so you need some tokens you can get them there okay um actually actually probably put more liquidity on the Manta side so that you can get more tokens actually I'll do that after the presentation so yeah I've talked long enough to be honest uh are there any questions anything in particular any comment and yeah like
um xcm is it yeah okay so yeah what how come you have to use is it if it's not like you could use any token Brazil to Moon B correct yeah so I mean this is basically this was me yesterday at one in the morning saying how are you guys going to get Manta tokens right because I mean I could tell you yeah go to Manta and Bridget from Manta to mumbim right this is all tested by the way this is not doesn't have any value but this is like how we can create a faucet for Manta token so that you can guys play with on the Bounty and so um the way that parenting tokens are represented on Moonbeam are like erc20s right and because of URC 20s you can add them to like uni swap for example right
and so this is basically the actual Manta token that exists on Manta but I've I've bridged via xcm on Moonbeam okay and yeah I mean it's it takes like six seconds to do a bxcm so okay thank you yep any other questions yeah go on uh I was just thinking this isn't really a question but since there was a few people who just did arrive later do you want to maybe just share again the upper like sort of the top level yeah of that project
oh yeah yeah so I mean do you mean the DAP yeah I was just sort of like going back to kind of that that earlier part where you were just talking about like the general overview of what this project is oh okay okay like Journal if that's okay no that's fine because people came late yeah no worries no worries yeah so um okay so let me go back and by the way like like I said if some of you want to leave because you already saw this let me put this slide first so this is a QR code where you can get today's presentation in today's presentation you have a lot of content so yeah sorry about that uh here you have also the bitly link to the slides and the bigly link to the Google Doc for the Bounty information okay so if some
of you want to leave just because you know you already watched this uh that's you can get with this information I already see some people open it because you can see the logo here so um all right so and in here you also have like I said before the link to the DAP and in the dab you have a lot of like click here click here just trying to be helpful for you guys but yeah let me explain really briefly I'll skip some slides but uh the one slide I'll hand pick some slides okay so first what you need to understand is it's briefly how polka dot works right so polka dot it's um it's an ecosystem of parenting so blockchains right there's no one blockchain to rule them all there's no one perfect blockchain there's basically a layer zero blockchain that provides
security right and then all these other blockchains which are called parallel chains para chains connect to it and each provide something to the greater good to the ecosystem right so parent chains are nothing without the relay chain because it really a chain provides security but the real estate doesn't it's nothing without the para chains because a lot of people don't really know this but you cannot build applications on polka dot you can't it's not an application blockchain okay and so what that's why you need para chains and because it's architecture you have something called xcm which is a language for these pair of jeans to communicate with each other all right to talk under the same consensus umbrella which is great because if you think about Wormhole about axelr about all these
Bridges they are it's like one consensus the bridge consensus and then other consensus so it's like there is a weak point in that chain of consensus right in this case everything happens under the same consensus so if you're already trusting the polka dot consensus should be all good more or less so basically the idea here is that on Moonbeam you can interact with solidity as you saw before I can create an incremental smart contract or whatever but there's also a lot more to move there's also the substrate side the part that it's not typical from a gas implementation from an AVM implementation I was showing you you guys that you can batch transactions you
can do xcm calls you can communicate with other blockchains using a solidity interface right that's why I was signing with metamask for example and so the way that this works is that you have a series of pre-compiled contracts that they're all there in the application and they're in the resources that I've shared with you that are basically provide an interface with a series of functions that can tap into this more complex operations right so that's why I had a function called transfer which was actually transferring tokens to another parent chain it's not transferring the tokens from Alice to Bob which is this is this that's an evm thing okay and so pre-compiles are really powerful because that what sets Moonbeam apart or it's
like differentiates amount of all these like evm blockchains that exist out there we have a lot of custom stuff that are really cool and the idea is that you guys start exploring them there's a huge list of free compass I'm not going to go through them because you know for time um I was explaining here basically how Axiom works at a very high level this is not really mandatory if you want to go in the Bounty but as a curiosity Axiom is basically a message from a chain a to a chain B the message is a series of instructions that by themselves they don't do anything but the combination of instructions as to what the result in a given action okay the typical example I always say is that if you want to turn off the lights you don't just stand up
by itself that doesn't do anything right burns out a few calories but doesn't do anything if you want to turn off the lights you have to stand up walk that's another instruction and then flick the switch those are three instructions to turn off the light that's similar to xcm so you have for example four instructions so that you can do something on the target chain going back to this right the way that we present these instructions to you guys is through pre-compile contracts you don't have to type the instructions yourself you just call this function and that function will grab this five Axiom instructions and pile them in a way that you don't really care you just have to configure that put the parameters correctly but you don't really have to like know the complexity of the
instructions themselves so um I think this is probably the most important slide for you guys to understand is that the way that remote execution works on polkadot it's it's via once again this series of instructions but if you go into an example basically you have Alice on polkadot and she wants to execute some stuff on Moonbeam let's say she wants to call an incremental contract and increment the value by one right so the way she would she would do that is basically create an xcm message with some instructions that are going to use a transact instruction and it's going to provide some bytes that for polka dot despite doesn't mean anything it's like you know Chinese and then in
Japanese or Spanish and English whatever languages right they don't they don't mean anything to each other but if you you know grab that message in Spanish and go to Venezuela my country and you you say it out a lot of people are going to understand you right so that's that's how Axiom works you grab the bytes you put them in in the message and then when that message gets executed on mumbim despite means something they're like go to this contract and incremented by one okay and the way that this is executed is through a special dispatcher called the multi-location derivative account and this is basically the message in the context of evm is the message sender all right because Alice on polkadot doesn't really have like an account on Moonbeam
and the way that this works is that we create an account for her via this special mechanism called multi-location derivative account and the way that this works and with this probably I can stop for some questions as well is that imagine Alice you don't really care what type of account she uses you don't really care what hashing mechanism or cryptography they use you don't really care maybe it's not ethereum compatible right but if you grab something called the multi-location which is a way to represent things in polka dot right in general you can represent my shoe if it would be on the blockchain um you can actually hash that multi-location because this multi-location is unique to Alice and
polka dot okay if Alice exists on on another blockchain let's say Manta the multi-location will be different and so if you hash the bytes of that multi-location in the case of mumbim you cut it to 20 bytes because ethereum accounts are 20 bytes you you have a analysis derived account which is now ethereum compatible right the long the length of the account is now ethereum compatible as well and the hashing that we use is blade256 and so now Alice once again Alice has an account on boombeam which she controls only via xcm she doesn't know the private keys of this account it's keyless okay but the important thing is that when she sends an xcm
message with some instructions she can actually dispatch code from this account and because she's dispatching code from this account she needs to have some money on that account right because if you're gonna dispatch a contract call on on the evm you need to have money to pay for gas exactly the same concept okay so that is why in the demo that I was showing you guys the first action that I was doing is transferring tokens to my multi-location derivative account so I can pay for the stuff that I'm going to do later on okay um I don't think this is important to go over these are multi-locations explained uh this actually was in our Workshop that we did on December I actually explained them as well if you want to
check that video out or I am here if you have any questions and last but not least uh well I'm not going to go through this as well I think this is more or less well explained on the on the comments but this is how you build multi-locations on for example the adapt that I've created for you guys uh this is how you you basically feed them into the the smart contracts that allow you to do x-stoke it's like transfer tokens to another parent chain or remote transact okay so this is how you would build those multiplications basically um yeah and this is how you created the transact data like what I was saying before um let's say you want to do you know a balanced transfer on Manta you need to
have the bytes that represent balance transfer on the Manta language right and this is basically how you do that you you create the API which is like the the web3 provider in ethers and then you put dot TX because it's a transaction that you want to do and then you put balance transfer which is a function that you want to invoke okay with this inputs right this inputs can be anything but basically this is what I did for this example and then using method to hex is how you get the call data so the bytes that represent something on Manta and this is what you feed into the contract basically and yeah what I was showing and I think by then you were here already is this application it's xcmo.num.netlifi.app um this application should help you get
started on the on Bounty because you only have a few hours so you know you can use it you cannot use it you can whatever you want you can Fork it it's it's a GitHub repo I think the code it's here at the bottom Yeah the code is here at the bottom if you want to use it or Fork it or what there's already one fork you guys are quick but yeah um yeah like I said I well I might some minor changes lately recently but you know you can use it you can ask me questions I know it's it's a lot to digest because this is very different to like a typical ethereum application but yeah this is the point of hackathon uh I'll be here to help uh I'm sitting in the the booth there with the moving logo and the polka dot logo and if you have
any questions on the Manta side even though they're not here uh Georgie is active on telegram if you have any specifics about the Manta SDK I think his contact should be in the Bounty sheet here at the bottom is GoGo mgc so basically uh Georgie and I are the people the the couple of people that work a lot on this so that's why you can ask us if any questions and yeah I'm happy to answer any other questions here that you might have or if not we can just meet in the booth is there any other question at this point no go for it uh yeah well some examples of what you
could do on Manta I should probably take my Manta t-shirt here and I was just kidding no but actually because I work with them for for so long on this is uh you can do you know like the typical things like private private payments right so you can bring your public assets let's say you know I bring my death tokens on Manta I can privatize them right I can create them as a private asset and then I can do a private payment right I mean remember that privacy um I'm not an expert I might be shooting myself on the foot here so sorry if I make a mistake but you know even though all the movements that are traceable on Moonbeam um and they're going to be traceable when you send them to Manta the moment that you put them on the Privacy layer that sort of link is lost right and so
you could then you know send it around do whatever you want and then when you take it out of manta you know as long as you do it in a sort of like you know genius way because if you put 1.2345 and then you take out the same same amount it's going to be probably traceable but if you do it in a way which is not traceable even though you move your money back to a public Ledger blockchain like traceability is going to be lost right so at least you have still you can conserve the Privacy even though you go back to a public Ledger blockchain like movie um I know they're doing a lot of stuff on SP sbts and I learned about them like a week ago so like I said I'm not a privacy expert but this sole bounded nfts and so you could also mint these
nfts on Manta from mumbim using this keyless account which is pretty cool right because you could create um experiences that are based on on this ethereum based blockchain application layer like Moonbeam but they're using privacy powered by another protocol basically via xcm so I think these are the two things that are there they have been quite big on basically this Manta pay or this like private payment system and the sbts so yeah I would say probably focus on these two things from the bounty anything else you would have to ask them to be [Music] cool yeah so thanks a lot for attending um like I said I'll be around uh so yeah
ask me any questions how you have for the Bounty so thank you [Applause]