LoginSignup
3
2

More than 5 years have passed since last update.

macのターミナルでSolidityをコンパイルできるようにした

Posted at

スマートコントラクトの書籍に習って、Geth(go-ethereum)とEthereum公式ウォレット(Mist Wallet)で学習を進めていました。
ただ、Solidityというプログラムのコンパイルためだけにウォレットアプリを使うことがあったので、ターミナルでコンパイルできるようにしました。

$ brew update
$ brew upgrade
$ brew tap ethereum/ethereum
$ brew install solidity
$ brew linkapps solidity

実行方法です。

$ solc --bin --abi hogehoge.sol

======= hogehoge.sol:hogehoge =======
Binary:
606060405〜
Contract JSON ABI
[{"constant":〜

出力されたBINとABIをコピーして、Geth上で下記のように登録します。

> bin = "0x606060405〜"
> abi = [{"constant":〜

※binは先頭に「0x」を付与する必要があります。

最後にhogeという変数にコントラクトを定義します。

> hoge = eth.contract(abi).new({ from: eth.accounts[0], data: bin, gas: 1000000 })

あとはhoge変数でコントラクトを操作できます。

3
2
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
3
2