SHARE
TWEET

Untitled

a guest May 16th, 2016 150 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. eth.getCompilers();
  2.  
  3. var source    = "contract mortal {     /* Define variable owner of the type address*/     address owner;      /*
  4.  this function is executed at initialization and sets the owner of the     contract */     function mortal() { o
  5. wner = msg.sender; }      /* Function to recover the funds on the contract */     function kill() { if (msg.send
  6. er == owner) suicide(owner); } }  contract greeter is mortal {     /* define variable greeting of the type strin
  7. g */     string greeting;      /* this runs when the contract is executed */     function greeter(string _greeti
  8. ng) public {         greeting = _greeting;     }      /* main function */     function greet() constant returns
  9. (string) {         return greeting;     } }";
  10.  
  11. var compiled  = web3.eth.compile.solidity(source);
  12.  
  13. var contract_ = web3.eth.contract(compiled.greeter.info.abiDefinition);
  14.  
  15. var contract  = contract_.new("This is a param!",
  16.                               {from: web3.eth.accounts[0],
  17.                                data: compiled.greeter.code,
  18.                                gas:  300000},
  19.                                function(e, contract) {
  20.                                        if(!e) {
  21.                                                if(!contract.address) {
  22.                                                        console.log("Wait.");
  23.                                                } else {
  24.                                                        console.log("Done.");
  25.                                                }
  26.                                        }
  27.                                })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top