Created
April 23, 2016 01:24
-
-
Save redsquirrel/4e438e91fb7e0ec3207b762d569084a5 to your computer and use it in GitHub Desktop.
problem deploying my solidity code to Ethereum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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