blockchain


https://github.com/IgorWounds/Terra-Blockchain-Algotrading101


https://medium.com/@vitaya.jealwarakun/%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B8%97%E0%B8%B3-1-dapp-choose-my-lunch-a8c636960f61


https://developer.algorand.org/tutorials/create-and-test-smart-contracts-using-python/


https://blog.cryptostars.is/building-web-3-decentralized-apps-dapps-using-python-93072a1dc101


https://www.web3.university/tracks/create-a-smart-contract/deploy-your-first-smart-contract


https://medium.com/20scoops-cnx/%E0%B8%A1%E0%B8%B2%E0%B8%A3%E0%B8%B9%E0%B9%89%E0%B8%88%E0%B8%B1%E0%B8%81%E0%B8%81%E0%B8%B1%E0%B8%9A-solidity-%E0%B8%82%E0%B8%B1%E0%B9%89%E0%B8%99%E0%B8%9E%E0%B8%B7%E0%B9%89%E0%B8%99%E0%B8%90%E0%B8%B2%E0%B8%99%E0%B8%81%E0%B8%B1%E0%B8%99-6f713b3fb64

https://killswitch-official.medium.com/%E0%B8%A1%E0%B8%B2%E0%B8%A3%E0%B8%B9%E0%B9%89%E0%B8%88%E0%B8%B1%E0%B8%81%E0%B8%81%E0%B8%B1%E0%B8%9A-solidity-%E0%B8%82%E0%B8%B1%E0%B9%89%E0%B8%99%E0%B8%9E%E0%B8%B7%E0%B9%89%E0%B8%99%E0%B8%90%E0%B8%B2%E0%B8%99-%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%99%E0%B8%B3%E0%B9%84%E0%B8%9B%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-golang-%E0%B8%81%E0%B8%B1%E0%B8%99-d2b18930c883


https://dev.to/leiw5173/writing-a-smart-contract-in-python-3po1

https://github.com/neo-ngd/NEO-Tutorial/blob/master/neo_docs_neopython_tutorial/part1_setup.md

https://github.com/HandsomeJeff/neo-python-workshop/blob/master/part2_neopy.md


https://www.freecodecamp.org/news/create-cryptocurrency-using-python/

https://geekflare.com/create-a-blockchain-with-python/

https://github.com/halilozercan/halocoin


https://medium.com/validitylabs/how-to-interact-with-the-ethereum-blockchain-and-create-a-database-with-python-and-sql-3dcbd579b3c0

http://ecomunsing.com/tutorial-controlling-ethereum-with-python

https://medium.com/infrageth/practical-steps-for-go-ethereum-setup-27b8d64903fc

https://hackernoon.com/heres-how-i-built-a-private-blockchain-network-and-you-can-too-62ca7db556c0

https://github.com/ricmoo/pycoind/blob/master/README.md#cookbook

https://hackernoon.com/learn-blockchains-by-building-one-117428612f46

https://medium.com/crypto-currently/lets-build-the-tiniest-blockchain-e70965a248b

https://gist.github.com/aunyks/8f2c2fd51cc17f342737917e1c2582e2

https://github.com/koshikraj/pynaivechain

https://github.com/emunsing/tutorials/blob/master/BuildYourOwnBlockchain.ipynb

from datetime import datetime import hashlib as hasher class Block: def __init__(self, index, timestamp, data, previous_hash): self.index = index self.timestamp = timestamp self.data = data self.previous_hash = previous_hash self.hash = self.hash_block() def __str__(self): return 'Block #{}'.format(self.index) def hash_block(self): sha = hasher.sha256() seq = (str(x) for x in ( self.index, self.timestamp, self.data, self.previous_hash)) sha.update(''.join(seq).encode('utf-8')) return sha.hexdigest() def make_genesis_block(): """Make the first block in a block-chain.""" block = Block(index=0, timestamp=datetime.now(), data="Genesis Block", previous_hash="0") return block def next_block(last_block, data=''): """Return next block in a block chain.""" idx = last_block.index + 1 block = Block(index=idx, timestamp=datetime.now(), data='{}{}'.format(data, idx), previous_hash=last_block.hash) return block def test_code(): """Test creating chain of 20 blocks.""" blockchain = [make_genesis_block()] prev_block = blockchain[0] for _ in range(0, 20): block = next_block(prev_block, data='some data here') blockchain.append(block) prev_block = block print('{} added to blockchain'.format(block)) print('Hash: {}\n'.format(block.hash)) # run the test code test_code()

Practical steps for go-ethereum setup

This tutorial cover installation, setup and basic commands of go-ethereum. After completing this tutorial, you can setup your own semi public ethereum network.

Prerequisites

OS: Ubuntu 16.04 ( 64 bit )

RAM: 2 GB

If you are using Virtual Machine, bridge the network adapter as below.

Network setting in virtual box

Geth Installation

sudo apt update

sudo apt install software-properties-common

sudo add-apt-repository -y ppa:ethereum/ethereum

sudo apt update

sudo apt install ethereum

Check geth command

geth --help

Testing geth

Project directory setup

mkdir ethProject

cd ethProject

Create a directory node_app to add script files containing geth commands.

mkdir node_app

Creating a new account

Inside directory node_app , create a file account.sh .

cd node_app

nano account.sh

Put the below command inside account.sh file.

geth --datadir ../eth_node account new

press Ctrl + x and y and enter to save file.

Make the file executable.

sudo chmod +x account.sh

Run script.

./account.sh

The directory structure become like below.

ethProject

|- eth_node

|- keystore

|- account-file

|- node_app

|- account.sh

