I am new to writing a smart contract with Ethereum.
According to an official document, to compile a smart contract, you must remove all line breaks in the source code of the contract:
var greeterSource = 'contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) suicide(owner); } } contract greeter is mortal { string greeting; function greeter(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }'
var greeterCompiled = web3.eth.compile.solidity(greeterSource)
https://ethereum.gitbooks.io/frontier-guide/content/contract_greeter.html
As I think the removal process is not smart, I want to compile the code itself, for example:
var greeterCompiled = web3.eth.compile.solidity_infile( "greeter.txt" )
greeter.txt
contract
mortal {
address owner;
function mortal() { owner = msg.sender; }
function kill() { if (msg.sender == owner) suicide(owner); }
}
contract greeter is mortal {
string greeting;
function greeter(string _greeting) public {
greeting = _greeting;
}
function greet() constant returns (string) {
return greeting;
}
}
Anyone how to do this?
I am using the Solidity compiler.
source
share