4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ethereumまとめメモ②

Posted at

Contract info (metadata)

参考
https://github.com/ethereum/go-ethereum/wiki/Contracts-and-Transactions

source = "contract test {
   /// @notice Will multiply `a` by 7.
   function multiply(uint a) returns(uint d) {
       return a * 7;
   }
}"
contract = eth.compile.solidity(source).test
MyContract = eth.contract(contract.info.abiDefinition)
contenthash = admin.saveInfo(contract.info, "~/dapps/shared/contracts/test/info.json")
MyContract.new({from: primary, data: contract.code}, function(error, contract){
  if(!error && contract.address) {
    admin.register(primary, contract.address, contenthash)
    // put it up on your favourite oldworld site:
    admin.registerUrl(contentHash, "http://dapphub.com/test/info.json")
  }
});
  • contentHash
    デプロイしたContractの情報(mete data)を含むinfo.jsonファイルのハッシュ値。
     これを登録する(admin.reister)

  • contentUrlを登録する

  • Urlは他の人が見れるサイト。info.jsonをアップロードしておく。
  • admin.registerUrlでそのUrlを登録する

疑問

  • なぜわざわざ情報を登録するのか?jsonをアップロードとかめんどくさいしdecentralizedと言えない。ブロックチェーンで完結しないのか?

参考サイト(上記)にこのような文言があった。

Note that if we use content addressed storage system like swarm the second step is unnecessary, since the contenthash is (deterministically translates to) the unique address of the content itself.

つまり、Swarmなどの分散データベースが実装されれば、contractにきちんと一意性のあるcontentHash値が得られるようになるが、いまはまだ実装できていないので、それまでは一意性が保てない。なので、どこかにmeta dataをアップロードしておかないと、そのcontractが信頼できるかわからない。metadataからハッシュ計算でcontentHashが得られるので、それと一致すれば良い。
 なのでcontentUrlは単にファイルが見れる場所であればどこでもよい(はず)

Create and deploy GlobalRegistrar, HashReg and UrlHint

きちんとデプロイするための方法が書いてある?(未読)

admin.setGlobalRegistrar();

実装されてないとの書き込みが10月の段階であったので今使えるか不明。以降の課題。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?