Whitepaper - Ethereum Classic With Cover
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Ethereum</strong> <strong>Classic</strong> Documentation, Release 0.1<br />
> admin.setSolc("/usr/local/bin/solc")<br />
solc, the solidity compiler commandline interface<br />
Version: 0.2.2-02bb315d/.-Darwin/appleclang/JIT linked to libethereum-1.2.0-8007cef0/.-Darwin/appl<br />
path: /usr/local/bin/solc<br />
Compiling a simple contract<br />
Let’s compile a simple contract source:<br />
> source = "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"<br />
This contract offers a single method multiply which is called with a positive integer a and returns a * 7.<br />
You are ready to compile solidity code in the geth JS console using eth.compile.solidity():<br />
> contract = eth.compile.solidity(source).test<br />
{<br />
code: '605280600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000<br />
info: {<br />
language: 'Solidity',<br />
languageVersion: '0',<br />
compilerVersion: '0.9.13',<br />
abiDefinition: [{<br />
constant: false,<br />
inputs: [{<br />
name: 'a',<br />
type: 'uint256'<br />
} ],<br />
name: 'multiply',<br />
outputs: [{<br />
name: 'd',<br />
type: 'uint256'<br />
} ],<br />
type: 'function'<br />
} ],<br />
userDoc: {<br />
methods: {<br />
}<br />
},<br />
developerDoc: {<br />
methods: {<br />
}<br />
},<br />
source: 'contract test { function multiply(uint a) returns(uint d) { return a * 7; } }'<br />
}<br />
}<br />
Note: The compiler is also available via RPC and therefore via web3.js to any in-browser Ðapp connecting to<br />
geth via RPC/IPC.<br />
The following example shows how you interface geth via JSON-RPC to use the compiler.<br />
$ geth --datadir ~/eth/ --loglevel 6 --logtostderr=true --rpc --rpcport 8100 --rpccorsdomain '*' -<br />
$ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_compileSolidity","params":["contract test {<br />
The compiler output for one source will give you contract objects each representing a single contract. The actual<br />
return value of eth.compile.solidity is a map of contract name to contract object pairs. Since our contract’s<br />
name is test, eth.compile.solidity(source).test will give you the contract object for the<br />
test contract containing the following fields:<br />
code The compiled EVM bytecode<br />
1.7. Contracts and Transactions 81