I’ve been learning solidity for three months, and finally, I built my very first Dapp (Link).
A couple of weeks ago, I got so inspired by the winners of Chainlink Virtual Hackathon 2021 spring. They all built very creative Dapps built around Chiainlink oracle systems. They literally showed how much potential smart contracts and Chainlink oracle have.
That’s when I got interested in Chainlink Price Feeds and made me feel like using it.
What is Chainlink Price Feed
It let you access a lot of kinds of the latest and historical price data within your smart contracts, so it’s useful when you want to know the current market prices of any assets.
Chainlink Price Feeds are the quickest way to connect your smart contracts to the real-world market prices of assets. They enable smart contracts to retrieve the latest price of an asset in a single call.
Sometimes people want to send the same worth of Ether as a specific amount of fiat currency for like payment.
Let’s say, you want to send $500 worth of Ether, then you realize you can’t set the amount of Ether which is worth of a specific amount of US dollar in Metamask.
It shows what’s your Ether worth in US dollar, but like you cannot set $500 worth of Ether.
That’s where my Dapp comes in. You can send the amount of Ether based on fiat currency.
How It Works
- Select a fiat currency, recipient, and amount of the fiat currency.
- Click “Send Ether” and “Confirm”.
It calculates the amount of Ether as soon as you enter amount using Chainlink Price Feeds.
The good thing is it does not cost anything to get the latest price since the contract is a view function.
Here is the smart contract code I use for this Dapp. This works on Kovan testnet. If you want it work on mainnnet or rinkeby, then all you have to do is change the addresses on AggregatorV3Interface (Line 22~26). Here is the link for each address on Ethereum network.
The problem is that it violate the DRY principle. The last 5 functions are doing the same thing with different variables.
Ideally, I could combine the last 5 functions together and add a new argument that specify a currency pair.
If you use feed registry, you get any pair of price data and don’t have to remember each address. However, it’s still in alpha, so you cannot use in production. In fact, currently some pairs don’t really work.
Here is the sample code using feed registry.
Hope this helps. Thank you for reading 😁
- Best Free Crypto Trading Bots — Top 16 Bitcoin Trading Bot 
- Best 6 Crypto Trading Signals Telegram Channels
- BlockFi Review 2021 — Earn 8.6% Interest Rates on Your Crypto
Join Coinmonks Telegram Channel and learn about crypto trading and investing
- What is Margin Trading | Dollar-Cost Averaging
- BigONE Exchange Review | Grid Trading Bot
- 3Commas Review | Pionex Review | Coinrule review
- Ledger vs Ngrave | Ledger nano s vs x | Binance Review
- Bybit Exchange Review | Bityard Review | CoinSpot Review
- 3Commas vs Cryptohopper | Earn crypto interest
- The Best Bitcoin Hardware wallet | BitBox02 Review
- NGRAVE ZERO review | Phemex Review | PrimeXBT Review
- Best Blockchain Analysis Tools | Earn Bitcoin | Swapzone Review
- Crypto arbitrage Guide | How to Short Bitcoin | Prokey Review
- Binance Trading Bots | OKEx Review | Atani Review
- Best Crypto Trading Signals Telegram | MoonXBT Review
- Godex.io Review | Invity Review | BitForex Review