Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- eth.getCompilers();
- var source = "contract mortal { /* Define variable owner of the type address*/ address owner; /*
- this function is executed at initialization and sets the owner of the contract */ function mortal() { o
- wner = msg.sender; } /* Function to recover the funds on the contract */ function kill() { if (msg.send
- er == owner) suicide(owner); } } contract greeter is mortal { /* define variable greeting of the type strin
- g */ string greeting; /* this runs when the contract is executed */ function greeter(string _greeti
- ng) public { greeting = _greeting; } /* main function */ function greet() constant returns
- (string) { return greeting; } }";
- var compiled = web3.eth.compile.solidity(source);
- var contract_ = web3.eth.contract(compiled.greeter.info.abiDefinition);
- var contract = contract_.new("This is a param!",
- {from: web3.eth.accounts[0],
- data: compiled.greeter.code,
- gas: 300000},
- function(e, contract) {
- if(!e) {
- if(!contract.address) {
- console.log("Wait.");
- } else {
- console.log("Done.");
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement