How to use Online Solidity Compiler?

ivoronlineivoronline Member Posts: 21
I wasn't able to understand how to use Online Solidity Compiler by following official greeter tutorial.
Image below shows that I have copied greeter contract into left pane?
And now what?
What should I paste where?

I assume I should now do something instead of this line
var greeterCompiled = web3.eth.compile.solidity(greeterSource);

I tried copying generated bytecode like this but then later commands won't work
var greeterCompiled = '60606040526040516102cd3803806102cd8339016040526060805160600190602001505b806001600050908051906020019082805482825590600052602060002090601f016020900481019282156071579182015b8281111560705782518260005055916020019190600101906054565b5b50905060989190607c565b8082111560945760008181506000905550600101607c565b5090565b50505b50610222806100ab6000396000f30060606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b51461004f578063cfae32171461005c578063f1eae25c146100d55761004d565b005b61005a6004506100e2565b005b6100676004506101a4565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100e0600450610176565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561017357600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b33600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b565b60206040519081016040528060008152602001506001600050805480601f0160208091040260200160405190810160405280929190818152602001828054801561021357820191906000526020600020905b8154815290600101906020018083116101f657829003601f168201915b5050505050905061021f565b9056';

Comments

  • ivoronlineivoronline Member Posts: 21
    OK I figured that I have to do this

    Contract Byte Code
    var greeterCompiled = 0x60606040526040516102cd3803806102cd8339016040526060805160600190602001505b806001600050908051906020019082805482825590600052602060002090601f016020900481019282156071579182015b8281111560705782518260005055916020019190600101906054565b5b50905060989190607c565b8082111560945760008181506000905550600101607c565b5090565b50505b50610222806100ab6000396000f30060606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b51461004f578063cfae32171461005c578063f1eae25c146100d55761004d565b005b61005a600450610110565b005b6100676004506101a4565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100e06004506100e2565b005b33600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101a157600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b60206040519081016040528060008152602001506001600050805480601f0160208091040260200160405190810160405280929190818152602001828054801561021357820191906000526020600020905b8154815290600101906020018083116101f657829003601f168201915b5050505050905061021f565b9056

    Contract ABI
    var greeterABI = [{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[],"name":"mortal","outputs":[],"type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"type":"constructor"}];

    Contract Object
    var greeterContract = web3.eth.contract(greeterABI);
    
    Deploy Contract Asynchronously. You will get message "waiting to be mined..."
    var greeter         = greeterContract.new(_greeting,{from:web3.eth.accounts[4], data: greeterCompiled, gas: 300000}, function(e, contract){
        if(!e) {
          if(!contract.address) {
            console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
          } else {
            console.log("Contract mined! Address: " + contract.address);
            console.log(contract);
          }
        }
    })
    Bit after I get message waiting to be mined..., and after I do some mining I get this
    > greeter
    {
      address: undefined,
      transactionHash: "0xc2b5fd51fa30cf33537a6060b48fc3b96adce2e8585ee2f2a44bc799c93fa723"
    }
  • ivoronlineivoronline Member Posts: 21
    edited September 2015
    I also tried changing the code to have only 1 contract instead of two as given by tutorial
    
    contract greeter {   
        
      address owner;                                                       /* Define address variable owner   */
      string greeting;                                                     /* Define string variable greeting */ 
    
      function greeter(string _greeting) public  {                         /* Run during initialization       */ 
        greeting = _greeting; 
        owner    = msg.sender;
      }                
    
      function kill()   { if (msg.sender == owner) suicide(owner); }       /* Get funds on killing contract  */
      
      function greet() constant returns (string) { return greeting; }      /* Main function                  */  
    }
    
  • ivoronlineivoronline Member Posts: 21
    I never get the message "Contract mined!".
    Therefore for some reason contract is not mined.
  • ivoronlineivoronline Member Posts: 21
    SOLVED

    It seems that compiled code needs to be placed inside qoutes like this

    var greeterCompiled = '60606040526040516102b23803806102b28339016040526060805160600190602001505b806001600050908051906020019082805482825590600052602060002090601f016020900481019282156071579182015b8281111560705782518260005055916020019190600101906054565b5b50905060989190607c565b8082111560945760008181506000905550600101607c565b5090565b505033600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b506101dc806100d66000396000f30060606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b514610044578063cfae32171461005157610042565b005b61004f6004506100ca565b005b61005c60045061015e565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561015b57600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b60206040519081016040528060008152602001506001600050805480601f016020809104026020016040519081016040528092919081815260200182805480156101cd57820191906000526020600020905b8154815290600101906020018083116101b057829003601f168201915b505050505090506101d9565b9056'
  • Crypt1xCrypt1x The BlockchainMember Posts: 52
    Thanks for sharing the info!
Sign In or Register to comment.