Last active
June 5, 2017 12:56
-
-
Save daragao/7727282d815d83f2f0bb5b84f9c150cc 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
//self running function to encapsulate all the variables | |
var Test = function() { | |
var testBIN = '6060604052341561000c57fe5b5b60326000819055505b5b60e7806100256000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063b69ef8a8146044578063b6b55f25146067575bfe5b3415604b57fe5b60516098565b6040518082815260200191505060405180910390f35b3415606e57fe5b60826004808035906020019091905050609e565b6040518082815260200191505060405180910390f35b60005481565b60008160006000828254019250508190555060005490505b9190505600a165627a7a723058206751dd5bc72fc42f08633904726ab78c48328a747e7fa4147ad042d513e1a9480029'; | |
var testABI = [ | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "balance", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"type": "function" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "_value", | |
"type": "uint256" | |
} | |
], | |
"name": "deposit", | |
"outputs": [ | |
{ | |
"name": "_newValue", | |
"type": "uint256" | |
} | |
], | |
"payable": false, | |
"type": "function" | |
}, | |
{ | |
"inputs": [], | |
"payable": false, | |
"type": "constructor" | |
} | |
]; | |
/* END SOLIDITY GENERATED DATA */ | |
/* JS CONTRACT FUNCTIONS */ | |
var deployTestContract = function(from,gas) { //from and gas are optional | |
var transactionObj = { | |
from: from, | |
data: testBIN, | |
gas: gas | |
}; | |
var testContractInstance = TestContract | |
.new(transactionObj); | |
return testContractInstance; | |
}; | |
//CREATE CONTRACT | |
var TestContract = eth.contract(eth.coinbase,1000000) | |
//return public variables and functions | |
return { | |
contract: TestContract, | |
deploy: deployTestContract, | |
}; | |
}(); | |
/* Example of commands | |
loadScript('Test.js'); | |
personal.unlockAccount(eth.accounts[0],'password') | |
Test.contractInstance = Test.deploy(eth.accounts[0]); //WAIT FOR CONTRACT TO BE MINED! | |
Test.contractInstance.balance.call(); | |
Test.contractInstance.deposit.sendTransaction(10,{from: eth.accounts[0], gas: 1000000 }); | |
Test.contractInstance.balance.call(); | |
*/ |
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
pragma solidity ^0.4.10; | |
contract HelloWorldTwo{ | |
uint public balance; | |
function HelloWorldTwo(){ | |
balance = 50; | |
} | |
function deposit(uint _value) returns(uint _newValue){ | |
balance += _value; | |
return balance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment