OKX 🛠️ Getting started with X1
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
OKX has launched X1, a ZK-powered layer 2 network that connects the OKX and Ethereum communities to allow anyone to take part in a truly global on-chain ecosystem. During ETHIndia, you'll have an opportunity to build on the X1 testnet and build with the latest Account Abstraction technologies. Hack with some of the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem at ETHIndia 2023! Find more about OKX's participation at ETHIndia: https://ethglobal.com/events/ethindia2023/prizes#okx ----------------- Follow us: https://x.com/ethglobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
[Music] hello everyone my name is diit login and I'm a senior software engineer at okx and today I will introduce X1 to you after the introduction I'm going to present more details about the technology behind X1 some of the developer tools that you can use and at the end I am going to show you some useful contexts what is X1 X1 is a zero knowledge proof based layer 2 Network which is built by okx using polygon chain development kit or cdk for short it's a layer two Network so it inherits the security of the underlying layer one which is ethereum it provides EV evm equivalence this means that your your smart contracts that you develop for ethereum layer one they are also being able to be ported to X1 and you can also use your favorite development tools for example remix ID trle hardhead web 3js to develop applications on X1 what set it a part is that it uses okb as a native token on layer to pay for the gas bees and also it has quite high performance for example more than 100 transactions per second at the sequencer side and more than 10,000 queries per second at the RPC side and I'm going to introduce this components later so being built by okx it has seemingless interoperability with the okx ecosystem including the KX wallet okx Dex okay link and so on it has very low gas fees and this is because X1 is using the validum mode with data availability nodes to store the bulk of the transaction data of chain and I'm going to tell you more about this mode later xon also provides a free bridge system this is to allow users to bridge their assets on L1 to L2 at no cost and also automatically so X1 is built using polygon cdk and as you can see on this slide polygon cdk has some um advantages compared to the competition in particular it supports Validia mode and it has state-ofthe-art Z knowledge proof technology so what is the validum mode and here I'm going to compare it with the widely known rollup mode so in the rollup mode on Layer Two we have transactions and we generate zero knowledge proofs for these transactions and we put both the bulk of the data uh of these transactions and the zero knowledge proofs on layer one uh in this case ethereum but uploading this data to layer one requires significant guess so it end up being very costly another model is the validum where we don't upload the bulk of the transaction data to L1 instead we store it of chain on data availability nodes that are governed by a data availability committee and we only put the zero knowledge proof and the headers of the transactions together together with the signatures of the data availability nodes to layer one this will reduce significantly the gas cost and makes the validum mode more scalable and more affordable let me show you some details about the technology behind X1 X1 is using um modular architecture that is highly scalable and can be implemented using microservices for example we have a Json RPC service that uh interacts with the users we'll take the the users um RPC and save them to the database for example then we have a sequencer that produces blocks of transactions and batches of uh blocks one once we have blocks of transactions the ZK evm executor executes them and updates the state database and as you can see here this uh database service is a core component of the layer two it's connected to many of the other services it provides for example the transaction pool database State database events database and so on we have the synchronized that listen for events on layer one and uploads them on on the database service and uh bridging of assets from layer one to layer two that I talked previously uh is done using this uh synchronizer service this will allow us to have automatic bridging of ss from L1 to L2 next once we have batches of transactions the sequencer will push them to data availability nodes and also tell the aggregator to start creating zero knowledge proofs for the batches the aggregator will create tasks for the approver and the approver will be the component that actually computes the zero knowledge proofs for the batches of transactions once we have these proofs we upload them on L1 using the ZK AVM contract in addition to this contract on layer one we have the bridge contract and the okb contract so in in regards of the zero knowledge proof technology behind X1 we use the state-ofthe-art polygon ZK Pro and this component takes batches of transactions and generates the zero knowledge proof for them but first it execute these transactions using um an Executor that consists of a main State machine executor and a collection of secondary State machines for other components such as the stack and uh different hashing mechanisms we have then the the proofs that are Stark proofs and then we combine them recursively into a lower number of proofs until we end up with a single Stark proof and then we take this proof and transform it into a snark proof and put this snark proof on layer one and why we do that is because snark proofs are smaller in size and Al also easier to verify on L1 and this will further save guess this diagram shows you more details about the process that I already mentioned so we have batches of transactions we generate Stark proofs we combine them into recursive proofs and in the final stage we end up with a single Stark proof we transform this into a snark proof and upload this snark proof on ethereum layer one next let me show you some of the developer tools that you can use to start developing applications on X1 you can use okay KX wallet this is a non-custodial wallet that will provide you among others asset Auto detection multiple chain support including popular evm chains non evm chains also Layer Two Chains um it's web3 native fully interoperable with the apps and also it supports Hardware connectivity this means that you can connect your Hardware wallets we also provide support for okay link which is a worldclass multi-chain blockchain Explorer and this will allow you to search for useful data such as addresses tokens prices and transactions and for example you can connect your D app to okay link using the API uh you can do onchain analysis and also uh audit your smart contracts in order order to ensure that they are secure enough we provide an oracle X1 Oracle this will uh provide developers pricing data and also verifiable Randomness functions and of course we also provide faet uh this is to help developers test their applications right when they test their application they need some uh tokens on the test Nets we provide an X1 seoa fet and you can generate for example uh test okb tokens in order to test your application and I'm going to show you how to do that later to stay up to dat with all the news regarding X1 uh you can join our Builder Community by scanning this uh QR code next let me show you the documentation of X1 for this you can use your browser and go to this address okay x.com slx1 you should be able to see this page then click Start building and here you have uh some useful documentation for example what is X1 build on X1 deploy smart contracts and this is of interest to us but first we need to set up our wallet so under user guide you can go to set up wallet and for example we support the okx wallet metamask particle network of course we highly recommend using the okx wallet which is a very powerful rep3 native non-custodial wallet and I'm going to show you later how to install and use the okx wallet and in okx wallet you already have the X1 test net configured you just have to select it on other wallets you may need to configure the network information manually and you can find it here right for example network name is X1 testet RPC URL L chain ID token symbol is okb as we mentioned before and block Explorer okay and you can see here more details including how to set up uh metamask right so we have Network information the one that I already mentioned to you okay uh we currently we have the test net online uh X1 main net will come later foret right we can get U test net okb from the foret and also we can Bridge test net okb from seoa test net this is on layer one 2x1 which is Layer Two and we also have here on how to bridge assets from seoa to xon testet step by right and Below we have other links to GitHub X Discord and so on now let me show you how to install the okx wallet in uh Google Chrome for this we go to extension manage extensions and we go to Chrome web store and look for okx wallet okay KX wallet then we click add to Chrome okay and now it's added to Chrome and we can pin it here now let's open the wallet we click here and of course we need to create a wallet with SE phrase we will set up a password make sure you set up a strong password we can set it as default also and then we are able to start our rep journey of course it's recommended to back it up I'm not going to show this step you can do it by yourself later and we can select the X1 test net if we go to test net we can already see X1 testet and okb as a native token so now we have our wallet installed okay X let's spin it but before deploying smart contracts we need to get some uh okb tokens so we can go to X1 website start building and we go to foret to get some test net okb and we have the documentation here let's click the link we can connect our wallet by clicking here connect wallet we approve it in the wallet okay now it's connected so we can get some okb and indeed this is our address we can check right in in uh our wallet and let's switch to the X1 test net okay so that we can see our okb tokens later we press get we need to complete this puzzle okay and we should already have 02 okb we don't Bridge it for now and indeed we see in our wallet we have 0.2 okb so now we can start to write a smart contract and deploy it uh let's use the remix ID this would be like remix we can search on Google for example it's remix.ogg let's create a new workspace with uh widely used erc20 smart contract template rc20 is for fible tokens let's make it it uh minable and we have the code here uh we can go to the source code my token. it's in solidity of course let's change the name let's call it my awesome token and here M8 okay and now by default uh it has a denomination which is 10 the^ of minus 18 so when we meant right we want to see some uh meaningful value okay so let's multiply the amount here by 10 to the power of 18 okay we can save and we can also uh compile our code it compiled successfully and now we go to the Deo deoy and Run tab so here is where we need to connect remix ID uh with our wallet and then on X1 test net so let's connect it to the first connect to wallet and it should already detect that we have the okx wallet installed and we approve this connection and we can see here our address right even under this tab uh under account we can see our wallet address here now we are still on the main net so we need to go to the wallet and change this so for example uh under the connections remix ethereum.
org manage and we should change here the network to X1 test net for this we can search X1 we found found it okay so now uh it's connected to our X1 test net and indeed we can see here that we have a custom Network and this is the ID of xon testet uh 195 so now we have our token contract let's deploy it using our address so let's copy our our address under initial owner transact and this should open the wallet right indeed because we need to pay the gas fee we confirm and it's already deployed we can see below here under deployed contracts my token was deployed at this address 0 x 86d and so on okay now now let's minan some tokens but in order to see them in our wallet we have to import this tokens so we go to we go to our wallet right and then under manage crypto custom crypto we should introduce the address of our smart contract and indeed the the wallet will automatically take the symbol and decimal points we confirm okay then go back to to our main screen uh for now we only have zero of my awesome token so let's mean some for this we copy again our address and we go below under mint okay to our address and let's say we we Min 15 uh tokens transact this again we required to us to pay get the guest fee confirm and we should already have them let's check indeed we already have 15 uh mat my awesome token of course we can also interact for example owner this one should return our address okay let's check again indeed it returns our address now let me show you how to use web sockets and again we should go to X1 documentation under developers build on X1 websocket endpoints okay you can read here and we can try it out by installing this uh WS tool with go and then then connected to X1 websocket endpoint And subscribe for example to events such as new heads right this one will give us new headers so let's try it out we first install this tool okay we should have it already indeed now we connect to X1 end point okay and now we subscribe to new [Music] headers this is successful now we should generate some activity to get headers so for example we can go to the foret and get some okb and we get some activity here now let me show you how to use the bridge to bridge assets from L1 to L2 we go to the documentation getting started Bridge and we can read here more about this bridge and how we can Bridge assets so let's go to the bridge web page and for this we can connect our wallet the okx wallet okay and we are going to bridge okb tokens from seoa test net which is on L1 to X1 test net which is Layer Two but before that we need to have some okb on seoa test net which is um L1 so for this let's go back to our X1 web page use faet to get some um okb tokens on sepolia okay we click here and we can get a maximum of 10 okay let's mean one thing to mention here is that in order to use this poset you need to have some uh sepolia eth in your wallet right and you can get this using third party faucets such as the Alchemy faucet it's quite easy to use you just need to create an account log into the account and then uh mean some seoa eth okay now we Min it 10 okb on L1 okay we add the token to our wallet then we we should be able to see it in our wallet and indeed we we have it here we have 10 okb on L1 and now let's Bridge Okay um we have to select here okb and the web page will automatically detect that we have 10 of them in our wallet okay let's say we only want to migrate five then we press Bridge okay and we need to confirm this and of course we need to pay the guest fee on L1 but only on L1 on L2 we don't need to pay the the guas fee it's um automatically paid by our platform and uh we need to wait a bit uh estimated waiting time is 15 minutes now the transaction is done we can see it here now let me show you how to use X1 Oracle for this we go to the X1 documentation go to developers and we have Oracle here with price feed currently on the test net we provide price feed API and uh we have some examples here we have a code example and I'm going to show you that this one is working so for this we go to our remix ID the same contract as before my awesome token we'll just add this functionality and try to get the price of the okb token okay so for this we import this interface we add it to our smart contract here okay after that we also need this these two functions I'm just going to copy [Music] them and add them to our smart contract here and we finally need the Oracle address so for this I'm just going to copy it from here okay and add it here we have an error here let's fix it we should have the address properly formatted okay now the code compiles we just have one warning but this is not so important the one thing we need to change is that we we want the okb price so here we'll input okb token symbol okay so the code compiled now let's deploy it but for this we need to connect our wallet so we go wallet connect connect the okx wallet and we are indeed on X1 test net 195 is the ID of this test net okay and we want to deploy my token we will use our address and deploy it for this of course the wallet should be shown in order to confirm the transaction we confirm it and we already have the deployed contract here now when we expand this we can already see that we have this method called get okb price let's try it out and we already have some response here if we expand it we get the value which is 5601 6571 is actually 50
Automatic transcript — names and jargon may be misspelled.