7
8

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.

Browser Solidityでスマートコントラクトをデプロイする際ハマったこと

Last updated at Posted at 2017-11-11

Browser Solidityで簡単なスマートコントラクトをやってみたかったら、いろいろハマったので、メモしておきます。

前提

スマートコントラクト内容は特に何もないですが、やりたいのは、スマートコントラクトコンストラクタメソッドでパラメータのアドレスをownerAddressに保持したいだけ。

pragma solidity ^0.4.0;

contract TestTranster {
    address public ownerAddress;
    
    function TestTranster(address _ownerAddress) public {
        ownerAddress = _ownerAddress;
    }
}

はまったこと

  • Web3 Provider を使いたいが、gethを起動しておいているのに、Not possible to connect to the Web3 provider. Make sure the provider is running and a connection is open (via IPC or RPC).で接続できない
    • 現象
      スクリーンショット 2017-11-11 20.21.01.png
      スクリーンショット 2017-11-11 20.21.08.png
    • 解決方法:gethの起動コマンドに --rpccorsdomain "*"オプションを追加するgeth --networkid "10" --nodiscover --rpc --rpccorsdomain "*" --datadir . console 2>>./err.log
  • コンストラクタメソッドのパラメータはどうやって渡すかは分からない
    • 現象:確かにこの辺に入れれば行けるはずだが、正しいアドレスをコピペして入れてCreateボタンをクリックしたらエラー
      スクリーンショット 2017-11-11 20.27.18.png
      • creation of browser/ballot.sol:CloudeaClubTranster errored: Error encoding arguments: SyntaxError: Unexpected token x in JSON at position 2
    • 解決方法:入力フィールドの普通にJSONとして解析されるので、文字列ならちゃんとダブルクオーテーションを入れれば上記エラーでなくなりました
  • creation of browser/ballot.sol:CloudeaClubTranster errored: authentication needed: password or unlock
    • 現象:これはまあ、分かると思いますが、操作しているAccountをunlockしておく必要がある
    • 解決方法:geth consoleで、personal.unlockAccount('選択されているアカウントのアドレス', 'そのアカウントのパスワード')実行しておいてから、Createボタンクリックするとできました。
    • もちろん、miner.start()を実行しないと、ブロックチェーンに書き込まられない

以上

7
8
1

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
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?