Skip to content

Instantly share code, notes, and snippets.

@redsquirrel
Created April 23, 2016 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redsquirrel/4e438e91fb7e0ec3207b762d569084a5 to your computer and use it in GitHub Desktop.
Save redsquirrel/4e438e91fb7e0ec3207b762d569084a5 to your computer and use it in GitHub Desktop.
problem deploying my solidity code to Ethereum
var Web3 = require('../index.js'); // i'm running this from the example directory of web3
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://0.0.0.0:8545'));
web3.eth.defaultAccount = web3.eth.coinbase;
// var source = 'contract L { function f() returns (uint) { return 7; } }';
var source = 'contract L { function f() returns (uint); }'+
'contract X { L l; function X(L lib) { l = lib; } function y() returns (uint) { uint z = 46 + l.f(); return z; } }';
var compiled = web3.eth.compile.solidity(source);
var code = compiled.X.code;
var abi = compiled.X.info.abiDefinition;
// address of L contract
web3.eth.contract(abi).new("0xa..snipped...543", {data: code}, function (err, contract) {
if (err) {
console.error("ERROR: " + err);
return;
} else if(contract.address){
console.log('address: ' + contract.address);
} else {
console.log("Transmitted, waiting for mining...");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment