feeds.chainlinkInterfaces & Price Feeds Ultimate Web3 Solidity & Javascript Course Lesson 4 Pt. 5

vechain • Instagram photos and videos VechainThor is the leading enterprise-tier L1 blockchain, delivering the sustainability revolution from a low-CO2, scalable smart contract platform. Voting has 50.000 Dollar monatlich mit Dogecoin-Mining verdienen Dogecoin Mining kann dir einen Traum erf ;llen. Mit professionellem und zuverl ssigem Mining, kannst Du bis zu 50.000 Dollar im Monat gewinnen! Wir werden Dir zeigen, wie Du anfangen kannst und feeds.chainlink Interfaces & Price Feeds Ultimate Web3 Solidity & Javascript Course Lesson 4 Pt. 5
feeds.chainlink Cardano Founder Proposes His Version Of A Decentralized... Interfaces & Price Feeds Ultimate Web3 Solidity & Javascript Course Lesson 4 Pt. 5
now in order for us to figure out if our message.value is actually greater than the minimum usd that we set we actually have to convert our message.value from its layer one slash ethereum to the usd equivalent so how are we actually going to do that well first we need to get the price of ethereum or phantom or avalanche or whatever layer one blockchain that were working with so lets create a function to get that price to get that conversion rate so well do function get price and this is going to be the function that we use to get the price of ethereum in terms of usd so we can convert our message.value to usd and then were also going to do a function called get conversion rate these are both going to be public functions so that we can go ahead and call them and test them and do whatever we want with them so in order to get the price were going to have to use one of these chain link data feeds to get the pricing information and we can look right here at this contract to see what using one of these chain link price feeds looks like what were actually doing when were interacting with this chain link price feed is were actually reading from one of these contracts theres a contract out there called the aggregator contract that is a function called latest round data which returns a whole bunch of data but namely this int price and this end price is what we are interested in lets look at our get price function and figure out how do we actually call this since this is an instance of us interacting with a contract outside of our project were gonna need two things what are those two things were gonna need the abi of the contract and also the address of the contract so the address of the contract is going to be easy we can get the address of the contract from the contract addresses section of the chain link data feeds lets scroll on down to rink b and we can find the eth usd address on rink b and well create this contract so that it works on rink b so were going to grab this address were going to copy it and were going to move back to our to our code here and were going to paste the address here so great we have the address now we have the address of the other contract that were going to want to interact with now how do we get the avi well what we did before with simple storage was we imported the entire contract into our code here thats something that we could do but thats actually a lot of code so whats something that we could do instead remember if were looking at remix and we look at one of the contracts that we compiled before the api is really just kind of this list of the different functions and interactions you can have with a contract the api itself doesnt actually need to include any of the logic it just needs to include hey here are the different functions that you can call for example in this contract we can call fund we have get conversion rate we have get price theyre not implemented yet but they will be eventually now there technically is another way to interact with contracts without the abi but for now were just going to ignore that so how can we get the abi theres a concept in solidity called an interface and lets look at an example of an interface if we go to smart contract kit chain link we can see a number of different contracts in the chain link repository we can go to contracts src v 0.8 interfaces and well go to aggregator v3 interface dot soul and if we look at the solidity in here we can see a whole bunch of function declarations but none of the logic is actually implemented in this this is whats known as an interface if we compile this well actually get the abi of a contract because it defines all the different ways we can interact with the contract it doesnt actually say what these functions do which is fine though because we dont need to know what the functions actually do those are going to be stored in the contract so what we can do is we can grab this interface from the code and paste it into our remix now hold on if youre following along you dont have to copy paste this with me because im going to show you an easier way in just a second so for now feel free to go ahead and just watch but once we have this interface aggregator v3 interface we can now use this to make api calls so now we could say aggregator v3 interface at this address and the combination of these two give us that aggregator v3 contract with whatever code is here if at this contract address this aggregator v3 interface is valid we do something like dot version lets look at this interface is there a version function there sure is so that means we could call the version function on this contract so lets actually go ahead and copy this into a different section im going to create a new function called get version just to illustrate this its going to be public its going to be a view and its going to return uin256 and were going to split it up into two steps here but were going to say aggregator v3 interface price feed so were creating a variable of type aggregator v3 interface equals aggregator v3 interface at this address and then were going to return price feed dot version now im going to go ahead and deploy this contract to rinpy just to show you what this get version is going to return but you dont have to follow along here if you dont want because again were working with the test net you can just watch if you like for this section we are going to test a little bit more sparse since were going to be mainly using the test net since were going to be working with an actual chain link oracle network once we move over to hardhat and with javascript all this testing locally will be a lot easier and a lot faster youre more than welcome to go ahead and fiddle and try and test a lot of the stuff as we go along but just note that it might take a little bit longer to do some of the testing on a test net lets delete that last funding contract were going to deploy this one were going to scroll up were going to switch to injected web 3. were going to switch from coven to rinkby and the reason we want to make sure were on rink b is because this address is specific to rink b the contract that were looking to interact with might not be at this address on every single chain we want to make sure were on the rink beat chain for this because if some other contract is there on a different chain this version function obviously wont exist and this function could err so lets go ahead well go to fund me were going to deploy this to the rank b chain again you dont have to follow along with me here you can just watch and once that contract has been deployed we now have a view function called get version and we can see its returning the variable four showing us that this is the fourth version of a price feed so this is a really easy way for us to interact with contracts that exist outside of our project we use one of these interfaces which can get compiled down to the api and then combine that api with the address to call a function as we work with these interfaces more and more theyll start to make more and more sense so if its a little confusing to you right now dont get discouraged the more you work with it the easier itll become you Go from beginner to expert Web3 developer in just 32 hours, divided into 19 different lessons. Focused on the Solidity and JavaScript coding languages, you’ll learn key frameworks, the best tools, and much more. Access the course resources on GitHub: Course outline: Lesson 0: Welcome To Blockchain Lesson 1: Blockchain Basics Lesson 2: Welcome to Remix! Simple Storage Lesson 3: Remix Storage Factory Lesson 4: Remix Fund Me Lesson 5: Ethers.js Simple Storage Lesson 6: Hardhat Simple Storage Lesson 7: Hardhat Fund Me Lesson 8: HTML / Javascript Fund Me Full Stack / Front End Lesson 9: Hardhat Smart Contract Lottery Lesson 10: NextJS Smart Contract Lottery Full Stack / Front End Lesson 11: Hardhat Starter Kit Lesson 12: Hardhat ERC20s Lesson 13: Hardhat DeFi and Aave Lesson 14: Hardhat NFTs Lesson 15: NextJS NFT Marketplace Full Stack / Front End Lesson 16: Hardhat Upgrades Lesson 17: Hardhat DAOs Lesson 18: Security and Auditing Connect with course instructor Patrick Collins: Twitter: LinkedIn: GitHub: Chainlink is the industry standard for building, accessing, and selling oracle services needed to power hybrid smart contracts on any blockchain. Chainlink oracle networks provide smart contracts with a way to reliably connect to any external API and leverage secure off-chain computations for enabling feature-rich applications. Chainlink currently secures tens of billions of dollars across DeFi, insurance, gaming, and other major industries, and offers global enterprises and leading data providers a universal gateway to all blockchains. Learn more about Chainlink: Website: Docs: Twitter: Chainlink freeCodeCampS2,