junjie blockchain using go

in #blockchain26 days ago

I try this in Freebsd

My BLOCKCHAIN using go cli in freebsd

$ git clone https://github.com/Jeiwan/blockchain_go.git

$ cd blockchain_go/

$ ls

$ go build

$ ls

$ ./blockchain_go

Usage:

createblockchain -address ADDRESS - Create a blockchain and send genesis block reward to ADDRESS

createwallet - Generates a new key-pair and saves it into the wallet file

getbalance -address ADDRESS - Get balance of ADDRESS

listaddresses - Lists all addresses from the wallet file

printchain - Print all the blocks of the blockchain

reindexutxo - Rebuilds the UTXO set

send -from FROM -to TO -amount AMOUNT -mine - Send AMOUNT of coins from FROM address to TO. Mine on the same node, when -mine is set.

startnode -miner ADDRESS - Start a node with ID specified in NODE_ID env. var. -miner enables mining

$ go build

$ ./blockchain_go createwallet

Your new address: 1P2B3XZk8Zi4AFGXpuPoPjBvMWdkLP6akG

$

$ ./blockchain_go createblockchain -address 1P2B3XZk8Zi4AFGXpuPoPjBvMWdkLP6akG

d10fb69d8e10f2e1846ad96dba7baad6ccbb6d9a0e9ce8c608f8c80c0d4c6f2d

Done!

$ ./blockchain_go getbalance -address 1P2B3XZk8Zi4AFGXpuPoPjBvMWdkLP6akG

Balance of '1P2B3XZk8Zi4AFGXpuPoPjBvMWdkLP6akG': 10

$

$ ./blockchain_go listaddresses

1P2B3XZk8Zi4AFGXpuPoPjBvMWdkLP6akG

$

$ ./blockchain_go printchain

============ Block 000058b74597b9e770de04b7008fbb7d835b3fbb2109dc76cc97d448f8380c84 ============

Height: 0

Prev. block:

PoW: true

--- Transaction de493a4d3c14d4639da7a70448e790ac63bf3ae4a9860613dbf9d01a136881f2:

Input 0:

TXID:

Out: -1

Signature:

PubKey: 5468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73

Output 0:

Value: 10

Script: f18b9130fc0e71225c4c5d8c9deaf3fac5e960a3

$

$ ./blockchain_go startnode -miner 1P2B3XZk8Zi4AFGXpuPoPjBvMWdkLP6akG -miner enables mining

Usage of startnode:

-miner string

Enable mining mode and send reward to ADDRESS

$

$ ./blockchain_go getbalance -address 1P2B3XZk8Zi4AFGXpuPoPjBvMWdkLP6akG

Balance of '1P2B3XZk8Zi4AFGXpuPoPjBvMWdkLP6akG': 10

$ ./blockchain_go printchain

============ Block 000058b74597b9e770de04b7008fbb7d835b3fbb2109dc76cc97d448f8380c84 ============

Height: 0

Prev. block:

PoW: true

--- Transaction de493a4d3c14d4639da7a70448e790ac63bf3ae4a9860613dbf9d01a136881f2:

Input 0:

TXID:

Out: -1

Signature:

PubKey: 5468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73

Output 0:

Value: 10

Script: f18b9130fc0e71225c4c5d8c9deaf3fac5e960a3

$ ./blockchain_go startnode -miner 1P2B3XZk8Zi4AFGXpuPoPjBvMWdkLP6akG

Usage of startnode:

-miner string

Enable mining mode and send reward to ADDRESS

$ ./blockchain_go startnode

Usage of startnode:

-miner string

Enable mining mode and send reward to ADDRESS

$ ./blockchain_go startnode 1234

Usage of startnode:

-miner string

Enable mining mode and send reward to ADDRESS

Coin Marketplace

STEEM 0.15
TRX 0.12
JST 0.026
BTC 56787.81
ETH 2507.96
USDT 1.00
SBD 2.24