New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

1inch 🛠 Building Dapps with 1inch Developer Portal

ETHGlobalMon, Oct 9, 2023, 12:00 AM

Join Nikita Kozlov for a workshop titled, "Building Dapps with 1inch Developer Portal". Some of the most skilled web3 developers, designers and product builders from all around the globe came together for a weekend-long hackathon at ETHGlobal New York 2023. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

foreign [Music] developer from one inch and today I'm going to talk about vanish developer portal and before that let's do some small recap maybe someone don't know what is one inch and I just want to say okay I just want to say that money she started at a few in New York four years ago as a hackathon project and I was there as well like at the same sitting me the same table with the co-founders they're not here right now but they're always happy to support ethereum Global and every hackathon of Developers and over over the last four years we have right now about 4 million users we have 55 billions of total available liquidity for Traders we have more than 350 billions of dollars of volume and we have about 70 of aggregation market share right now yeah and over this years we developed several protocols and services for developers the main one is aggregation protocol of course we do have a limit order protocol as well we do have Avalanche Fusion the latest our invention that allows you to trade with Dutch auction enabled and also we do have a non-custodial G5 wallet available for all mobile platforms and you do also have a developer portal what I will be talking about right now so a small recap about aggregation protocol so aggregation protocol allows you to make a swap with unit swap like experience but inside one Atomic transaction we have the best trades on the market even if you're doing that with API or with the user interface is still the best solution on the market right now according to analytics that we have here as well uh vanish always have open source and traceable analytics over all protocols and but you can also always check this out what numbers do we have by just checking june.com one inch so okay let's start um actually recently we considered what kind of we how we can we help Builders to continue building on us maybe what else we can provide for developers to simplify the experience they have with one inch and we decided that maybe it's a good idea to build a developer portal um actually it says it's a camera of every all solutions that we have right now we have multiple apis that we are not available publicly for their hackers but right now we opened most of them and we've developer portal currently you can use almost anything that manage have developed over for years for our non-custodial wallet and for our G app and of course we do have aggregation protocol and limit other protocol and fusion available there as well so it looks basically like that if you want to try try it out I will have a link soon and the only requirement for you is just to have a registration and by default if you have an identification token that will be having the limit of 1 RPS per second and you can freely use any API that is available there with documentation portal um for example if we'll try to use aggregation protocol I've only just wanted to recap how it works the basic integration is pretty simple you do have two handles that you need to quote to start to make a transaction first you need to make a quote we'll call a call quote handle with three parameters from token amount two target amount and address and amount of the token that you want to swap if you're okay with the returned amount that you will get basically you need to continue and call another quote called swap it will actually build a call data that you will need to execute on your own on your own address on your own like wallet by calling the one inch router smart contract directly so you can try aggregation protocol via Advantage developer fertile instantly right now if you want to check if you want to check it out there is a shortcut for it and I just want to show how it looks like how you can try it out um so for that we basically don't need anything except have been registered on developer portal already and we do have a Swagger here um let's wait until until it will be downloaded so uh we do have multiple handles there but this is the main two handles that you need to use if you want to play with aggregation protocol the first one basically allows you to get a quote so let's just use it in this example we will have a native token swap right to the one inch token with the amount of I think 0.1 ethereum so let's take a look what will be the rate that you will have okay we got it so this is the two amount that you have for the one inch token we can actually calculate what will be the return um if you'll just make it not in the very amount but in the in the killer edible amount one second okay looks like internet doesn't want to to be my friend today okay let's continue on other apis that we have on developer portal so uh compare adding editing the API we added miles much more apis developed proposal compared to aggregation protocol and the next interesting one is actually spot price API and this API allows you to get any token to Native token and to USD and any other fiat currency price rate and you will get it in the batched amount so the problem that we want to solve actually is that we need to get some somehow we need to get rates via trades of almost every token that we have on the market to basically users always compare any amount of the field amount and we need to get updated prices of them and if you'll try to use Pathfinder in such case it will be very resourceful and but we still need to use something for that the progress that we have is that it must be really up to date because if you it will be not up to date during one block transaction the price can significantly change and in such case users can lose money and will not usually can't make a trade in such case for example and this API is actually used almost everywhere on our front end on our G app on our wallet and what this allows to you to do is basically get price of almost any bunch of tokens we're almost with the real time precision and it's actually based on open source of spot price Oracle that is available on our GitHub our spot price Oracle actually allows you to get via like native token price and finding a token based on Smart contract that actually Aggregates the prices of every unit swap pool that is available for any Con on any token on multiple networks or uniform like protocols so you got press transparent pricing model for every token that you need to get as a price one more API that we have there is a balances API we also widely widely use it everywhere the main feature of the balancers API is that you don't need to call not RPC directly and you can use batched requests so basically you don't need to make a thousand requests per thousand tokens you just need to make one request and it will do all of all for you uh we're using one inch multi-call operation there and it's pretty easily available on the news developer portal so you don't need to care about other PC services for example if your app have a cross chain support you need to take care about all Every Chain another PC and it's quite resourceful on developer portal you can just use it and just change the parameter of the request so yeah multi-chain low latency and one API call for getting all the balances and allowances at the same time and one more pretty simple and nice API that we have it's called token API that allows you to search over tokens by querying so basically you have a text search uh over all your adventure tokens over all networks that we do support it's about 11 evm networks right now and also you can get images and everything that you need to display for user as a target for the tokens we use it on the front end on our G app as well and we do also support unit swap token least standards so we do aggregate multiple providers of tokens so if you want to switch between multiple providers of unit swap token least you could make it with this API and we do have a small racing system inside so when you do a search we actually so we actually provide a filtering and we provide like search but depends on the amount of depends on the rating of this token and the rating of this token is actually amount of uniform token least lists where this token is actually available so that means that if we show for example searching for other token this token is quite popular and it's almost available on every token list so it will be on in the top of the results and last but not least we have a portfolio API it's uh API allows you to get your trading portfolio with CBL with a lot of new features uh it's small some small prerelease that we'll have soon uh the best of it is that we have a fantastic charge for any talking to any other talk in multiple networks with very nice precision and granular granularity all the data is taken from on chain so basically it's pretty accountable and right now I have a small examples funnel runs how you can run all these apis on your video notes if you leave your code you're using using node.js for example so this is the link for the one inch developer portal 101 if you want to try it later on your own uh just download this Reaper and there are only two requirements that you need to have there to run it is basically um it's available in the config the only two requirements to run it is to have your private key available for the swaps if you want to make a swaps and after authorization K available authorization key is free so you need you can get it on developer portal and the private key I think you know what this is so uh let's let's let's play a bit so I decided to make some user flow with all our apis how we can build a small G app I am a back-end developer so I decided to skip on front-end part so let's let's trust open the eye and someone else to build a frontal later so let's try let's imagine that we have a user that is trying to search something over like our input so for some tokens let it be for example one each because they just somehow went up on each website so let's try to run a search using tokens API for the search and yeah I will check out what will be the result so we have a search result here for the tokens of an inch so as you can see the vanish token is on the top list so we have some sort of it so like sorting of every token based on your text query and um basically I made a wrapper over our apis if you want to see how it works it's pretty simple it's basically HTTP requests and almost nothing else the it's pretty it's simple as I can it's really hard to imagine how even more simple it can be it's basically API request to our developer portal we've basically passing the parameters that you have from the Swagger in such cases just passing the query there for the text and also chain ID I made it a bit simple so if you want to try to use anything of that you can just copy these functions and um that's almost it really need uh to like to use this API so as you can see we have some search results of vanish tokens and just wanted to demonstrate that right now you can get not all we can we can take a look on vanish token what it what is inside so we have name symbol log URI so you can display a picture on your front ends for example and we have a list of providers so uh it's a providers are actually talking lists that are available with such token that such token have and we can see that we have a vanish token list in the top of it so let's try to continue and grab a total list of some providers in such cases there will be one inch token list so I already make this request so let's let's wait until we'll get a total list upon inch and here we are we have a token list by provider uh these tokens have this technology is the sender took a list of by by standard of uniswap so you have a group of tokens it's about a thousand tokens that vanish the support on the interface by default and let's imagine our user right now sees a lot of tokens so user wants to get information what is the price of some tokens here let's imagine that our user speaks some of these addresses and want to get a Fiat price of these tokens so for that we will need a spot price API let's let's try to run it and this is like basically the example how you can run a spot price API it's almost as simple as token API so basically it's a wrapper over one get method that allows you just to pass a list of tokens and versus cars you want to gather rates so now I guess there will be some tokens from one each token list so let's try to run it I'm sorry uh let me turn off the tokens part oh debugger something goes wrong with the debugger let me just play it so I will get a lock unlocks of it so here we are uh we do have actually the prices returned for this bunch of tokens and this is actually the Fiat prices of these tokens uh uh basically okay user x-ray now knows about our USD prices and let's imagine that our user wants to continue on this deep research and if no user is get interested in one of them and want to get a historical price of some of some tokens by getting by using a chart API so let's try to get the chart it's historical chart of some token versus USD tokens to make a technical analysis charts for example for such user and for in such case we will use charts API basically and it's it comes from portfolio API I will show you a wrapper over it it's almost as simple as everyone else everything else so it's here and the only requirements here is just chain ID token in versus currency it's almost simple as everything else so let's try to use the chart bi right now to get some information about historical prices of this token that these are already found okay so we have some candles I don't want to visual visualize that via the console but as you can see we have some price movements here and let's imagine that our user right now do perform very nice productive technical analysis and this user wants to trade this token uh via an inch API and let's try to trade this token so to make it possible to make a trace we will need to use aggregation API and to make so for that we first need to have some preparations so before we make some preparations we need first to get our balances so we need to understand what is our balances on our address that we have from the user and for that we will use balances API the balances SPI is also as simple as everything else to use the only difference here between these two wrappers is that you can either have balances and allowances together batched via one call so you just pass address and list of tokens and it will get allowances and balances of every token for this address leave the spanner on it if you will also pass a spender for such uh for allowances in this in our case it will be one inch token or an inch rotor address so before we'll we'll try to perform a swap we will firstly need to get to make approval on the one inch router smart contract and if you want to make approval you first need to check that the user needs to have some approval like does user already have approval or not so let's check that we have some approval on it or not I will use a get balances and allowances and and in my case I will have very shorter smart contracts as a spanner address of my private key that they have in any variables and the network will be actually ethereum Network authorization K I have the config and we will try to get a balances and allowances of several tokens it will be one inch token it will be usdc usdc coin is the same on binance machine and inferior so I just hardcoded it for wireless blockchain here sorry for the naming and for the abrupt ethereum token so let's execute the balances here one second okay so we have a balances as you can see it's a key value result and for the vanish token we have a balance this one and we have this one alone so it looks like it's okay and we for potentially for example can trade for one inch token to any other token and we already have allowance for this address if you don't have it we I also do have a script here nearby to make a proof it's just below here and I think I will skip it to the photo for now because I want to continue on other interesting apis but you want to try if you want to try uh to use you can you can just use it with arguments true so let's try to make a firstly a quote and if the quote will be okay for us we will make a swap from one each token to for example let it be let it be developed if I'm talking that user user actually was doing research okay okay let's try to perform a swap I don't have a I'm a bit out of time so let me just to continue to the swap with this API so we just perform it so in our case we will try to swap down one inch tokens to some amount of raptiferum let's imagine we already quoted the code API and we got some results so this is a transaction hash that we have let's check that we have its uh like we had this transaction and other scan so here we are we try to use aggregation rotary character swap some unleash tokens let's wait until it will be executed basically see the information about the swap here oh I think my transaction stacked a bit but uh one more one more point one transaction will be executed we already have a transaction hash and what if I want to get information more information about the my transaction hash by the window section hash like how it was executed for such thing we can continue to do we use one inch API and use manage traces API and using demonstrations API we will get information about the trace about all events about all logs calls everything potentially that you need to debug and analyze the transaction you can build almost anything on that if you are familiar with transaction phrases you can you know that it's extremely hard to get traces of almost any transaction of almost any block and manage developer portal provides traces API that will have almost zero latency and will be extremely reliable and fast to get traces of almost any block from Genesis to the current one for multiple chains for eight wheel evm chains so I don't have enough time to wait for the transaction to be executed so let me just show you example how the trace looks likes and I'll finish so as you can see the block Trace is uh something like that it's basically the transaction Trace not the block Trace but you can also use a block Trace in such case and we do have a course here that allows you us actually to see information how our transaction was executed what was the storage operations here and using all of this data basically it's much more easier to build analytics and basically if using using transaction phrases API you can build your own indexer and even though the only requirement for for you is just using one like traces API instead of running your own arrival nodes which is which is much more easier especially for the l2s so I think that's it so thank you for your for your attention

Automatic transcript — names and jargon may be misspelled.