-
-
Save iurimatias/b098589bbddf3d03ae56 to your computer and use it in GitHub Desktop.
This file contains 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
// copy paste to nodejs | |
var web3 = require('web3'); | |
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8101")); | |
web3.eth.defaultAccount = web3.eth.accounts[0]; | |
source = 'contract SimpleStorage {\n uint public foo;\n\n function SimpleStorage(uint y) {\n foo = y;\n }\n}\n' | |
compiled_contracts = web3.eth.compile.solidity(source) | |
contract = compiled_contracts.SimpleStorage | |
contractObject = web3.eth.contract(contract.info.abiDefinition) | |
contractObject.new(150, {from: web3.eth.defaultAccount, data: contract.code}, function(err, contract) { | |
if (err) { | |
console.log("error"); | |
console.error(err); | |
return; | |
} | |
console.log("deployed at " + contract.address); | |
}) | |
// wait for transaction to mine first before continuing!! | |
var SimpleStorageContract = web3.eth.contract(contract.info.abiDefinition); | |
var SimpleStorage = SimpleStorageContract.at(contractAddress); | |
console.log("value is " + SimpleStorage.foo() + " and it should be 150"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment