Day-06: Understanding Oracle Chain-link  Datasource & First Project Setup #100DaysOfCode #MyLearnings

Day-06: Understanding Oracle Chain-link Datasource & First Project Setup #100DaysOfCode #MyLearnings

·

5 min read

Intro

When you get unplayable, unexpected bouncers what do we do? we duck the ball & let go of it, the same is true with life... was facing an unexpected bouncer in work life & the only way to survive was to duck, it can't be the reason for not being consistent & I'll try harder next time to maintain the consistency, till then, here's my #day05 of blockchain which I've covered yesterday but am late on the blog.

My learnings & catching up with the pace despite of having the hurdles I am facing with my work life, & it feels worth doing when you struggling the most, finally covered up with Lesson-03 of solidity insights & got on to project-based learning part with setting up my first FundMe project with come more concepts alongside...more on it is covered below,

Concepts covered & new learnings

I am now sure that the contract is a class that we use in other programming languages and similar object-oriented concepts follow up on contracts,

Inheritance

follows the same principle of inheriting the parent class using the IS keyword.

Method Overriding

  • Method overriding follows overriding the parent class methods. We need to use virtual keywords in the parent class to make the method overridable & then specify the override keyword for the same method in the child class to add updates in the native functionality.
contract SimpleStorage{
function addPeople( string memory _name ,int256 _favouriteNumber) public virtual {
people.push(People({name: _name, favouriteNumber : _favouriteNumber}));
}
}
contract InheritSimpleStorage is SimpleStorage{
function addPeople(string memory _name,int256 _favouriteNumber) public override {
people.push(People({name: _name,favouriteNumber: _favouriteNumber + 10}));
}
}

Fields exist for each transaction in the Blockchain

  • Nonce: Transaction count for the account

  • Gas Price: Price per unit of gas (in wei)

  • Gas Limit: max gas that this transaction can use

  • To: address that the transaction is sent to

  • Value: amount of Wei to send

  • v,r,s: components of transaction signature, essential in cryptographic computation & storing relevant information, will be covered later on.

Payable keyword

To make our function/method payable with Eth or any other native blockchain currency,, we add the payable keyword to the function.


contract FundMe{
    function fund() public payable  {
    }
}

Accessing transaction fields of blockchain in code

  • global msg value: To access the transaction fields like value, nonce & others we need to access the global variable msg in our method for which making the method payable is essential. The transaction values we can access are listed below,

    1. msg.value: 1e18 = 1 10 * 18 i.e. 10^18 wei (Eth to Wei conversion)

    2. msg.gas

    3. msg.data

    4. msg.sender

    5. msg.sig

require (condition, revert msg)

Adds up a compulsory condition to fulfill, & if not fulfilled it undoes the action, returns the gas & sends an error to revert message that we’ve provided.

Hybrid Blockchains:

  • The most important thing in blockchain is to maintain the consensus i.e. to always be decentralized & deterministic. Blockchain runs on math & rules & it’s completely decentralized, deterministic & transparent, that means if we accept or store data of these blockchain smart contracts then it won’t follow the consensus, we again will be storing data in a centralized source which is against the whole purpose of implementing blockchains i.e against the consensus.

  • Blockchain currencies in themselves are deterministic & isolated, & are not convertible to usual**(fiat)** currencies, now that is a problem that needs to be solved.

  • That's where chain link comes into the picture, it works as the data source for blockchain but it is Not Centralized i.e. it is Decentralized.

  • In our fund me problem we want to specify minimum fund limits in terms of Dollars but we don’t have any medium for comparing both as they are not interconvertible, we need some external decentralized source that could do these things for us & won’t go against the consensus throughout the process.

  • Chain-Link uses multiple API endpoints i.e. centralized sources to get the data values needed for multiple sources & then runs through a process in such a way as to provide a decentralized data source network for the main blockchain.

A bit on FUNDME

  • It’s gonna be a short assignment kinda project that will cover some complex concepts & real-time transaction scenarios.

  • The project FundMe will be built on Remix with the pure solidity use case, & eventually connect with the test wallets to perform the transactions.

  • FundMe enables individuals to fund the money in terms of dollars & which will be converted to crypto & stored in the fund wallet, again there will be a withdraw functionality to withdraw the amount from the fund's wallet.

Outro

The learnings are becoming more exciting day by day, getting more challenging concepts to learn, the only important & crucial thing is to be consistent throughout the process. Though I wasn't consistent the past two days with blogs, I was covering the lectures at least a bit every day, that is something I should be happy about but the target would be to complete what decided & that is ai tend to achieve...

So far these are some of the learnings that I can share with you all, I've tried to put everything as per my understanding & there's a chance that I might've mistaken somewhere, so, feel free to correct me on anything in the comments.

Wrapping up my Day-06 of #100DaysOfCode, will catch up again tomorrow, till then, it's a farewell.