ソリデイテイで、最初の貴方のイーサリアム スマート契約を構築-チュートリアル

Build Your First Ethereum Smart Contract with Solidity —Tutorial
ソリデイテイで、最初の貴方のイーサリアム スマート契約を構築-チュートリアル
Pete Humiston
ピート ハミストン著
“The more I read, the more I acquire, the more certain I am that I know nothing.”
「読めば読むほど、いっそう多くを獲得します。いっそう確かであればあるほど、私が何も知らないということです。」
Nov 12, 2017
2017年11月12日
So you wanna build a smart contract? Perhaps you want to understand how they work, maybe you want to build your own Dapp, maybe you want to launch the very first billion dollar ICO (sarcasm)... Regardless of your intentions, learning how smart contracts work is invaluable. The Ethereum platform possesses enormous potential to create Dapps that could change the way we interact on the web in the decades to come. While Ethereum deploys smart contracts that work much like a standard blockchain transaction, they yield a conditional statement that must be met before a function(s) is executed. Smart contracts can be used for voting, crowdfunding, blind auctions, multi-signature wallets and MUCH more.
それであなたはスマート契約を作りたいですか? 多分あなたは彼らがどのように働くか理解することを望みます、多分あなたはあなた自身の Dapp を作ることを望み、多分あなたは・・・まさしくその最初の10億ドルの ICO (皮肉)を開始することを望みます。 あなたの意図にかかわらず、スマート契約がどのようにうまくいくか学ぶことは非常に貴重です。 イーサリアムプラットホームは来たるべき数十年に我々がウエブで相互作用する方法を変えることができた Dapps を作成する巨大な可能性を有します。 イーサリアムが標準的なブロックチェーン取引とほとんど同じようにうまくいくスマート契約を配置する一方で、彼らは、ファンクションが実行される前に、直面されなくてはならない条件付きの陳述をもたらします。 スマート契約が投票、クラウドファンディング、盲目的なオークション、多署名ウオレットとはるかに多くのために使われる可能性があります。
A Quick Smart Contract Example:
ある理解しやすいスマート契約例:
Bob has his own scrap metal depot business in the United States, Eric is his iron scrap supplier. Eric is based out of China. Bob and Eric have a GREAT business relationship. They trust each other and have been doing business for a long time. Both have booming businesses, and Bob in particular sells out of iron scrap on a routine basis. Bob deploys a contract where once his iron scrap inventory reaches a certain range, he automatically sends an order out to Eric for X lbs of iron scrap at Y ether per ton. Eric agrees to the arrangement and accepts Bob’s payment in ether right away. Eric gets to work right away and starts fulfilling Bob’s order. Eric can exchange his ether at a local exchange online for Yuan for a tiny fee and it’ll be processed instantaneously. Whether Eric decides to hold ether or convert to Yuan is his choice, but either way he can now put this capital to work right away!
ボブは合衆国で彼自身のくず鉄貯蔵ビジネスを持っていて、エリックは彼の鉄のスクラップ供給元です。 エリックは中国に拠点を置いています。 ボブとエリックは大きいビジネス関係を持っています。 彼らはお互いに信頼し合って、そして長い間ビジネスをしていました。 両方ともはブームのビジネスを持っていて、ボブは決まりきった仕事ベースで特に鉄のスクラップを売り切ります。 ボブは彼の鉄のスクラップ在庫がある範囲に達すると、彼が1トンについてYイーサでXポンド鉄のスクラップのために自動的にエリックにオーダーを送りだすように契約します。 エリックは取り決めに同意して、すぐにイーサでボブの支払いを受け入れます。 エリックはすぐに仕事場に到着して、ボブのオーダーを満たし始めます。 エリックはごく小さい料金で彼のイーサをローカルな為替オンラインで中国の元と交換することができます、そしてそれは直ちに処理されるでしょう。 エリックがイーサを持つことに決めるか、あるいは元に換わるかどうかは彼の選択ですが、いずれにしても彼は今やただちにこの資本を利用することができます!
Both parties are ecstatic! Typically Bob has to contact his bank and request a money wire to be sent to Eric’s bank in China. It typically takes ~48 hours to process the wire transfer, at which point Eric will have to wait another few days for his bank to clear the payment. Not only that, Bob’s bank is going to charge him a fee for wiring money to Eric… Time and money out the window. To make matters worse, both parties have to deal with the headache of foreign exchange, turning the US Dollars into Chinese Yuan.
両者は有頂天になっています! 典型的にはボブは彼の銀行と連絡を取って、そしてエリックの中国にある銀行に電信で送金するように要請しなければなりません。 典型的にエリックは電信送金を処理するのに48時間は要します。さらにその点で数日彼の銀行が支払いをクリアするのを待たなければならないでしょう。それだけでなく、ボブの銀行はエリックに電信送金に対して、---その窓口からの時間とお金に料金を請求するでしょう。 さらに悪いことに、両者は、USドルを中国元に変えて、外貨交換の頭痛の種を処理しなければなりません。
So What Am I Going to Learn?
それでこれから私は何を学びますか?
As the saying goes, “you have to crawl before you can walk”. Before we get to deploying our first contract it’s important we learn a few basics. More importantly, I’d like to point out that Ethereum’s platform launched in 2016. While still in it’s infancy, now is the perfect time to start learning about smart contracts.
格言が言うように「あなたが歩けるようになる前に、あなたは這わなければなりません」。 我々が我々の最初の契約を配置することを始める前に、我々が少数の基本を学ぶことは重要です。 もっと重要なことに、私は イーサリアムのプラットホームが2016年に始動したことを指摘したいです。 まだ幼少期である一方で、今はスマート契約について学び始める完ぺきな時です。
In this tutorial we’re going to learn about:
このチュートリアルで我々は下記を学ぼうとしています:
• Ethereum Nodes
イーサリアム ノード
• Building A Private Blockchain Network
私的ブロックチェーンネットワークを構築
• MetaMask Browser Plug In
メタマスクブラウザプラグイン
• Mist Browser
Mistブラウザ
• Ethereum Wallet
イーサリアムウオレット
• Web3 Ethereum JavaScript API
Web3 イーサリアムジャバスクリプトAPI
• Remix Web Browser IDE
リミックス Web ブラウザ IDE
• Geth (Go Ethereum) Command Line Interface
Geth (Goイーサリアム)コマンドラインインタフェース
• Solidity Programming Language
ソリダリテイプログラム言語
Important: If at any point you run into an issue with running a program, try launching it as administrator by right clicking on it and selecting “Run as administrator”.
重要:もしいかなる点でもあなたが、プログラムを走らせることで、問題に出くわすなら、それを右クリックして、そして「アドミニストレーターとして走らせる」を選択して、アドミニストレーターとしてそれを始動するのを試みてください。

