 - Solidity   Ethereum.  
  


       - Solidity    DApp   Ethereum.    12    .  ,       Ethereum,  -    ,       -   ,    Rinkeby.   ,            ,      .









    ,         Ethereum,          DApp    Solidity   .

     ,    ,   ,   .      ,        Debian  Ubuntu.        Raspberry Pi.

        Ethereum   ,     ,     .

        Ethereum          Ubuntu  Debian.      ,   geth,     ,       swarm.

       Ethereum    Raspberry Pi.     () Rasberian  Raspberry Pi,  Geth,    ,       Swarm.

         Ethereum,             Geth.    ,    ,      .

      -   Ethereum,       Ethereum.

       Ethereum   -     .        Remix Solidity IDE.  ,        solc.

         Application Binary Interface (ABI)    .

     JavaScript,    Node.js     - Solidity.

  Node.js   Ubuntu, Debian  Rasberian,     -    Ethereum    .

 ,          ,       -.

           - Solidity   Truffle.     JavaScript,       truffle-contract,      -  Truffle.

     Solidity.   -,     ,      ,   , , ,   , , ,   .

          -    Ethereum.       Truffle    Geth,      Rinkeby.  -   Rinkeby             -,  .

        Rinkeby,      -.

 10     Ethereum Swarm.   ,          Ethereum.

        Swarm,      ,     .        Swarm,      Swarm  Node.js,      Perl Net::Ethereum::Swarm.

  11     - Solidity      Python   Web3.py.    ,       -,      .   Web3.py      ,        Truffle.

 12       -      .        Web-,    IoT,    ,     -   .         -,     USD      .




 


         sbook@frolov-lib.ru (mailto:sbook@frolov-lib.ru)  https://www.facebook.com/frolov.shop2you (https://www.facebook.com/frolov.shop2you).

,     ,       .




 1.      Ethereum






       (),         (Blockchain),  (Cryptocurrency  Crypto Currency),  (Bitcoin),    (ICO, Initial coin offering), - (Smart Contract),      ,    .

          .          -,             .

 ,        .         ,   ,      ..             -  Ethereum (, )       (Distributed Application, DApp).




  



 (Blockchain, Block Chain)     ,      .      ,     (genesis block)   .    ,     .

          .       .

          (   ),           .      ,     ()      .          .




  


       ,      .        ,      ,    .




  


          ().       .

     ,      .   ,  ,   ,          .

      ()     .    ,        .







     ()  .   ,       .     ,  .

            .     , ,     ,    ,       ..

 Ethereum     .          .    .




   


  ,           ,          ,    .

          ,    , ,     .




  


    ?

 ,       ()        .     (,  , , , ,   ..)      .      , ,      .

,  ,       ,     .      ( Fiat Money).

     ,   ,         .      -    (),      .

       ,                .

  -,    ,    Ethereum,         .   ,       Ether ().

 Ethereum  - Ethereum,     Solidity,  , ,   :

    ;

           ;

          (, ,    ..);

    ;

     ;

    ,   ;

        ;

     ;

    ,     .




  


, ,    ,    !

          (,    ?),       ,     ,                ..

 ,       ,      ,    ,    ,       ,         .

  ,  ,   ,    .     ( )      .   ,      ,         .

  Ethereum  ,      .   ,      ,      DApp  -.

   ,    ,            .       ,   ,       .

     ,  -  Ethereum              .  ,  -         -   (,   ..),        -  .           ,        -.

     .   , ,      ,        ,   .        .   ,   ,   ,      ,      .




   


   ,       .      ,        . ,            .

 . 1.1.      ,      .






. 1.1.   



  , ,        ,           . ,        ,    ,   ,         .

     .           (. 1.2.).






. 1.2.      



       ,         .    ,    .

         ,   MD-5, SHA-1, SHA-256  .. -    (,      )        .     -.

        -  .   -,    ,     .

    ?  , .

     (-)    ,     .    -,      .            .

     ,               (. 1.3.).






. 1.3.       



  ,   - ,   -   .  ,   ?

             ,    .   ,            ,   ,     .

 ,     ()    , ..   .      , ..       .

       ,       .




 Ethereum


 Ethereum   ,        DApp.     , Ethereum       (-, smart contracts),     Solidity.

     2013   ,   Bitcoin Magazine,    2015 . ,          ,      Ethereum  - Solidity.