Blockchain initialization

Create a file genesis.json

nano genesis.json

Put the below contents

{

"config": {

"chainId": 88888,

"homesteadBlock": 0,

"eip155Block": 0,

"eip158Block": 0

},

"coinbase" : "0x0000000000000000000000000000000000000000",

"difficulty" : "0x1",

"extraData" : "0x00",

"gasLimit" : "0xfffffffffffffff",

"nonce" : "0x0000000000000042",

"timestamp" : "0x00",

"alloc" :{

"account-address": {"balance": "0xffffffffffffffffffffffff"}

}

}

Notes: "alloc" properties will fill your account(s) with ether. You need to fill account-address with the previously created account. When you setup geth on another computer, you need to use the same 'genesis.json' file in order to make successful connections between nodes.

genesis.json

Create a file init.sh .

nano init.sh

Put the below command.

geth --datadir ../eth_node init genesis.json

Make the file executable as above.

Run script.

./init.sh

Running geth and interacting with javascript console

Create a file console.sh putting the below command and make it executable.

geth --datadir ../eth_node --nodiscover console

Run script

./console.sh

You can test basic commands valid inside JavaScript console.

eth.accounts // list accounts

eth.getBalance(eth.accounts[0]) //check balance of account 0

more commands

Start mining

miner.start(1)

Let’s Create another account to transfer ether.

Open another terminal and Inside node_app directory, run ./account.sh .

You will see two accounts when running eth.accounts inside console.

Check the balance of new account.

Transferring ether between accounts

Unlock account to send transaction.

personal.unlockAccount(eth.accounts[0])

Transfer ether

eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[1], value:10000000000})

Transferring ether

The above transaction is mined by geth as below.

Make sure geth node is mining by checking a boolean property,

eth.mining

Check balances again

Balances after transaction

Now, geth is running as a single node with own genesis block and mining transactions successfully. Let’s create a blockchain network.

Geth multi-nodes setup

Create a file static-nodes.json

Inside console, print enode of geth node

admin.nodeInfo.enode

Copy result into static-nodes.json file and insert ip address as below

static-nodes.json

Copy node_app folder to another computer.

Run scripts inside node_app folder.

./account.sh

./init.sh

Copy static-nodes.json into eth_node directory

cp static-nodes.json ../eth_node

Start geth

./console.sh

When geth run, it will detect static-nodes.json and connect to the node(s) using enode(s).

Check peer count

net.peerCount

Check balance of account

Transfer ether from account of first node to account of second node.

Check balance again.

Now, you have successfully created blockchain network using geth.

You can add as many nodes as you want by adding enodes inside static-nodes.json file.

Developing smart contract on go-ethereum using Truffle framework

Smart contract is a code that can be deployed inside blockchain. Once it is deployed, Users can trigger it by using its address. In this tutorial, the smart contract is written with solidity language and deployed on semi pubic ethereum blockchain network. The development steps are simplified by using Truffle framework.

Prerequisites

OS: Ubuntu 16.04 ( 64 bit )

RAM: 2 GB

The go-ethereum setup steps can be followed here.

Truffle Installation

First, install nodejs using nvm.

sudo apt update

sudo apt install build-essential libssl-dev

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh

source ~/.profile

nvm ls-remote

nvm install 8.9.3

Install Truffle

npm install -g truffle

Truffle TutorialToken

Following steps are referenced from BUILDING ROBUST SMART CONTRACTS WITH OPENZEPPELIN

Writing contract

Inside directory ethProject

mkdir truffle

cd truffle

truffle unbox tutorialtoken

npm install zeppelin-solidity

Create a new file TutorialToken.sol in directory contracts with the following contents.

pragma solidity ^0.4.17;

import 'zeppelin-solidity/contracts/token/ERC20/StandardToken.sol';

contract TutorialToken is StandardToken {

string public name = 'TutorialToken';

string public symbol = 'TT';

uint8 public decimals = 2;

uint public INITIAL_SUPPLY = 12000;

function TutorialToken() public {

totalSupply_ = INITIAL_SUPPLY;

balances[msg.sender] = INITIAL_SUPPLY;

}

}

Create another file 2_deploy_contracts.js in directory Migrations with below contents.

var TutorialToken = artifacts.require("TutorialToken");

module.exports = function(deployer) {

deployer.deploy(TutorialToken);

};

Compile contract

truffle compile

Deploying contract

Change port value to 8545 ( geth rpc port ) in truffle.js file.

Add options in console.sh file in node_app directory to access from http-rpc.

geth --datadir ../eth_node --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --nodiscover console

Run geth on another terminal.

cd node_app

./console.sh

Unlock account to send transaction ( deploy contract ).

personal.unlockAccount(eth.accounts[0],'passphrase',1000)

deploy contract

truffle migrate

successful migration

Interacting with smart contract from web ui

Change port to 8545 in src/js/app.js as below.

app.js

Run dev web server.

npm run dev

TutorialToken Dapp

Send Token and ether between nodes

Metamask

Installation

starting metamask

Send Token and ether to metamask accounts

After transferring ether

Using Remix to test smart contracts on both simulator and geth network

npm install -g remixd

Run remixd with absolute path

remixd -S /.../bcWorkshop/ethProject/truffle

Use remix web UI and connect to local file server and select web3 provider with http://127.0.0.1:8545 to connect to geth.

If you want to test quickly without geth, Select javascript VM.

Testing Contract using remix

Detail steps for remix setup.

Now you have developed smart contract using truffle framework and used standard library OpenZeppelin.

To develop smart contracts further, you need to learn solidity documentation.