ãã©ã€ããŒãã€ãŒãµãªã¢ã ãããã¯ãã§ãŒã³ããŒãããäœæããæ¹æ³ã¯ïŒ
Ethereumã¯ãã¹ããŒãã³ã³ãã©ã¯ããæ©èœããåæ£ãã©ãããã©ãŒã ã§ããããŠã³ã¿ã€ã ãæ€é²ãè©æ¬ºããŸãã¯ãµãŒãããŒãã£ã®å¹²æžã®å¯èœæ§ãªãã«ãå³å¯ã«ããã°ã©ã ãããæ¹æ³ã§å®è¡ãããã¢ããªã±ãŒã·ã§ã³ã§ãã ãã®èšäºã§ã¯ãããŒã«ã«ãããã¯ãŒã¯å ã«å®å šã«æ©èœããã€ãŒãµãªã¢ã ãã©ã€ããŒããããã¯ãã§ãŒã³ãäœæããããã«å¿ èŠãªãã¹ãŠã®æé ã説æããŸãã
æ瀺ã«ã¯ä»¥äžãå«ãŸããŸãã
- gethã䜿çšããŠãã©ã€ããŒãEthereumãããã¯ãã§ãŒã³ãäœæããŸã ã
- ãã©ã€ããŒããããã¯ãã§ãŒã³ãæäœããããã®MetaMaskãŠã©ã¬ããã®äœæã
- è€æ°ã®ã¢ã«ãŠã³ãéã§è³éã移åããŸãã
- remixã䜿çšããŠããã©ã€ããŒããããã¯ãã§ãŒã³ã§ã¹ããŒãã³ã³ãã©ã¯ããäœæããããã€ãããã³åŒã³åºããŸãã
- ãã©ã€ããŒããããã¯ãã§ãŒã³äžã«ã€ãŒãµãªã¢ã ãããã¯ãšã¯ã¹ãããŒã©ãŒãäœæããŸãã
Gethã®ã€ã³ã¹ããŒã«
Go EthereumïŒãŸãã¯geth ïŒã¯ãEthereumãããã³ã«ã®3ã€ã®åæå®è£ ã®1ã€ã§ãïŒC ++ããã³Pythonãšãšãã«ïŒã Goã§æžãããŠãããå®å šã«ãªãŒãã³ã§ãGNU LGPL v3ã®äžã§ã©ã€ã»ã³ã¹ãããŠããŸãã Go Ethereumã¯ãã»ãšãã©ãã¹ãŠã®OSã§å®è¡ãããã¹ã¿ã³ãã¢ãã³ã¯ã©ã€ã¢ã³ããšããŠããŸãã¯GoãAndroidãiOSãããžã§ã¯ãã«åã蟌ãããã®babliotekãšããŠããŠã³ããŒãã§ããŸãã
Mac OS Xã«gethãã€ã³ã¹ããŒã«ããã«ã¯ã homebrewã䜿çšããŸããã Homebrewã¯å¿ èŠãªãã®ããã¹ãŠã€ã³ã¹ããŒã«ããŸãããAppleã¯ãããåŠçããŸããã§ããã ãã®èšäºã¯ããã§ã«homebrewãã€ã³ã¹ããŒã«ãããŠããããšãåæãšããŠããŸãã ããã§ãªãå Žåã¯ã ãããã®æ瀺ã«åŸã£ãŠãã ãã ã homebrewãã€ã³ã¹ããŒã«ããåŸã次ã®ã³ãã³ãã§gethãã€ã³ã¹ããŒã«ããŸã ã
brew tap ethereum/ethereum
brew install ethereum
Ubuntuãžã®gethã®ã€ã³ã¹ããŒã«ã¯éåžžã«ç°¡åã§ã次ã®apt-getã³ãã³ããå®è¡ããã ãã§ãã
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
Windowsã®å Žåãé©åãªã€ã³ã¹ããŒã©ãŒã¯ãã¡ãã§ãã åé¡ãããå Žåã¯ã æé ãåç §ããŠãã ãã ã
ãã€ããŒã¢ã«ãŠã³ããäœæãã
æåã«ãã€ãŒãµãªã¢ã ããã€ãã³ã°ããããã®ã¢ã«ãŠã³ããäœæããå¿ èŠããããŸãã ãããã£ãŠãä¿è·ã®ããã«ãã¹ã¯ãŒãä»ãã®ç§å¯éµãšå ¬ééµã®ãã¢ãçæããŸãã ãã¹ã¯ãŒããçŽå€±ããªãã§ãã ãããããããªããšãããŒãå埩ã§ããªããªããŸãã ããã©ã«ãã§ã¯ãããŒã¯<datadir> / keystoreå ã«ä¿åãããŸã ã gethãä¿åãããã®ã¯ãã¹ãŠã datadirå ã«ä¿åãããŸã ïŒPoW Ethash DAGãé€ãïŒã ããã©ã«ãã®ãã£ã¬ã¯ããªã®å Žæã¯OSã«äŸåããŸãã ããã©ã«ãèšå®ãå€æŽãããã©ã€ããŒããããã¯ãã§ãŒã³ã®ç¬èªã®ãã¹ãèšå®ããããšããå§ãããŸãã
- MacïŒã/ã©ã€ãã©ãª/ Ethereum
- LinuxïŒã/ .ethereum
- WindowsïŒïŒ APPDATAïŒ \ Ethereum
Ethash DAGã¯ã/ .ethashïŒMac / LinuxïŒãŸãã¯ïŒ APPDATAïŒ \ EthashïŒWindowsïŒã«ä¿åãããããããã¹ãŠã®ã¯ã©ã€ã¢ã³ãã䜿çšã§ããŸãã
次ã®ã³ãã³ãã¯ãããŒã¿ãã£ã¬ã¯ããªã®ä»»æã®ãã¹ã§ã¢ã«ãŠã³ããäœæããæ¹æ³ã瀺ããŠããŸãã ãã®ã³ãã³ãã¯ãEthereumã¢ãã¬ã¹ãæäŸããŸãã
geth account new --datadir <path-to-data-directory>
äŸïŒ
geth account new --datadir /path/to/data/dir
ãã©ã€ããªãããã¯ïŒãžã§ãã·ã¹ãããã¯ïŒã®äœæ
ã€ãŒãµãªã¢ã ãããã¯ãã§ãŒã³ã¯ããã©ã€ããªãããã¯ãäºãã«ç°ãªããŸãã åãããã¯ãã§ãŒã³ã¯ãã®ãããªãããã¯ã§å§ãŸããä»ã®ãã¹ãŠã¯ãã®äžã«æ§ç¯ãããåŸç¶ã®åãããã¯ã¯åã®ãããã¯ãåç §ããŸãã Ethereumãããªãã¯ãããã¯ãã§ãŒã³ã§ã¯ããã©ã€ããªãããã¯ã2015幎7æ20æ¥ã«äœæãããŸããã ç¬èªã®ãã§ãŒã³ã§ã¯ãç¬èªã®ãã©ã€ããªãããã¯ãäœæããå¿ èŠããããŸãã ãã©ã€ããŒããããã¯ãã§ãŒã³ã¯ã次ã®ã³ãã³ãã«ãããæå®ããããã©ã€ããªãããã¯ã§åæåãããŸãã
geth -datadir <path-to-data-directory> init <path-to-genesis-block>
äŸïŒ
geth -datadir /path/to/data/dir init /path/to/genesis.json
- datadir ïŒããŒã¿ããŒã¹ããã³ããŒã¹ãã¢ã®ãã£ã¬ã¯ããªã
- init ïŒå¯Ÿå¿ããjsonãã¡ã€ã«ã䜿çšããŠãæ°ãããã©ã€ããªãããã¯ãããŒãã¹ãã©ããããŠåæåããŸãã
以äžã¯ããã©ã€ããŒããããã¯ãã§ãŒã³ã§äœ¿çšããããã©ã€ããªãããã¯ã§ããgenesis.jsonãšããååã§ä¿åããäžèšã®ã³ãã³ãã§æå®ããå¿ èŠããããŸãã
{ "config": { "chainId": 15, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0 }, "difficulty": "0x400", "gasLimit": "0x2100000", "alloc": { "7a69b359e86893efa3d9732e4c65ced51567edd0": { "balance": "0x1337000000000000000000" } } }
- chainid ïŒETCïŒEthereum ClassicïŒãŸãã¯Mordenãã¹ããããã¯ãŒã¯ã䜿çšããã«Ethereumã§ãã©ã³ã¶ã¯ã·ã§ã³ãäœæããæ¹æ³ãæäŸããŸãã EIP 155ã¯ãããŸããŸãªãããã¯ãŒã¯ã«å¯ŸããŠæ¬¡ã®ãã§ãŒã³IDå€ãæäŸããŸããã¡ã€ã³ãããã¯ãŒã¯EthereumïŒ1ïŒãã¡ã€ã³ãããã¯ãŒã¯Morden / ExpanseïŒ2ïŒãRopstenïŒ3ïŒãRinkebyïŒ4ïŒãã¡ã€ã³ãããã¯ãŒã¯ã«ãŒãã¹ããã¯ïŒ30ïŒããã¹ããããã¯ãŒã¯ã«ãŒãã¹ããã¯ïŒ31ïŒã KovanïŒ42ïŒãEthereum Classicã¡ã€ã³ãããã¯ãŒã¯ïŒ61ïŒãEthereum Classicãã¹ããããã¯ãŒã¯ïŒ62ïŒããã©ã€ããŒãgethãã§ãŒã³ïŒããã©ã«ãã§ã¯1337ïŒã ãã®äŸã§ã¯ãæ¢åã®åç·ã§äœ¿çšãããŠããªãèå¥å15ãæå®ããŸããã
- homesteadBlock ïŒå€0ã¯ãEthereum HomesteadãªãªãŒã¹ã®äœ¿çšã瀺ããŸãã ããã¯ãã€ãŒãµãªã¢ã ã®2çªç®ã®ã¡ãžã£ãŒãªãªãŒã¹ã§ããæè¿ã2017幎10æ16æ¥ã«ãã€ãŒãµãªã¢ã ã¯ByzantiumãªãªãŒã¹ã«åœãããŸãã ã
- eip155Block ïŒå€0ã¯ããã®ãŠããããEIPïŒEthereumæ¹åææ¡ãEthereumæ¹åææ¡ïŒçªå·155ããµããŒãããããšã瀺ããŸããEIPææ¡ã¯ãäž»èŠãªãããã³ã«ä»æ§ãã¯ã©ã€ã¢ã³ãAPIãå¥çŽæšæºãªã©ãEthereumãã©ãããã©ãŒã ã®æšæºãèšè¿°ããŸãã
- eip158Block ïŒå€0ã¯ããã®ãããã¯ãEIP 158ããµããŒãããããšã瀺ããŸãã
- é£æ床 ïŒå€ã¯ããã®ãããã¯ã®ã©ã³ãã ãªãã³ã¹å€ãæ€çŽ¢ããããã«äœ¿çšãããé£æ床ã¬ãã«ã«å¯Ÿå¿ããŸãã ãã®èšäºã§ã¯ãã€ãŒãµãªã¢ã ã®é£æ床ã®èšç®æ¹æ³ã«ã€ããŠè©³ãã説æããŸãã
- gasLimit ïŒã¬ã¹ã¯ãã€ãŒãµãªã¢ã ã§ååŒãŸãã¯å¥çŽãè¡ãããã®å éšæ¯æãåäœã§ãã ãã©ã³ã¶ã¯ã·ã§ã³ãŸãã¯ã¹ããŒãå¥çŽãåŠçããããã«ã€ãŒãµãªã¢ã ä»®æ³ãã·ã³ïŒEVMïŒã«éä¿¡ãããååœä»€ã«ã¯ãäžå®éã®ã¬ã¹ãããããŸãã ãã©ã³ã¶ã¯ã·ã§ã³ãå¿ èŠãªéã®ã¬ã¹ãåãåããªãå ŽåãééããŸããã Ethereumã§åãã©ã³ã¶ã¯ã·ã§ã³ãäœæãããšããã¬ã¹å¶éïŒãã®ãã©ã³ã¶ã¯ã·ã§ã³ã®ãã¹ãŠã®é¢é£æäœã䜿çšã§ããæ倧éïŒãæå®ããŸãã ãããã¯å ã®gasLimitãã©ã¡ãŒã¿ãŒã¯ããããã¯å ã®ãã¹ãŠã®ãã©ã³ã¶ã¯ã·ã§ã³ã®åèšå¶éã決å®ããŸãã
- alloc ïŒãã©ã€ããªãããã¯ãã1ã€ä»¥äžã®ã¢ã«ãŠã³ããžã®Etherã®äºåé åžã®ãã©ã¡ãŒã¿ãŒã äžèšã®ãã©ã€ããªãããã¯ã®äŸã§ã¯ããã¹ãŠã®Etherã¯æåããäœæãããã¢ã«ãŠã³ãã«éãããŸãã
ãã€ãã³ã°ãéå§
ãã¹ãŠæºåå®äºã§ãïŒ ããã§ã次ã®ã³ãã³ãã䜿çšããŠgethãããã€ãã³ã°ãéå§ã§ããŸãã ããã§ã networkidãã©ã¡ãŒã¿ãŒã¯ããã®ã€ãŒãµãªã¢ã ãããã¯ãŒã¯ãä»ã®ãã®ãšåºå¥ããŸãã ãã®ãããã¯ãŒã¯ãžã®æ¥ç¶ãåžæãããã¹ãŠã®ãã€ããŒã¯ãåããã©ã€ããªãããã¯ã§åããããã¯ãŒã¯IDã䜿çšããå¿ èŠããããŸãã
geth --mine --rpc --networkid <networkd-id> --datadir <path-to-data-directory>
äŸïŒ
geth --mine --rpc --networkid 1999 --datadir /path/to/data/dir
- networkid ïŒãã®ã€ãŒãµãªã¢ã ãããã¯ãŒã¯ã®ãããã¯ãŒã¯èå¥åã ä»»æã®å€ãéžæããŠãã ããã ããšãã°ããªãªã³ããã¯ïŒ0ïŒãããã³ãã£ã¢ïŒ1ïŒãã¢ãŒãã³ïŒ2ïŒããããã¹ãã³ïŒ3ïŒã
- mine ïŒãã€ãã³ã°ãå«ã¿ãŸãã
- rpc ïŒHTTP-RPCãµãŒããŒãæå¹ã«ããŸãã ãŠã©ã¬ããã¢ããªã±ãŒã·ã§ã³ã¯ãhttpãä»ããŠãã®ãã€ãã³ã°ããŒãã«æ¥ç¶ã§ããŸãã
- rpcaddr ïŒHTTP-RPCãµãŒããŒã§ãªãã¹ã³ããã€ã³ã¿ãŒãã§ã€ã¹ãæå®ããŸãïŒããã©ã«ãïŒãlocalhostãïŒ
- rpcport ïŒHTTP-RPCãµãŒããŒã§ãªãã¹ã³ããããŒããæå®ããŸãïŒããã©ã«ãïŒ8545ïŒ
- rpcapi ïŒHTTP-RPCã€ã³ã¿ãŒãã§ãŒã¹ã§äœ¿çšå¯èœãªAPIã瀺ããŸãïŒããã©ã«ãïŒâ ethãnetãweb3âïŒ
- rpccorsdomain ïŒCORSãã¢ã¯ãã£ãã«ããèŠæ±ãåãå
¥ããïŒã¯ãã¹ãªãªãžã³ïŒãµãŒãããŒãã£ãã¡ã€ã³ã®ã³ã³ãåºåããªã¹ããæå®ããŸãã SolidityïŒRemixïŒãã©ãŠã¶ãŒãšãã£ã¿ãŒãŸãã¯ãã©ãŠã¶ãŒãŠã©ã¬ããã䜿çšããŠã¹ããŒãã³ã³ãã©ã¯ããé
眮ããå Žåã«åœ¹ç«ã€ãªãã·ã§ã³ã ããšãã°ããã®ãªãã·ã§ã³ã䜿çšãããšãä»»æã®ãã¡ã€ã³ããCORSãåãå
¥ããããšãã§ããŸãã
--rpccorsdomain "*"
- nodiscover ïŒ ãã¢æ€çŽ¢ãšã³ãžã³ãç¡å¹ã«ããŸãã ãããã¯ãŒã¯äžã®ä»ã®ããŒãã¯ãµã€ããèŠã€ããããšãã§ããŸããã ããŒã«ã«ãããã¯ãŒã¯ã§ãããã¯ãã§ãŒã³ãä»ã®ãããã¯ãã§ãŒã³ãšãšãã«äœ¿çšããå Žåã¯ããã®ãã©ã¡ãŒã¿ãŒã䜿çšããªãã§ãã ããã
- console ïŒãã®ã³ãã³ãã䜿çšãããšãã€ã³ã¿ã©ã¯ãã£ããªJavaScriptç°å¢ã§ãã€ãã³ã°ããŒããéå§ã§ããŸãã 次ã®ã»ã¯ã·ã§ã³ã§ã¯ããã®ãããã¯ã詳ããèŠãŠãããŸãã
geth --mine --rpc --networkid 1999 --datadir /path/to/data/dir console
Gethã³ã³ãœãŒã«ãæ¥ç¶ããŸã
ã³ã³ãœãŒã«ãšããŠãã€ãã³ã°ãéå§ãããã ã³ã³ãœãŒã«ãåå¥ã«å®è¡ããŠã attachã³ãã³ãã§ãã€ãã³ã°ããŒãã«æ¥ç¶ããŸãã 次ã«ããããã©ã®ããã«è¡ããããã瀺ããåãé åºã§ãã©ã¡ãŒã¿ãŒãæå®ããããšã確èªããŸãã
geth --datadir <path-to-data-directory> attach ipc:<path-to-data-directory>/geth.ipc
äŸïŒ
geth --datadir /path/to/data/dir attach ipc:/path/to/data/dir /geth.ipc
ã³ã³ãœãŒã«ã¯ã IPCãä»ããŠãã€ãã³ã°ããŒãã«æ¥ç¶ããŸãã IPC ïŒããã»ã¹ééä¿¡ïŒã¯ããŒã«ã«ã³ã³ãã¥ãŒã¿ãŒã§å®è¡ãããŸãã ãã®å Žåã gethã¯ããŒã«ã«ã³ã³ãã¥ãŒã¿ãŒã®ãã¡ã€ã«ã·ã¹ãã ã«Gethãã€ãã©ã€ã³ïŒãã¡ã€ã«<path-to-data-directory> /geth.ipcã§è¡šããã ïŒãäœæããã³ã³ãœãŒã«ã¯IPCãä»ããŠãã®ããŒãã«æ¥ç¶ããŸãã
ãã¹ãŠã®ã¢ã«ãŠã³ãã衚瀺
gethã³ã³ãœãŒã«ã«æ¥ç¶ãããã次ã®ã³ãã³ããå®è¡ããŠã䜿çšå¯èœãªãã¹ãŠã®ã¢ã«ãŠã³ãã衚瀺ã§ããŸãã
> eth.accounts
["0x7a69b359e86893efa3d9732e4c65ced51567edd0"]
ã¢ã«ãŠã³ãæ®é«ã衚瀺
次ã®ã³ãã³ãã䜿çšãããšãç¹å®ã®ã¢ã«ãŠã³ãã®æ®é«ãgethã³ã³ãœãŒã«ãã衚瀺ã§ããŸãã
> eth.getBalance("0x7a69b359e86893efa3d9732e4c65ced51567edd0")
1.295e+21
MetaMask Ethereum Walletã®æ¥ç¶
MetaMaskã¯ãChromeæ¡åŒµæ©èœãšããŠæ©èœããEthereumãŠã©ã¬ããã§ãã ãµã€ãã®ãã¹ãŠã®JavaScriptã³ã³ããã¹ãã«Ethereum Web3 APIãçµã¿èŸŒãŸããŠããããããããã®ã¢ããªã±ãŒã·ã§ã³ã¯ãã¹ãŠãããã¯ãã§ãŒã³ããæ å ±ãåãåãããšãã§ããŸãã MetaMaskã䜿çšãããšãç¬èªã®IDãäœæããã³ç®¡çã§ãããããã¢ããªã±ãŒã·ã§ã³ããã©ã³ã¶ã¯ã·ã§ã³ãå®äºããŠããŒã¿ããããã¯ãã§ãŒã³ã«æžã蟌ãå ŽåããŠãŒã¶ãŒã¯ãã©ã³ã¶ã¯ã·ã§ã³ãæ¿èªãŸãã¯æåŠããåã«ãã©ã³ã¶ã¯ã·ã§ã³ã衚瀺ããå®å šãªã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšã§ããŸãã
MetaMaskãEthereumãã©ã€ããŒããããã¯ãã§ãŒã³ã«æ¥ç¶ããã«ã¯ãæ£ãããã¹ãåãšããŒããéžæããå¿ èŠããããŸãã Web3 APIã¯ã web3.jsã«å®è£ ãããŠããã€ãŒãµãªã¢ã çšã®JavaScriptããã°ã©ãã³ã°ã€ã³ã¿ãŒãã§ã€ã¹ã§ãã JavaScriptã¢ããªã±ãŒã·ã§ã³ãã€ãŒãµãªã¢ã ããŒããšéä¿¡ããããã«ãMetaMaskã¯web3.jsã©ã€ãã©ãªãšrpcã¡ãœããã®äŸ¿å©ãªã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšããŸãã ããŒã«ã«ãã¹ããšrpcåŒã³åºãã亀æããŸã ã web3.jsã©ã€ãã©ãªã¯ã rpcã¬ã€ã€ãŒãæã€ä»»æã®EthereumããŒãã§åäœããŸãã ãã€ãã³ã°ããŒãã®èµ·åæã«ã rpcapiãã©ã¡ãŒã¿ãŒãæž¡ããŠããã®ããŒãã§äœ¿çšããã€ã³ã¿ãŒãã§ã€ã¹ãæå®ã§ããããšã«æ°ã¥ãããããããŸããã ããã©ã«ãã§ã¯ãäœãæå®ãããŠããªãå Žåãã€ã³ã¿ãŒãã§ãŒã¹ethãnetãweb3ã䜿çšãããŸãã
空æ°äŒé
MetaMaskã¯ãã€ãŒãµãªã¢ã ã¢ã«ãŠã³ãïŒã€ãŒãµãªã¢ã ã®ç§å¯ããŒãšã¢ãã¬ã¹ïŒãäœæããŸãã 次ã«ãæåã«äœæãããæåã®ã¢ã«ãŠã³ãããgethã³ã³ãœãŒã«ããMetaMaskã¢ã«ãŠã³ãã«Etherã転éããæ¹æ³ãèŠã€ããŸãã ã¢ã«ãŠã³ãã®è³éã転éããã«ã¯ããã®ã¢ã«ãŠã³ãã®ç§å¯éµã䜿çšããŠçœ²åããå¿ èŠããããŸãã 以äžã«ç€ºãããã«ãããã䜿çšããã«ã¯ãæåã«ããã¯ã解é€ããå¿ èŠããããŸãã
> personal.unlockAccount( "0x7a69b359e86893efa3d9732e4c65ced51567edd0","password")
personalã¯gethã®å¶åŸ¡ããã°ã©ã ã€ã³ã¿ãŒãã§ã€ã¹ã§ã ã å人ã«å ããŠã gethã¯admin ã debug ã minerãããã³txpoolã®ç®¡çAPIãæäŸããŸãã ã¢ã«ãŠã³ãã®ããã¯ã解é€ãããšãã³ã³ãœãŒã«ã§3ã€ã®å€æ°ãå®çŸ©ã§ããŸããsender ã receiver ãããã³amount ãã€ãŸããåä¿¡è ãéä¿¡è ãããã³è»¢éãããè³éã®éã§ãã éä¿¡è ã®å€ã¯ãã®èšäºã®åé ã§äœæããã€ãŒãµãªã¢ã ã¢ãã¬ã¹ã§ããã åä¿¡è ã®å€ã¯MetaMaskã§äœæãããã€ãŒãµãªã¢ã ã¢ãã¬ã¹ã§ãã
> var sender = "0x7a69b359e86893efa3d9732e4c65ced51567edd0";
> var receiver = "0xA9f28458eE1170F285440990c196c1592D3a73f5"
> var amount = web3.toWei(1, "ether")
次ã®ããŒã ã¯è³éã転éããŸã-ããã¯äžã§å®çŸ©ããå€æ°ãåç §ããŸãã
> eth.sendTransaction({from:sender, to:receiver, value: amount})
MetaMaskã§å£åº§æ®é«ã衚瀺
äžèšã®æé ã«åŸã£ãŠè³éã®æ¯æ¿ãå®äºãããã2ã€ã®æ¹æ³ã§å£åº§æ®é«ã衚瀺ã§ããŸãã æåã®æ¹æ³ã¯ã以äžã«ç€ºãããã«ãMetaMaskãã©ã°ã€ã³ããçŽæ¥ã§ãã
å¥ã®æ¹æ³ã¯ã次ã®ã³ãã³ãã䜿çšããŠgethã³ã³ãœãŒã«ã䜿çšããããšã§ãã
< eth.getBalance("0xA9f28458eE1170F285440990c196c1592D3a73f5")
1000000000000000000
Solidityã®Remix Editor
Solidityã¯ãæã人æ°ã®ããEthereumã¹ããŒãã³ã³ãã©ã¯ãããã°ã©ãã³ã°èšèªã§ãã Remixã¯ãçµã¿èŸŒã¿ã®ãããã¬ãŒãšãã¹ãç°å¢ãåããSolidityçšã®IDEã§ãã ãªããã¯ã¹ãªã³ã©ã€ã³ãšãã£ã¿ã¯ãã¡ãã«ãããŸã ã Remixã¯ä»»æã®Ethereumãããã¯ãŒã¯ã«æ¥ç¶ããŸãã ããŒã«ã«ãããã¯ãã§ãŒã³ã«æ¥ç¶ããã«ã¯ã以äžã«ç€ºãããã«ã次ã®ã³ãã³ãã䜿çšããŠãã€ãã³ã°ããŒããèµ·åããŠãã ããã
--rpccorsdomain "*"
ãã©ã¡ãŒã¿ãŒã«ã€ããŠã¯æ¢ã«èª¬æããŸããã ã¢ã¹ã¿ãªã¹ã¯ïŒæ倧ãªãŒãã³æ§ïŒã®ä»£ããã«ããã®ãã©ã¡ãŒã¿ãŒã®å€ãšããŠãhttps://remix.ethereum.orgããæå®ã§ããŸãã
geth --mine --rpc --rpccorsdomain "*" --networkid <networkd-id> --datadir <path-to-data-directory>
ãªããã¯ã¹ãéãããããã¯ãŒã¯ã«æ¥ç¶ããã«ã¯ã[ ç°å¢ ]ã[ Web3ãããã€ã㌠]ã«å€æŽããå¿ èŠããããŸããããã¯[ å®è¡ ]ã¿ãã§è¡ããŸãã ãã®å€æŽã«ããã remixã¯Web3ãããã€ããŒãšã³ããã€ã³ããæå®ããããèŠæ±ããŸã-å€ã
http://localhost:8545
èšå®ããŸãã ããŒããæ瀺çã«å€æŽãããŸã§ãããã©ã«ãã§ã¯ããã€ãã³ã°ããŒãã¯ããŒã8545ã§èµ·åããŸãã
ã¹ããŒãã³ã³ãã©ã¯ããäœæãã
ããã§ãEthereumãããã¯ãŒã¯ã§éå§ããæåã®ã¹ããŒãã³ã³ãã©ã¯ããäœæããæºåããã¹ãŠæŽããŸããã 次ã®ã³ãŒããã³ããŒããŠã ãªããã¯ã¹ãªã³ã©ã€ã³ãšãã£ã¿ãŒã«è²Œãä»ããŸãã ããã¯éåžžã«ã·ã³ãã«ãªã¹ããŒãã³ã³ãã©ã¯ãã§ããäžè¡ãã€èª¬æãããã¯ãããŸããã 次ã®èšäºã§ã¯ãããã°ã©ãã³ã°èšèªSolidityã«ã€ããŠè©³ããæ€èšããŸãã
pragma solidity ^0.4.11; contract Hello { // a string variable string public greeting; // the function with the same name as the class is a constructor function Hello(string _greeting) { greeting = _greeting; } // change the greeting message function setGreeting(string _greeting) { greeting = _greeting; } // get the greeting message function greet() constant returns (string _greeting) { _greeting = greeting; } }
remixã§ããã©ã«ãèšå®ãå€æŽããªãã£ãå Žåã¯ãèªåçã«ã³ã³ãã€ã«ããããã«èšå®ãããŸãã ããã§ãªãå Žåã¯ãã³ãŒããã³ã³ãã€ã«ããå¿ èŠããããŸãã
ã³ã³ãã€ã«åŸã[ 詳现 ]ãã¿ã³ãã¯ãªãã¯ãããšããã®ã¹ããŒãã³ã³ãã©ã¯ãã®äœæã«å¿ èŠãªæšå®ã¬ã¹éã衚瀺ãããŸãã
ã¹ããŒãã³ã³ãã©ã¯ãã®å®è£
ããã§ããã©ã€ããŒããããã¯ãã§ãŒã³ã«ã¹ããŒãã³ã³ãã©ã¯ããå®è£ ã§ããŸãã [ å®è¡ ]ã¿ãã§ãæ£ããã€ãŒãµãªã¢ã ã¢ã«ãŠã³ããšæ£ããã¬ã¹å¶éãéžæãããŠããããšã確èªããŸãã ã¬ã¹ã®äŸ¡æ Œãšå€ã¯ãŒããšããŠæå®ã§ããŸãã
ãããã¯ãã§ãŒã³ã§ã¹ããŒãã³ã³ãã©ã¯ããäœæããããã«ãäžèšã§éžæããã¢ã«ãŠã³ããã眲åãããã€ãŒãµãªã¢ã ãã©ã³ã¶ã¯ã·ã§ã³ã¯æ¬¡ã®ãšããã§ãã ãµã€ã³ã¢ããããã«ã¯ããŸãgethã³ã³ãœãŒã«ããã¢ã«ãŠã³ãã®ããã¯ã解é€ããå¿ èŠããããŸãã
> personal.unlockAccount( "0x7a69b359e86893efa3d9732e4c65ced51567edd0","password")
ããã§ã[ äœæ ]ãã¿ã³ãã¯ãªãã¯ããŠã¹ããŒãã³ã³ãã©ã¯ããäœæã§ããŸãã æååãã©ã¡ãŒã¿ãŒãåãåãã³ã³ã¹ãã©ã¯ã¿ãŒããããŸãããã®ããã remixã¯[ äœæ ]ãã¿ã³ãšå ±ã«å ¥åãã£ãŒã«ãã衚瀺ããŸãã ããã«å€ãå ¥åããããšãã§ããŸãïŒåŒçšç¬Šã§å²ãã§ãããšãã°ãHiãïŒ-ãŸãã¯åã«ç©ºçœã®ãŸãŸã«ããŸãã ã¹ããŒãã³ã³ãã©ã¯ããäœæãããšã gethã³ã³ãœãŒã«ã«æ¬¡ã®ã¡ãã»ãŒãžã衚瀺ãããŸãã ãŸããæ£ããã¬ã¹å¶éãèšå®ãããŠããªãå Žåããã®ãããªã³ãã³ãã¯ãšã©ãŒã«ã€ãªããããšã«æ³šæããŠãã ããã
INFO [10-19|07:31:08] Submitted contract creation fullhash=0xf5511bb9d088672ac0d3896b8590b9a3e25484300f02deecdd739c3a549ed33a contract=0x42b7E903Fb42e191a7D623cbb4b7b4330D329d78
ã¹ããŒãã³ã³ãã©ã¯ãã³ãŒã«
ã¹ããŒãã³ã³ãã©ã¯ããäœæããåŸã ãªããã¯ã¹ã€ã³ã¿ãŒãã§ã€ã¹ã¯å°ãå€æŽãããŸã-以äžã«ç€ºãããã«ã[ å®è¡ ]ã¿ãã§ã
ããã§ã setGreetingã¡ãœããã«ç¹å®ã®å€ãèšå®ãããããã¯ãªãã¯ããŠã¹ããŒãã³ã³ãã©ã¯ããåŒã³åºãããšãã§ããŸãã ç¹°ãè¿ããŸãããã¹ããŒãã³ã³ãã©ã¯ããåŒã³åºããšãã€ãŒãµãªã¢ã ãã©ã³ã¶ã¯ã·ã§ã³ã䜿çšãããéå§è ã®çœ²åãå¿ èŠã«ãªããããã¢ã«ãŠã³ãã®ããã¯ã解é€ãããŠããããšã確èªããå¿ èŠããããŸãã setGreetingã䜿çšããŠæäœãå®äºãããšãä»ã®ã¡ãœãããåŒã³åºãããšãã§ããŸãã
ã€ãŒãµãªã¢ã ãããã¯ãšã¯ã¹ãããŒã©ãŒ
Ethereumãããªãã¯ãããã¯ãã§ãŒã³ãã¹ãã£ã³ããããã®etherscanãµãŒãã¹ã«ç²ŸéããŠãããããããŸããã ãã ããããŒã«ã«ãããã¯ãã§ãŒã³ã«éä¿¡ããããšã¯ã§ããŸããã Ethereum Block Explorerã¯æ©èœãetherscanãšæ¯èŒãããŠããŸããããããŒã«ã«ãããã¯ãã§ãŒã³ã§äœãèµ·ãã£ãŠãããã調ã¹ãã®ã«éåžžã«é©ããŠããŸãã
ããã°ã©ã ãã€ã³ã¹ããŒã«ããã«ã¯ããŸã次ã®ãªããžããªãããœãŒã¹ãååŸããŸãã
git clone https://github.com/carsenk/explorer
次ã«ãEthereum Block Explorerãã£ã¬ã¯ããªããã€ã³ã¹ããŒã«ã³ãã³ããå®è¡ããŸãã
npm install
ã€ã³ã¹ããŒã«ãå®äºãããã次ã®ã³ãã³ãã§ã€ãŒãµãªã¢ã ãããã¯ãšã¯ã¹ãããŒã©ãŒãèµ·åãã
http://localhost:8000
ä»ããŠWebã³ã³ãœãŒã«ã«ã¢ã¯ã»ã¹ããŸãã
npm start
Ethereum Block ExplorerãããŒã«ã«ãããã¯ãã§ãŒã³ã«æ¥ç¶ããåã«ããã©ã¡ãŒã¿
--rpccorsdomain "*"
æå®ãã次ã®ã³ãã³ãã§ãã€ãã³ã°ããŒããèµ·åããŠãã ãã-ãã®å€ã«ã€ããŠã¯åã«èª¬æããŸããã
geth --mine --rpc --rpccorsdomain "*" --networkid <networkd-id> --datadir <path-to-data-directory>
æŽæ° ïŒHacker Newsã«é¢ãããã®èšäºã®è°è«ã«ã€ããŠã¯ã ãã¡ããåç §ããŠãã ãã ã æ°è»œã«åå ããŠãã ããã
ãŸãšã
ãã®èšäºã§ã¯ã gethã䜿çšããŠãã©ã€ããŒãEthereumãããã¯ãã§ãŒã³ãäœæããæ¹æ³ã«ã€ããŠèª¬æããŸããã 次ã«ããã®ãããã¯ãã§ãŒã³ã§åäœããMetaMaskãŠã©ã¬ãããã»ããã¢ããããMetaMaskã§äœæãããEthereumã¢ã«ãŠã³ãã«è³éã転éããŸããã ã¹ããŒãã³ã³ãã©ã¯ããäœæãå®è£ ãåŒã³åºãããã«ããªã³ã©ã€ã³ãªããã¯ã¹ IDEã䜿çšãããŸããã æåŸã«ããã©ã€ããŒããããã¯ãã§ãŒã³ã調ã¹ãããã«Ethereum Block Explorerãã€ã³ã¹ããŒã«ããŸããã