Introduction to Web 3
Blockchains, DApps and smart contracts
-
What is blockchain?
-
Block structure
-
Block time
-
Transaction
-
Ethereum
-
-
What are DApps?
-
Why DApps
-
Decentralized Vs Federated
-
-
What is a smart contract?
-
Structure
-
Environment
-
Solidity
-
-
Create your first Smart contract!
Blockchain
A block is a Node in a blockchain where information is stored and encrypted.
- Block #
- Nonce
- Data
- Hash
Mining is the process where we try to fit the 'nonce' to get a signed block.
- Block #
- Nonce
- Prev
- Data
- Hash
A blockchain is a series of blocks, where prev refers to the block# of previous node.
Replace Data with transactions
- Block #
- Nonce
- Prev
- Tx : $10->Bill
$20->Clive - Hash
Add Coinbase to keep track of transaction amount in the account
- Block #
- Nonce
- Prev
- Cb: $70
- Tx : $10->Bill
$20->Clive - Hash
The amount of time that it takes to check the hash and find a nonce which is less than the target value
Transaction
- Message
- amount
- from
- to
- private key
- message signature
signed message = message + private key
verify = message + public key + signed message
A record that describes one account sending money to another.
- Nonce
- to
- value
- gas price
- start gas
- v
- r
- s
private key => v+r+s
v+r+s => sender's address
We create a transaction object and submit to a network
Ethereum
The ultimate smart contract and decentralized application platform
Its white paper introduces the idea of 'smart contracts' as an entity that can send and receive money beyond just humans
When we interact with a node in Ethereum network for a transaction, our transaction along with other transactions happening in the network are put together as a "block" in the block chain
Decentralized Apps
Digital applications or programs that exist and run on a blockchain or peer-to-peer (P2P) network of computers instead of a single computer.
They are outside the control of a single authority. DApps—which are often built on the Ethereum platform—can be developed for a variety of purposes including gaming, finance, and social media.
Smart Contracts
Structure
Rinkeby
Contract Instance
Contract Instance
Contract Instance
deployment
Contract Source
Solidity
Contract definition
|
solidity compiler
|
Byte code for deployment | Application Binary Interface(ABI)
JS -> ABI -> Byte code preview
- Invented specifically for authoring smart contracts
- .sol files
- strongly typed
Solidity - v4
pragma solidity ^0.4.12
contract Inbox{
string public message;
function Inbox(string initialMessage) public{
message = initial message;
}
function setMessage(string newMessage) public{
message = newMessage;
}
function getMessage() public view returns(string){
return message;
}
}
Solidity - v8
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
pragma abicoder v2;
contract Message {
string message;
constructor(string memory initialMessage) {
message = initialMessage;
}
function setMessage (string memory newMessage) public{
message = newMessage;
}
function getMessage() public view returns(string memory){
return message;
}
}
Introduction to web3
By Supriya kotturu
Introduction to web3
Blockchain, DApps and Smart contracts
- 79