,    


 (mining)             ,     .    , ..          Ethereum.

  ,   ,   (miner).

  (),    ,          Nonce,     -,  .   Ethash,   Ethereum,    Nonce    .

      Nonce,        (PoW, Proof-of-work).   ,       Ethereum,         Ether.        5 Ether,      .

 ,  Ethereum   ,  ,      .          ,       Solidity    DApp   Ethereum.




 


        ,         .      ,             ,        .

       .           (  ),    .  ,             Ethereum  - Solidity.   ,   ,   ..

  ,        .    ,   ,   ,  ,     -   ,      ,        .

             .     . ,   ,          .




 2.      Ubuntu  Debian






     - Ethereum,          ()     ().

        -    (IDE, Integrated Development Environment), , Remix  Truffle. ,         - Solidity.   ,     ,   Ethereum,     .




  


    Ethereum       Go Ethereum (https://geth.ethereum.org/).       Ethereum      Go      Geth.   Geth      Ethereum.

    Geth     ,     (API, Application Programming Interface) JSON RPC.      ,    ,    Ethereum,      .

 Geth    ,   Go (, , Linux, Mac OSX, Windows, Raspberry Pi, Android OS, iOS).    https://geth.ethereum.org/downloads/ (https://geth.ethereum.org/downloads/)    Linux, macOS  Windows.       Geth.

      OC Ubuntu Live Server 18.04.2, Ubuntu 18.10 cosmic, Debian  9  10 Alfa 5,  Geth       Linux.       Geth  OC Rasberian   Raspberry Pi 3.

  Ethereum          .          ,        , , VMware Workstation,     .

   Ubuntu  Debian     ,        ,   .  ,             . ,    64-   Ubuntu  Debian.

           :

 4  CPU    2 GHz;

 2 GB RAM;

 20 GB Disk SSD.

   OC Ubuntu 18.10 cosmic    VMware Workstation   :

 8  CPU    2 GHz;

 8 GB RAM;

 100 GB Disk SATA.

        .     ,       .  ,  ,   2   .

  Raspberri Pi,   ,  ,       .

    Ubuntu  Debian      apt-get:



$ sudo apt-get update

$ sudo apt-get upgrade



  Ubuntu Server  ,    .         :



*** System restart required ***



       :



$ sudo shutdown -r now



 Ubuntu          .

       root.




  


  Ubuntu   ssh,        (      ssh  ,   Ubuntu Live Server    ).

         book,           sudo.

     book    Ubuntu.       visudo        sudo.       root  :



# visudo



   /etc/sudoers.         :



book ALL=(ALL) ALL



   ssh   :



$ sudo apt-get install ssh



  Ubuntu  Debian   vim (     ),  sudo (   ), git, curl, gcc  mc (mc   , ,       Midnight Commander):



$ sudo apt-get install vim sudo git curl gcc mc



          ( )   SSH,  fail2ban:



$ sudo apt-get install fail2ban



           .




 Geth  Swarm  Ubuntu


     Geth,        Swarm ( ,  10 ).

   Geth   Ubuntu.   : https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu (https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu).

    :



$ sudo apt-get install software-properties-common

$ apt-get install build-essential

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

$ sudo apt-get update

$ sudo apt-get install ethereum



     (  Geth),     :



$ sudo apt-get install ethereum-unstable



    Geth:



$ geth version

Geth

Version: 1.8.23-stable

Git Commit: c942700427557e3ff6de3aaf6b916e2f056c1ec2

Architecture: amd64

Protocol Versions: [63 62]

Network Id: 1

Go Version: go1.10.4

Operating System: linux

GOPATH=

GOROOT=/usr/lib/go-1.10



 ,    Geth   1.8.23  Go  1.10.4.

     Swarm       :



$ sudo apt-get install ethereum-swarm



    Swarm:



$ swarm version

Swarm

Version: 0.3.11-stable

Git Commit: c942700427557e3ff6de3aaf6b916e2f056c1ec2

Go Version: go1.10.4

OS: linux



   ,    ,    .

  ,     ,       Google. ,         .




 Geth  Swarm  Debian



 Geth  Swarm   Debian     .       Go,     Geth  Swarm.

        Go 1.12.1. ,  Geth  Swarm     .  ,   ,       ,       Go.




 


       :



$ sudo apt-get update

$ sudo apt-get upgrade

$ apt-get install vim sudo git curl gcc mc



        book     sudo,    ,       Ubuntu.

      Go  Geth.




  Go


 Go         : https://golang.org/dl/ (https://golang.org/dl/).

      (  )  book    Go  :



$ curl -O https://dl.google.com/go/go1.12.1.linux-amd64.tar.gz (https://dl.google.com/go/go1.12.1.linux-amd64.tar.gz)



,       book,      /usr/local:



$ sudo tar -C /usr/local -xzf go1.12.1.linux-amd64.tar.gz



      book.  sudo ,          /usr/local.




  


       book  go    :



$ mkdir-p~/go;echo"exportGOPATH=$HOME/go">>~/.bashrc

$ echo "export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin" >> ~/.bashrc

$ source~/.bashrc



,    :



$ printenv|grepgo



GOPATH=/root/go

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/go/bin:/usr/local/go/bin




  Go


      Geth  Swarm,    go:



$ go version

go version go1.12.1 linux/amd64



    1.12.1,   .     -         go  ,   :



sudoapt-getremovegolang-go

sudoapt-getremoveauto-removegolang-go




 Geth  Swarm


     Geth    GitHub:



$ mkdir-p$GOPATH/src/github.com/ethereum

$ cd$GOPATH/src/github.com/ethereum

$ gitclonehttps://github.com/ethereum/go-ethereum

$ cdgo-ethereum

$ gitcheckoutmaster



$ gogetgithub.com/ethereum/go-ethereum



    Geth  Swarm:



goinstall-v./cmd/geth

goinstall-v./cmd/swarm



    ,   Go  .     ,     .

   ,       Geth  Swarm:



$ geth version

Geth

Version: 1.9.0-unstable

Architecture: amd64

Protocol Versions: [63 62]

Network Id: 1

Go Version: go1.12.1

Operating System: linux

GOPATH=/home/book/go

GOROOT=/usr/local/go



$ swarm version

Swarm

Version: 0.3.12-unstable

Go Version: go1.12.1

OS: linux



 ,     Geth  Swarm.   whereis   ,      :



$ whereis geth

geth: /home/book/go/bin/geth



   ,       https://geth.ethereum.org/downloads/ (https://geth.ethereum.org/downloads/).      geth     .

    Geth  Swarm     https://media.readthedocs.org/pdf/swarm-guide/latest/swarm-guide.pdf (https://media.readthedocs.org/pdf/swarm-guide/latest/swarm-guide.pdf).




  



       -,   .       ,       .       Rinkeby,     Ethereum          Ethereum.




  genesis.json


       book  genesis.json ( 2.1.).

 2.1.  genesis.json



{

"config": {

"chainId": 1999,

"homesteadBlock": 0,

"eip155Block": 0,

"eip158Block": 0

},

"difficulty": "10",

"gasLimit": "5100000",

"alloc": {}

}



     (genesis block)       .       ,         .

     Ethereum  , , : https://arvanaghi.com/blog/explaining-the-genesis-block-in-ethereum/ (https://arvanaghi.com/blog/explaining-the-genesis-block-in-ethereum/).

 config  genesis.json     Ethereum.

 chainId   .      , ..    ,       .

      Ethereum,     1.    Rinkeby  4.          ,   .    1999.

 0   homesteadBlock   ,       Ethereum   Homestead. Homestead      Ethereum (   Frontier).          Ethereum.

     EIP.   Homestead   ,        Ethereum.         Ethereum (Ethereum Improvement Proposals, EIPs),    https://eips.ethereum.org/ (https://eips.ethereum.org/).

         (hard-forking),    .        ,            .

      ,      eip155Block  eip158Block  .

 difficulty      .           .           ,  10,             .

   gasLimit           (Gas).  Ethereum    ,      ,   ,      ..      .          ,        .

 alloc            .         .




   


     node1:



$ mkdir node1



      .




 


      .        book    :



$ geth datadir node1 account new



     ,      :



INFO [02-13|08:42:28.798] Maximum peer countETH=25 LES=0 total=25

Your new account is locked with a password. Please give a password. Do not forget this password.

Passphrase:

Repeat passphrase:

Address: {4f744742ac711fd111c7a983176db1d48d29f413 }



 account new          .      4f744742ac711fd111c7a983176db1d48d29f413.       .

 datadir  geth     .    /home/book/node1.




  


       ,       book:



$ geth datadir node1 init genesis.json



     datadir      ,    init       genesis.json.

         :



INFO [02-13|08:43:53.934] Maximum peer countETH=25 LES=0 total=25

INFO [02-13|08:43:53.936] Allocated cache and file handlesdatabase=/home/book/node1/geth/chaindata cache=16 handles=16

INFO [02-13|08:43:53.950] Writing custom genesis block

INFO [02-13|08:43:53.950] Persisted trie from memory databasenodes=0 size=0.00B time=28.058s gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B

INFO [02-13|08:43:53.951] Successfully wrote genesis statedatabase=chaindatahash=a5e5bc3f490e

INFO [02-13|08:43:53.951] Allocated cache and file handlesdatabase=/home/book/node1/geth/lightchaindata cache=16 handles=16

INFO [02-13|08:43:53.955] Writing custom genesis block

INFO [02-13|08:43:53.955] Persisted trie from memory databasenodes=0 size=0.00B time=1.778sgcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B

INFO [02-13|08:43:53.956] Successfully wrote genesis statedatabase=lightchaindatahash=a5e5bc3f490e



         ,      book.

  ,      :



$ geth etherbase "0x4f744742ac711fd111c7a983176db1d48d29f413"datadir node1 nodiscover mine minerthreads 1 maxpeers 0 verbosity 3 networkid 98760 rpc rpcapi="db,eth,net,web3,personal,web3" console



   etherbase    ,     .

       .         DAG.       :



INFO [02-13|08:51:16.647] Maximum peer countETH=0 LES=0 total=0

INFO [02-13|08:51:16.649] Starting peer-to-peer nodeinstance=Geth/v1.8.22-stable-7fa3509e/linux-amd64/go1.10.4

INFO [02-13|08:51:16.649] Allocated cache and file handlesdatabase=/home/book/node1/geth/chaindata cache=512 handles=524288

INFO [02-13|08:51:16.662] Initialised chain configurationconfig="{ChainID: 1999 Homestead: 0DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0EIP158: 0Byzantium: <nil> Constantinople: <nil>ConstantinopleFix: <nil> Engine: unknown}"

INFO [02-13|08:51:16.663] Disk storage enabled for ethash cachesdir=/home/book/node1/geth/ethash count=3

INFO [02-13|08:51:16.663] Disk storage enabled for ethash DAGsdir=/home/book/.ethashcount=2

INFO [02-13|08:51:16.663] Initialising Ethereum protocolversions="[63 62]" network=98760

INFO [02-13|08:51:16.724] Loaded most recent local headernumber=0 hash=a5e5bc3f490e td=10 age=49y10mo16h

INFO [02-13|08:51:16.724] Loaded most recent local full blocknumber=0 hash=a5e5bc3f490e td=10 age=49y10mo16h

INFO [02-13|08:51:16.724] Loaded most recent local fast blocknumber=0 hash=a5e5bc3f490e td=10 age=49y10mo16h

INFO [02-13|08:51:16.724] Loaded local transaction journaltransactions=0 dropped=0

INFO [02-13|08:51:16.725] Regenerated local transaction journaltransactions=0 accounts=0

INFO [02-13|08:51:16.732] New local node recordseq=3 id=eae4aa1f2059eed4 ip=127.0.0.1 udp=0 tcp=30303

INFO [02-13|08:51:16.732] Started P2P networkingself="enode://5ac26687728e3e3f4575e5e8feab33748bbc467951e1841b2063cc201dcb6ed4e9b9e26ca322fc935cc5b6b042ebbb6126f5bd7d6cf6903c1e19600cf7f6c8b5@127.0.0.1:30303?discport=0"

INFO [02-13|08:51:16.732] IPC endpoint openedurl=/home/book/node1/geth.ipc

INFO [02-13|08:51:16.733] HTTP endpoint openedurl=http://127.0.0.1:8545cors= vhosts=localhost

INFO [02-13|08:51:16.733] Transaction pool price threshold updated price=1000000000

INFO [02-13|08:51:16.733] Updated mining threadsthreads=1

INFO [02-13|08:51:16.733] Transaction pool price threshold updated price=1000000000

INFO [02-13|08:51:16.734] Commit new mining worknumber=1 sealhash=5c4116c8c1bf uncles=0 txs=0 gas=0 fees=0 elapsed=562.141s

INFO [02-13|08:51:16.779] Mapped network portproto=tcp extport=30303 intport=30303 interface=NAT-PMP(192.168.0.1)

Welcome to the Geth JavaScript console!



instance: Geth/v1.8.22-stable-7fa3509e/linux-amd64/go1.10.4

coinbase: 0x4f744742ac711fd111c7a983176db1d48d29f413

at block: 0 (Wed, 31 Dec 1969 16:00:00 PST)

datadir: /home/book/node1

modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0



> INFO [02-13|08:51:18.459] Generating DAG in progressepoch=0 percentage=0 elapsed=983.779ms

INFO [02-13|08:51:19.420] Generating DAG in progressepoch=0 percentage=1 elapsed=1.944s

INFO [02-13|08:51:20.395] Generating DAG in progressepoch=0 percentage=2 elapsed=2.919s

INFO [02-13|08:51:21.440] Generating DAG in progressepoch=0 percentage=3 elapsed=3.963s





INFO [02-13|08:55:56.193] Successfully sealed new blocknumber=46 sealhash=fccbc15cc27f hash=7769673700c9 elapsed=7.306s

INFO [02-13|08:55:56.193] 


 block reached canonical chainnumber=39 hash=9c6ba7c95452

INFO [02-13|08:55:56.193] 


 mined potential blocknumber=46 hash=7769673700c9

INFO [02-13|08:55:56.193] Commit new mining worknumber=47 sealhash=41558f3ef931 uncles=0 txs=0 gas=0 fees=0 elapsed=97.707s

> [1;5FINFO [02-13|08:56:01.030] Successfully sealed new blocknumber=47 sealhash=41558f3ef931 hash=f67a9b773bfd elapsed=4.837s

INFO [02-13|08:56:01.030] 


 block reached canonical chainnumber=40 hash=3a6600bde7e0

INFO [02-13|08:56:01.030] 


 mined potential blocknumber=47 hash=f67a9b773bfd

INFO [02-13|08:56:01.030] Commit new mining worknumber=48 sealhash=d4ab027151c7 uncles=0 txs=0 gas=0 fees=0 elapsed=97.374s



           DAG      .

 DAG     (Directed Acyclic Graph).       Ethereum      Ethash.      1 .         Ethereum.     , ,   https://investoon.com/tools/dag_size (https://investoon.com/tools/dag_size).        DAG    Ethereum   2.95 .

   DAG,    .     ,   DAG      ,       .

       ,        , , start_node.sh ( 2.2.).

 2.2.  start_node.sh



geth etherbase "0x4f744742ac711fd111c7a983176db1d48d29f413"datadir node1 nodiscover mine minerthreads 1 maxpeers 0 verbosity 3 networkid 98760 rpc rpcapi="db,eth,net,web3,personal,web3" console




  


   geth,      .                  Ethereum.           Rinkeby     Ethereum,     .

         geth,    :



$ geth -h



  datadir,      ,   .       ,       .

 etherbase   ,       .

 nodiscover     .   ,          .

     maxpeers,  .            .

   mine             .  ,           -  .

 minerthreads   ,   .          ,         .

    networkid.   .       98760   .

 verbosity   :

 0      ;

 1     ;

 2    ;

 3    ;

 4    ;

 5    .

    3.

          JSON RPC,     ,   rpc.     rpcapi  ,       .     : db, eth, net, web3, personal, web3.      .

  geth    console.      JavaScript,     .




   


         :



$ geth datadir node1 networkid 98760 attach ipc://home/book/node1/geth.ipc



    geth      .

       datadir  networked,     .  attach   ,     ,     JavaScript.             .

     attach_node.sh   ( 2.3.).

 2.3.  attach_node.sh



geth datadir node1 networkid 98760 attach ipc://home/book/node1/geth.ipc



   ,      geth:





$ sh attach_node.sh

Welcome to the Geth JavaScript console!



instance: Geth/v1.8.22-stable-7fa3509e/linux-amd64/go1.10.4

coinbase: 0x3cd46aab0631305437842cf639218e41ce946baa

at block: 379 (Wed, 13 Feb 2019 09:12:48 PST)

datadir: /home/book/node1

modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0



>



     web3.eth.accounts:



> web3.eth.accounts

["0x4f744742ac711fd111c7a983176db1d48d29f413"]



   () ,    ,    .      .

    web3.version.       Web3,        ,  geth,    .      ,  98760.

   Geth  1.8.22     :



> web3.version

{

api: "0.20.1",

ethereum: "0x3f",

network: "98760",

node: "Geth/v1.8.22-stable-7fa3509e/linux-amd64/go1.10.4",

whisper: undefined,

getEthereum: function(callback),

getNetwork: function(callback),

getNode: function(callback),

getWhisper: function(callback)

}



   Geth     node:



> web3.version

{

api: "0.20.1",

ethereum: "0x3f",

network: "98760",

node: "Geth/v1.8.11-unstable/linux-amd64/go1.9.6",

whisper: undefined,

getEthereum: function(callback),

getNetwork: function(callback),

getNode: function(callback),

getWhisper: function(callback)

}




    


      .         :



> web3.fromWei( eth.getBalance(eth.coinbase) )

0



    Ethereum    .

        .    ,     ,   :



> web3.fromWei( eth.getBalance(eth.coinbase) )

15



  ,    ,       :



INFO [02-13|09:37:10.577] 


 block reached canonical chainnumber=45 hash=924ce1d8b5a2

INFO [02-13|09:37:10.577] 


 mined potential blocknumber=52 hash=a80a36153593

INFO [02-13|09:37:10.577] Commit new mining worknumber=53 sealhash=3acb6c0ecd19 uncles=0 txs=0 gas=0 fees=0 elapsed=130.557s

INFO [02-13|09:37:11.223] Successfully sealed new blocknumber=53 sealhash=3acb6c0ecd19 hash=14e0fa575494 elapsed=645.999ms

INFO [02-13|09:37:11.223] 


 block reached canonical chainnumber=46 hash=c5ff7ada8069

INFO [02-13|09:37:11.224] 


 mined potential blocknumber=53 hash=14e0fa575494

INFO [02-13|09:37:11.224] Commit new mining worknumber=54 sealhash=96235bf3fc50 uncles=0 txs=0 gas=0 fees=0 elapsed=124.053s

INFO [02-13|09:37:11.723] Successfully sealed new blocknumber=54 sealhash=96235bf3fc50 hash=e5438e2f6f2e elapsed=498.975ms



   miner.start  miner.stop     .

           :



> miner.start(4)



        .   ,      .

,    -     ,       ,      .   ,         :



> miner.stop()



            20-30 ,            .  ,  ,       Web-   .




   Geth


   Geth     exit:



> exit




 


      ,     Ethereum  - Solidity.      Ubuntu  Debian,  Go, Geth      Swarm.

    ,    ,      ,      .      Ethereum      .        Geth          .




 3.     Raspberry Pi 3






         Ethereum     Ubuntu  Debian. ,      -       Raspberry Pi 3 (     Raspberry Pi 3 model B),      .

 ,   Raspberry Pi  ,  ,      1  (    Raspberry Pi 4  4    ).   Raspberry Pi      Geth  ,          Ubuntu  Debian.

  ,  .

      ,     ,        , ,      .   ,  Geth   dev,     . ,        ,   .




 Raspberry Pi 3  



    Rasberian       ,  (    HDMI),  (  USB).      Ethernet   .

     MicroSD    8 .

      Rasberian  ,      .

     Raspberry Pi 3     : http://dmitrysnotes.ru/raspberry-pi-3-obzor-i-nachalo-raboty (http://dmitrysnotes.ru/raspberry-pi-3-obzor-i-nachalo-raboty).




 Rasberian


      MicroSD.   Microsoft Windows      SD Memory Card Formatter,     https://www.sdcard.org/downloads/formatter_4/ (https://www.sdcard.org/downloads/formatter_4/).     Microsoft Windows  .

    Raspbian   https://www.raspberrypi.org/downloads/raspbian/ (https://www.raspberrypi.org/downloads/raspbian/).      Raspbian Stretch Lite.   Zip   .         img, , 2018-04-18-raspbian-stretch-lite.img.

        MicroSD.        Rufus.     https://rufus.akeo.ie/ (https://rufus.akeo.ie/).

       Raspberry Pi   .     Rasberian  .

          pi   raspberry.         passwd.




 


       IP   DHCP  ,     .

       :



sudoapt-getupdate

sudoapt-getupgrade




  SSH


        SSH,    .       :



sudo raspi-config



    5. Interfacing options,    SSH  .




   IP


    SSH  ,       IP.   ,   /etc/dhcpcd.conf:



sudo nano /etc/dhcpcd.conf



   #   :



interfaceeth0

staticip_address=192.168.0.38/24

staticip6_address=fd51:42f8:caae:d92e::ff/64

staticrouters=192.168.0.1

staticdomain_name_servers=192.168.0.18.8.8.8fd51:42f8:caae:d92e::1



   staticip_address    IP. ,       DHCP    .

    :



sudo shutdown -r now



           SSH   .    ,        Raspberry Pi     SSH.

     ,      .    .




  


    ,      vim,  sudo  git:



# apt-get install vim

# apt-get install sudo

# apt-get install git



  book     visudo        sudo,       .




 Go



    Go  1.9.6.   Rasbian      Debian,    ,     ARM.




  Go


   ,  Go         : https://golang.org/dl/ (https://golang.org/dl/).

    Raspberry Pi  book    Go  :



$ curl -O https://dl.google.com/go/go1.9.6.linux-armv6l.tar.gz (https://dl.google.com/go/go1.9.6.linux-armv6l.tar.gz)



    ,       book   sudo,      visudo.

    /etc/sudoers :



book ALL=(ALL) ALL



      book       /usr/local:



$ sudo tar -C /usr/local -xzf go1.9.6.linux-armv6l.tar.gz



 ,         ARM.




  


     book  go    :



$ mkdir-p~/go;echo"exportGOPATH=$HOME/go">>~/.bashrc

$ echo "export PATH=$PATH:$HOME/go/bin:/usr/local/go/bin" >> ~/.bashrc

$ source~/.bashrc



,    :



$ printenv|grepgo



GOPATH=/root/go

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/go/bin:/usr/local/go/bin




  Go


      Geth  Swarm,    go.    ,    1.9.6   ARM:



$ go version

go version go1.9.6 linux/arm




 Geth  Swarm


 Geth  Swarm   ,       .

   Geth    GitHub:



$ mkdir-p$GOPATH/src/github.com/ethereum

$ cd$GOPATH/src/github.com/ethereum



$ gitclonehttps://github.com/ethereum/go-ethereum

$ cdgo-ethereum

$ gitcheckoutmaster



$ gogetgithub.com/ethereum/go-ethereum



   Geth  Swarm:



goinstall-v./cmd/geth

goinstall-v./cmd/swarm



    ,   Go  .     ,     .

   ,       Geth  Swarm:



$ geth version

Geth

Version: 1.8.9-unstable

Architecture: arm



Protocol Versions: [63 62]

Network Id: 1

Go Version: go1.9.6

Operating System: linux

GOPATH=/home/book/go

GOROOT=/usr/local/go



$ swarm version

Swarm

Version: 1.8.9-unstable

Network Id: 0

Go Version: go1.9.6

OS: linux

GOPATH=/home/book/go

GOROOT=/usr/local/go



 ,   geth version   ,        ARM.




  


      ,        genesis.json.        book   node1,  ,    , ,    .      DAG       .              Web3.

       .    node1    :



$ mkdir node1



        :



$ geth datadir node1 networkid 98760 dev rpc rpcapi="db,eth,net,web3,personal,web3" console



        .

         start_node.sh ( 3.1.).

 3.1.  start_node.sh



geth datadir node1 networkid 98760 dev rpc rpcapi="db,eth,net,web3,personal,web3" console



 ,         datadir, networked, rpc  rpcapi,     .

             ,   :



$ geth datadir node1 networkid 98760 attach ipc://home/book/node1/geth.ipc



     attach_node.sh   ( 3.2.).

 3.2.  attach_node.sh



geth datadir node1 networkid 98760 attach ipc://home/book/node1/geth.ipc




    


  attach_node.sh     Geth   accounts:



> web3.eth.accounts

["0xd902f8405a6108e8bd9343d1bfccf21a081d2897"]



,       ,           ,    .     .

    web3.version:



> web3.version

{

api: "0.20.1",

ethereum: "0x3f",

network: "98760",

node: "Geth/v1.8.9-unstable/linux-arm/go1.9.6",

whisper: "6.0",

getEthereum: function(callback),

getNetwork: function(callback),

getNode: function(callback),

getWhisper: function(callback)

}



        ,     .

      :



> web3.fromWei( eth.getBalance(eth.coinbase) )

1.15792089237316195423570985008687907853269984665640564039457584007913129639927e+59

 ,         Ether,        .      geth,     dev.




 


         Ethereum   Raspberry Pi 3,      1 .

         Geth,    dev    .       , ..        .




 4.       






      Ubuntu  Debian     Go Ethereum ( Geth),    .       Raspberry Pi 3,     Rasberian  Geth         dev.

         ,   Geth    > (       Geth). ,      Geth          exit.

     Web3 JavaScript API  0.2x.x,   : https://github.com/ethereum/wiki/wiki/JavaScript-API (https://github.com/ethereum/wiki/wiki/JavaScript-API).

     1.0   ,          http://web3js.readthedocs.io/en/1.0/ (http://web3js.readthedocs.io/en/1.0/).            0.2x.x,  - 1.0-beta.xx.




   



  Ethereum,  ,   ,     .     ,    .     Ethereum      .

,    ,   Ethereum   -,   ,       .

      Ethereum         ()  ,    :



$ geth datadir node1 account new



       ,  geth  dev.          ,       .

   ,     .       ,       .




  


          book.        :



$ sh start_node.sh



      :



$ sh attach_node.sh



 start_node.sh  attach_node.sh        .

,    ,        Web3:



> web3.eth.accounts

["0x4f744742ac711fd111c7a983176db1d48d29f413"]



  ,        :



> web3.eth.accounts

["0x4f744742ac711fd111c7a983176db1d48d29f413", "0xf212d0180b331a88bd3cafbd77bbd0d56398ae00"]



    ,  ,     .       web3.eth.accounts.




 


      Geth    ,   Geth   .

   ,     test (        ):



> web3.personal.newAccount("test")

"0x346cc69a63f9b84c45f17e337574c0150ab6bc03"



     web3.personal.     ,                rpcapi (.  2).    dev  rpcapi     .

      ,         :



> web3.eth.accounts

["0x4f744742ac711fd111c7a983176db1d48d29f413", "0xf212d0180b331a88bd3cafbd77bbd0d56398ae00", "0x346cc69a63f9b84c45f17e337574c0150ab6bc03"]



      .        .       ,    .

      geth account   new.      book     :



$ geth datadir node1 account new



   ,    (),     :



INFO [02-17|23:01:28.855] Maximum peer countETH=25 LES=0 total=25

Your new account is locked with a password. Please give a password. Do not forget this password.

Passphrase:

Repeat passphrase:

Address: {ae7bb3649a5c597d44f812b4a636f3cc21ee98e1}



       .

 ,                  datadir.

       Geth     ,  ,         :



> web3.eth.accounts

["0x4f744742ac711fd111c7a983176db1d48d29f413", "0xf212d0180b331a88bd3cafbd77bbd0d56398ae00", "0x346cc69a63f9b84c45f17e337574c0150ab6bc03", "0xae7bb3649a5c597d44f812b4a636f3cc21ee98e1"]




  geth account


  geth account     ,     .    ,             ,    Geth .

 geth account   ,   . 4.1.



. 4.1.   geth account






        : https://github.com/ethereum/go-ethereum/wiki/Managing-your-accounts (https://github.com/ethereum/go-ethereum/wiki/Managing-your-accounts).




 


  ,     .               ,     .

              .         .

         , ,   -      ,   .     ,     .        ( ,    ),         .

 ,       ,         Clipboard.             .            .

       ,         , ,         .




  Ethereum


   ,        ,    -,     .   ,      ,       .        Geth,    dev,    ,      .

               ,    .

    Ethereum      .   ,  :           .          .       ,    ,        .

         (, )    .

  Ethereum

   Ethereum  Ether,  .     , ,     , .

 Ether,         Ethereum ( ,        ,   ).

     Wei.    (..  Ether)   1000000000000000000  Wei.

   ,  Wei ,  Ether,      ,    .

  4.2.       Ethereum      Wei.



 4.2.   Ethereum






        Ethereum,    : https://etherconverter.online/ (https://etherconverter.online/).      Ether      .

    

        .         Geth    web3.eth.accounts.

   web3.eth.getBalance        Wei.        :



> web3.eth.getBalance("0x4f744742ac711fd111c7a983176db1d48d29f413")

2.3085e+22



 web3.eth.getBalance    .     API  Ethereum         .        (DApp),    .

         Ether,   fromWei:



> web3.fromWei(eth.getBalance("0x4f744742ac711fd111c7a983176db1d48d29f413"))

23110



   eth.getBalance     .




      



      ,   ,  ,       , :



> web3.fromWei( eth.getBalance("0xf212d0180b331a88bd3cafbd77bbd0d56398ae00"))

0



 ,         .          ,      .     ,      .




 eth.sendTransaction


 ,          :



> web3.eth.accounts

["0x4f744742ac711fd111c7a983176db1d48d29f413", "0xf212d0180b331a88bd3cafbd77bbd0d56398ae00", "0x346cc69a63f9b84c45f17e337574c0150ab6bc03", "0xae7bb3649a5c597d44f812b4a636f3cc21ee98e1"]



> web3.fromWei( eth.getBalance("0x4f744742ac711fd111c7a983176db1d48d29f413"))

23135

> web3.fromWei( eth.getBalance("0xf212d0180b331a88bd3cafbd77bbd0d56398ae00"))

0

> web3.fromWei( eth.getBalance("0x346cc69a63f9b84c45f17e337574c0150ab6bc03"))

0

> web3.fromWei( eth.getBalance("0xae7bb3649a5c597d44f812b4a636f3cc21ee98e1"))

0



 ,       ,      .

   ,   0.05 Ether,       ,   .     eth.sendTransaction:



> eth.sendTransaction({from:"0x4f744742ac711fd111c7a983176db1d48d29f413", to:"0xf212d0180b331a88bd3cafbd77bbd0d56398ae00", value: web3.toWei(0.05, "ether")})



     , ,    :



Error: authentication needed: password or unlock

at web3.js:3143:20

at web3.js:6347:15

at web3.js:5081:36

at <anonymous>:1:1



       ,    .     :



> web3.personal.unlockAccount("0x4f744742ac711fd111c7a983176db1d48d29f413", "*********")

true



   ,     .       ,     true.

    eth.sendTransaction:



> eth.sendTransaction({from:"0x4f744742ac711fd111c7a983176db1d48d29f413", to:"0xf212d0180b331a88bd3cafbd77bbd0d56398ae00", value: web3.toWei(0.05, "ether")})

"0xb6d13a5e915c3af1feabad7caec7b45348146695973b32285df287639717e916"



             (Transaction Hash)  :



0xb6d13a5e915c3af1feabad7caec7b45348146695973b32285df287639717e916



    ,     .  ,  ,         .       .

  ,     . ,           ,    ,     :



INFO [02-17|23:20:50.917] Submitted transactionfullhash=0xb6d13a5e915c3af1feabad7caec7b45348146695973b32285df287639717e916 recipient=0xF212D0180B331a88BD3CafbD77bBd0D56398aE00

INFO [02-17|23:20:53.018] Commit new mining worknumber=4643 sealhash=0f860cd73ae1 uncles=0 txs=1 gas=21000 fees=2.1e-05 elapsed=36.186ms

INFO [02-17|23:22:10.119] Successfully sealed new blocknumber=4643 sealhash=0f860cd73ae1 hash=3c97618b0eea elapsed=1m17.116s

INFO [02-17|23:22:10.119] 


 block reached canonical chainnumber=4636 hash=3b52370e8761

INFO [02-17|23:22:10.119] 


 mined potential blocknumber=4643 hash=3c97618b0eea



,     ,     ,  ,      0.05 Ether,    :



> web3.fromWei( eth.getBalance("0xf212d0180b331a88bd3cafbd77bbd0d56398ae00"))

0.05



 eth.sendTransaction     from  to      .   value        Wei.            Ether,    Wei    web3.toWei.

,           ,       (  ).    eth.sendTransaction    gas ( ,    )  gasPrice (   Wei):



eth.sendTransaction({from:"0x208970e5e3d48a6eab968e64ba3447f6181310c1", to:"0x82a4165f21d8f1867d536e81537fc0085e5470a1",value: web3.toWei(5, "ether"), gas: 120000, gasPrice: 80000000000})




  


  ,       .       web3.eth.getTransaction,        .

      :



> web3.eth.getTransaction("0xb6d13a5e915c3af1feabad7caec7b45348146695973b32285df287639717e916")

{

blockHash: "0x3c9761fefa52a0bc563733d87163828c5fe1316d78ca89be8af18d9c818b0eea",

blockNumber: 4643,

from: "0x4f744742ac711fd111c7a983176db1d48d29f413",

gas: 90000,

gasPrice: 1000000000,

hash: "0xb6d13a5e915c3af1feabad7caec7b45348146695973b32285df287639717e916",

input: "0x",

nonce: 0,

r: "0x1e3519fbca45cc5f6a0804232c8f0362d42c8abfeaf5225536867651f53787fd",

s: "0x69e617eceec461b727a0997fd837264e02242fa16f61491e58974faaf20c49c7",

to: "0xf212d0180b331a88bd3cafbd77bbd0d56398ae00",

transactionIndex: 0,

v: "0xfc2",

value: 50000000000000000

}



      . 4.3.



 4.3.  






 ,     from   to,       Wei.

     ,    .      ,        .     blockNumber,    ,  ,       .

 v, r, s     .         .        : https://ethereum.stackexchange.com/questions/13778/get-public-key-of-any-ethereum-account (https://ethereum.stackexchange.com/questions/13778/get-public-key-of-any-ethereum-account).

  gasPrice  gas     .      ,     .  ,  gasPrice     ,     ,   gas   ,      .

    ,   ,     .     ,         .




 


   (          web3.eth.getTransaction),         .     web3.eth.getTransactionReceipt.

        ,       :



> web3.eth.getTransactionReceipt("0xb6d13a5e915c3af1feabad7caec7b45348146695973b32285df287639717e916")

{

blockHash: "0x3c9761fefa52a0bc563733d87163828c5fe1316d78ca89be8af18d9c818b0eea",

blockNumber: 4643,

contractAddress: null,

cumulativeGasUsed: 21000,

from: "0x4f744742ac711fd111c7a983176db1d48d29f413",

gasUsed: 21000,

logs: [],

logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",

root: "0xa5cdcd909d837e937189f4cffc52840111f4430bf871f07094eaea96c47d682d",

to: "0xf212d0180b331a88bd3cafbd77bbd0d56398ae00",

transactionHash: "0xb6d13a5e915c3af1feabad7caec7b45348146695973b32285df287639717e916",

transactionIndex: 0

}



     . 4.4.



 4.4.   






 ,     ,     blockNumber,         transactionIndex.

   cumulativeGasUsed  gasUsed   ,      .         ,     ,     .    Ethereum,      ,             .

     contractAddress.     -,     -   .




 


      ,         .     ,     Ethereum.

 ,               ,        .       web3.eth.getTransaction.

  ,     web3.eth.getTransactionReceipt     .    ,       .       ,         .   ,    ,    .




 5.   






 , , ,      (  )   . ,     ,         - ,        .     ,       .

          .   , ,      .    ,      ,      .         .




-  Ethereum



  Ethereum      - (Smart Contracts). -    ,      Ethereum.      ,         .

  -     , ,      ( ,        ),      .  -         ,    , ,   .




  .


   .

   ,     (https://www.litres.ru/aleksandr-frolov-198/sozdanie-smart-kontraktov-solidity-dlya-blokcheyna-et/)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