Setting Up An Ethereum Node
イーサリアム ノードをセットアップ
In the simplest form, an Ethereum node is any device that is running the Ethereum protocol (blockchain). While nodes are typically running on desktops & laptops, development for mobile is on going. When we connect to the Ethereum protocol we are on the Ethereum blockchain network and are running a node. By running an Ethereum node we can connect to other nodes in the network, have direct access to the blockchain, and even do things like mine blocks, send transactions, and deploy smart contracts.
最も単純な形式で、イーサリアム ノードは イーサリアムプロトコル(ブロックチェーン)を走らせている装置がどれでもそうです。 ノードが典型的にデスクトップ&ラップトップ上で走っている一方で、モバイルの開発が進行中です。 我々が イーサリアムプロトコルに接続するとき、我々は イーサリアムブロックチェーンネットワーク上にあって、ノードを走らせています。 イーサリアムノードを走らせることによって、我々はネットワークで他のノードに接続して、ブロックチェーンへ直接アクセスを持って、採掘ブロックのようなことさえして、トランザクション送信、そしてスマート契約を配置することができます。
Nodes are written in Go (Go Ethereum/Geth), C++, and Python. In this tutorial we’re going to stick to the most popular of the three, Go. Important to also note that by downloading Geth we are downloading the ENTIRE Ethereum blockchain. That said, make sure you have ~35GBs of storage on your hard drive before continuing.
ノードは、Go(Ethereum / Geth)、 C++ とPythonで書かれ。 このチュートリアルで我々は3つのうち最も人気が高いGoに固執するつもりです。 Gethのダウンロード によって我々が全体イーサリアムブロックチェーンをダウンロードしていることをに注目することが、重要です。 すなわち、継続する前に、あなたが35GBまでの容量がハードドライブにあることを確認してください。
1. Visit the Go Ethereum website and install Geth
Go Ethereum ウェブサイトを訪れて、 Geth をインストールしてください
Visit here:https://geth.ethereum.org/downloads/
ここを訪問してください:https://geth.ethereum.org/downloads/
2. Download the latest release of Geth (currently 1.7.2) for Windows, make sure you download the 64-bit version.
Windows のために Geth の最近のリリース(現在1.7.2)をダウンロードしてください、あなたが64ビットのバージョンをダウンロードすることを確かめてください。

Geth Ethereum Downloadable Releases
Geth イーサリアムダウンロード可能なリリース
3. Once your download is complete, open the installer and click “I Agree”
ひとたびあなたのダウンロードが完了したならば、インストーラを開いて、そして「私は同意する」をクリックしてください

4. Make sure the Geth box is checked and click “Next”
Geth ボックスがチェックされることを確認してください、そして「次に」をクリックしてください


5. You’ll be prompted to select a destination folder for your download. By default, Geth will install under C:\Program Files\Geth
あなたはあなたのダウンロードのために目的地フォルダーを選ぶよう促されるでしょう。 デフォルトで、 Geth は C:\ プログラムファイル\ Geth の下でインストールするでしょう

6. Close installation once complete
完了したら、インストール画面を閉じる

7. Open up command prompt (I’ll be using Git Bash — download here:https://git-scm.com/ , do make sure you add to PATH variables during installation) and navigate to the Geth directory by typing “cd C:\Program Files\Geth”
コマンドプロンプトを開く(私は git Bash を使って いるでしょう- こちらでダウンロード here:https://git-scm.com/ 、あなたがインストールする間にパス変数を確実に追加してください)、そして、「cd C:\ プログラムファイル\ Geth」をタイプすることによって、 Geth ディレクトリにナビゲートしてください


Geth Path File
Geth パス ファイル
8. Begin syncing to the Ethereum blockchain by typing “Geth”. Because this is your first sync you’ll download the ENTIRE blockchain from other peers. This will take some time so get comfy…
「Geth」をタイプすることで、イーサリアム ブロックチェーンに同調を始めてください。 これがあなたの最初の同期性であるから、あなたは他の仲間からブロックチェーン全体をダウンロードするでしょう。 これはしばらく時間を要するでしょうから、落ち着いてください…


What you’ll see when launching Geth for the first time (post download)
あなたが初めて Geth を立ちあげるとき、見るであろうもの(ポストダウンロード)
Done? Right on! You’re now running an Ethereum Node. Let the fun begin…
終わりましたか? ちょうど! あなたは今 イーサリアムノードを走らせています。 楽しみ始めてください…。
Establishing Our Own Private Ethereum Network
我々自身の私的な イーサリアム ネットワークを設立
Now that we have access to the Ethereum protocol via our node, we’re going to setup our own private server to develop & deploy our smart contract. Note that none of this will actually be deployed on the Ethereum blockchain, instead we’ll deploy on our own blockchain. We’ll start by initializing the very first block in our blockchain, the genesis block (genesis.json).
我々が我々のノードを経由してイーサリアム プロトコルへのアクセスを持っている今、我々は我々のスマート契約を開発して、配置するために我々自身の私的なサーバーをセットアップするつもりです。 これの少しも実際に イーサリアムブロックチェーン上に配備されていないことに注意を払ってください、その代わりに我々は我々自身のブロックチェーン上に配備されるでしょう。 我々は、起源ブロック(genesis.json)で、まさしくその我々のブロックチェーンの最初のブロックを初期化することによって、開始するでしょう。
1. Create a new folder on your desktop called “Private Chain”.
「私的チェーン」と呼ばれる、あなたのデスクトップに新しいフォルダーを作成。
2. Open command prompt in this folder and create a data directory folder for our chaindata by typing “Mkdir chaindata”. You can open a command prompt in this folder by holding shift and right clicking, then select “open command window here”.
このフォルダーでコマンドプロンプトを開き、そして、「Mkdir chaindata」とタイプすることによって、我々の chaindata のためにデータディレクトリフォルダーを作成してください。 あなたは、シフトヲ保持して正しくクリックして、このフォルダーでコマンドプロンプトを開くことができます。それから「ここにコマンドの窓を開く」を選択
3. Next, we need to create and save our genesis.json block in our Private Chain folder, as the genesis block will be used to initialize our private network and store data in the data directory folder “chaindata”.
次に、起源ブロックが我々の私的ネットワークを初期化し、そしてデータをデータディレクトリフォルダー「chaindata」にストアするために使われるから我々の私的チェーンフォルダーで我々の genesis.json ブロックを作成して、保存する必要がある
4. Open up notepad, copy & paste the code below into a new file called “genesis.json” and save this file in our Private Chain folder.
ノートパッドを広げて、「genesis.json」と呼ばれる新しいファイルの中に下のコードをコピー&ペーストして、そして我々の私的なチェーンフォルダーでこのファイルを保存してください。
Learn more about genesis.json parameters visit the link below:
https://ethereum.stackexchange.com/questions/2376/what-does-each-genesis-json-parameter-mean
genesis.json パラメータについてさらに学び、下記のリンクを訪問してください:
https://ethereum.stackexchange.com/questions/2376/what-does-each-genesis-json-parameter-mean
{
"coinbase" : "0x0000000000000000000000000000000000000001",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"alloc": {},
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
}
}

ここから先は

39,660字 / 1ファイル

¥ 100

期間限定 PayPay支払いすると抽選でお得に!

この記事が気に入ったらサポートをしてみませんか?