Friday, 7 January 2022

Blockchain

Satoshi Nakamoto's Paper

How to Store Bitcoin

Good Tutorials

Good tutoria about smart contract

Block

Every block has the previous block's hash. It has it's own hash which is generated by hashing previous hash and own data.


{data: "some data", previous_block_hash: "hash value", own_hash: "own hash value"}

hashfunction( data, previous_block_hash) => this block's hash

Chain Blocks

For the first block, we give it some randon string as the previous block hash because it does not have previous block. For every other block, it has the previous block's hash. Use hash to link blocks and these blocks become a blockchain.

Verify Block Chain

traverse through the chain, for every block, verify it's hash by using the hash function. Also, except the first block, check the previous hash property does match the hash of the previous block.

keccak256 value

use ruby. Need to install a gem first

gem install keccak256
require "keccak256"
code = Digest::Keccak256.new.hexdigest 'hello1'
puts code

Private and public key

require 'openssl'

key = OpenSSL::PKey::RSA.generate(2000)
key.public_key

puts key.public_key
puts key

Smart contract hello world

Hello World Totorial

//I made an adjustment in order to compile the contract successfully
//change to this solidity version in HelloWorld.sol
pragma solidity ^0.8.0;
//because in hardhat.config.js
solidity: "0.8.4",

Voila! successfully deploy the smart contract to a test net!

npx hardhat run scripts/deploy.js --network ropsten
//voila
Contract deployed to address: 0x4827E8a9858f73d061262fB3BAaa4FA8461F7904

See Contract Details

Screenshot of the transaction

Labs

Lab One

No comments:

Post a Comment