Created
March 20, 2017 21:11
-
-
Save johnfkneafsey/50ce758fe29951d5688e9cb39c4b0d54 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
Token Contract Address: | |
0xa3f5f88cf2156c94f3b0a831a45afb6685eab2df | |
Token Contract Transaction Hash: | |
0x1a4ec9a31edcf6bde90a0a72731ce04870383b5878515a5f4dba5dba46679ef8 | |
Token Balance: | |
token.coinBalanceOf(eth.accounts[0]) + " tokens" | |
EVENT LISTENER: Send token: | |
var event = token.CoinTransfer({}, '', function(error, result){ | |
if (!error) | |
console.log("Coin transfer: " + result.args.amount + " tokens were sent. Balances now are as following: \n Sender:\t" + result.args.sender + " \t" + token.coinBalanceOf.call(result.args.sender) + " tokens \n Receiver:\t" + result.args.receiver + " \t" + token.coinBalanceOf.call(result.args.receiver) + " tokens" ) | |
}); | |
Token Contract Send Coin: | |
token.sendCoin.sendTransaction(eth.accounts[1], 1000, {from: eth.accounts[0]}) | |
Name Token: | |
token = eth.contract([{constant:false,inputs:[{name:'receiver',type:'address'},{name:'amount',type:'uint256'}],name:'sendCoin',outputs:[{name:'sufficient',type:'bool'}],type:'function'},{constant:true,inputs:[{name:'',type:'address'}],name:'coinBalanceOf',outputs:[{name:'',type:'uint256'}],type:'function'},{inputs:[{name:'supply',type:'uint256'}],type:'constructor'},{anonymous:false,inputs:[{indexed:false,name:'sender',type:'address'},{indexed:false,name:'receiver',type:'address'},{indexed:false,name:'amount',type:'uint256'}],name:'CoinTransfer',type:'event'}]).at('0xa3f5f88cf2156c94f3b0a831a45afb6685eab2df') | |
web3.eth.sendTransaction({from:"0x9aE6C8795c4158C73d5B7303Ae39ed0a248f86cB", to:"0x1f963bccf699187a1321ddcbaeece7d0e27564bf", value: web3.toWei('2', 'ether')}) | |
ar democracy = eth.contract( [{ constant: true, inputs: [{ name: '', type: 'uint256' } ], name: 'proposals', outputs: [{ name: 'recipient', type: 'address' }, { name: 'amount', type: 'uint256' }, { name: 'data', type: 'bytes32' }, { name: 'descriptionHash', type: 'bytes32' }, { name: 'creationDate', type: 'uint256' }, { name: 'numVotes', type: 'uint256' }, { name: 'quorum', type: 'uint256' }, { name: 'active', type: 'bool' } ], type: 'function' }, { constant: false, inputs: [{ name: '_proposalID', type: 'uint256' } ], name: 'executeProposal', outputs: [{ name: 'result', type: 'uint256' } ], type: 'function' }, { constant: true, inputs: [ ], name: 'debatingPeriod', outputs: [{ name: '', type: 'uint256' } ], type: 'function' }, { constant: true, inputs: [ ], name: 'numProposals', outputs: [{ name: '', type: 'uint256' } ], type: 'function' }, { constant: true, inputs: [ ], name: 'founder', outputs: [{ name: '', type: 'address' } ], type: 'function' }, { constant: false, inputs: [{ name: '_proposalID', type: 'uint256' }, { name: '_position', type: 'int256' } ], name: 'vote', outputs: [{ name: 'voteID', type: 'uint256' } ], type: 'function' }, { constant: false, inputs: [{ name: '_voterShareAddress', type: 'address' } ], name: 'setup', outputs: [ ], type: 'function' }, { constant: false, inputs: [{ name: '_recipient', type: 'address' }, { name: '_amount', type: 'uint256' }, { name: '_data', type: 'bytes32' }, { name: '_descriptionHash', type: 'bytes32' } ], name: 'newProposal', outputs: [{ name: 'proposalID', type: 'uint256' } ], type: 'function' }, { constant: true, inputs: [ ], name: 'minimumQuorum', outputs: [{ name: '', type: 'uint256' } ], type: 'function' }, { inputs: [ ], type: 'constructor' } ] ).at( | |
Congress Address: | |
0x1f963bccf699187a1321ddcbaeece7d0e27564bf | |
Congress Event Listeners: | |
var event = democracy.ProposalAdded({}, '', function(error, result){ | |
if (!error) | |
console.log("New Proposal #"+ result.args.proposalID +"!\n Send " + web3.fromWei(result.args.amount, "ether") + " ether to " + result.args.recipient.substring(2,8) + "... for " + result.args.description ) | |
}); | |
var eventVote = democracy.Voted({}, '', function(error, result){ | |
if (!error) | |
var opinion = ""; | |
if (result.args.position > 0) { | |
opinion = "in favor" | |
} else if (result.args.position < 0) { | |
opinion = "against" | |
} else { | |
opinion = "abstaining" | |
} | |
console.log("Vote on Proposal #"+ result.args.proposalID +"!\n " + result.args.voter + " is " + opinion ) | |
}); | |
var eventTally = democracy.ProposalTallied({}, '', function(error, result){ | |
if (!error) | |
var totalCount = ""; | |
if (result.args.result > 1) { | |
totalCount = "passed" | |
} else if (result.args.result < 1) { | |
totalCount = "rejected" | |
} else { | |
totalCount = "a tie" | |
} | |
console.log("Votes counted on Proposal #"+ result.args.proposalID +"!\n With a total of " + Math.abs(result.args.result) + " out of " + result.args.quorum + ", proposal is " + totalCount + ". Proposal is " + (result.args.active? " still on the floor" : "archived") ) | |
}); | |
Send Congress Money from main account: | |
eth.sendTransaction({from: eth.accounts[0], to: democracy.address, value: web3.toWei(2, "ether")}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment