For example, suppose that the contract's code is:
例えば、契約の符号が下記の通りであると仮定します:

 

if !self.storage[calldataload(0)]: self.storage[calldataload(0)] = calldataload(32)

 

Note that in reality the contract code is written in the low-level EVM code; this example is written in Serpent, one of our high-level languages, for clarity, and can be compiled down to EVM code. Suppose that the contract's storage starts off empty, and a transaction is sent with 10 ether value, 2000 gas, 0.001 ether gasprice, and 64 bytes of data, with bytes 0-31 representing the number 2 and bytes 32-63 representing the string  CHARLIE  .fn. 6  The process for the state transition function in this case is as follows:
実際は契約符号が低レベルのEVM符号で書かれることに注意を払ってください;この例は明瞭にするために我々の高水準言語の1つ、Serpentで書かれ、そしてEVM符号にコンパイルすることができます。契約の記憶装置が空から始める と仮定してください。ある取引きが10イーサの値、2000ガス、0.001イーサー gasprice と64バイトのデータと送られ、数字2を表しているバイト0-31とストリングCHARLIE  .fn. 6を表すバイト32-63を伴う。状態遷移関数のプロセスはこの場合次の通りです:

1.      Check that the transaction is valid and well formed.
取引きが有効で、そしてよく整っていることを検査すること。

2.      Check that the transaction sender has at least 2000 * 0.001 = 2 ether. If it is, then subtract 2 ether from the sender's account.
取引き送信者が少なくとも2000 * 0.001 = 2 イーサを持っていることを検査すること。 もしそれがそうであるなら、送信者のアカウントから2イーサを引くこと。

3.      Initialize gas = 2000; assuming the transaction is 170 bytes long and the byte-fee is 5, subtract 850 so that there is 1150 gas left.
gas = 2000を初期化すること;その取引きが170バイトの長さで、そしてバイト - 費用が5であると想定して、1150ガスが残るように、850を引くこと。

4.      Subtract 10 more ether from the sender's account, and add it to the contract's account.
送信者のアカウントからさらに10イーサーを引いて、そして契約のアカウントにそれを加えること。

5.      Run the code. In this case, this is simple: it checks if the contract's storage at index 2 is used, notices that it is not, and so it sets the storage at index 2 to the value  CHARLIE  . Suppose this takes 187 gas, so the remaining amount of gas is 1150 - 187 = 963
その符号を走らせること。 この場合、これはシンプルです:それは、インデックス2の契約の記憶装置が使われているかどうか検査し、それがそうではないことに気付くなら、それは調べます、そしてそれでそれはインデックス2の記憶装置をその値 CHARLIE にセットします。 これが187ガスを取ると仮定します。それで残っているガス量は1150 - 187 = 963です。

6.      Add 963 * 0.001 = 0.963 ether back to the sender's account, and return the resulting state.
963 * 0.001 = 0.963イーサを送信者アカウントに戻し、加えて、そして結果の状態を返えします。

 

=====================================================================

人気ブログランキングへ人気ブログランキングへ

=====================================================================