Skip to content

Instantly share code, notes, and snippets.

@johnfkneafsey
Created March 21, 2017 23:22
Show Gist options
  • Save johnfkneafsey/eb8359a337e64607ba6d37e1671d50d1 to your computer and use it in GitHub Desktop.
Save johnfkneafsey/eb8359a337e64607ba6d37e1671d50d1 to your computer and use it in GitHub Desktop.
MetaMask Information
CONNECTING TO GETH
In the console:
geth --networkid 3 --port "35555" --datadir "/Users/johnfkneafsey/Library/Ethereum/testnet" console
ACCOUNTS
Account Addresses:
John (Main Account): 0xA7feBB8C2baaC3F4B4bc7d6C38c55507d917b1d3
John 2:
John 3:
GENERAL COMMANDS
Login/Unlock Account
web3.personal.unlockAccount("yourAddress", "password")
Send Ether
web3.eth.sendTransaction({from:"fromAddress", to:"toAddress", value: web3.toWei('integer', 'ether')})
View Transaction
web3.eth.getTransaction("transactionHash")
Get Ether Balance of Contract:
web3.eth.getBalance("address")
CONGRESS
TestCongress Address:
0xa7136b4f0e53acc357b241196e5ed2c46af1fbe0
TestCongress JSON Interface:
https://gist.github.com/johnfkneafsey/6190593c4cc4192d957f6a9485d03fe1
TestCongress Ether Balance
web3.eth.getBalance("0x6aC33c3D4073b39D2B57De2a4EF472371F7277AC")
TestCongress Functions:
ChangeOfRules: function(), //Event Listener
MembershipChanged: function(), //Event Listener
ProposalAdded: function(), //Event Listener
ProposalTallied: function(), //Event Listener
Voted: function(), //Event Listener
addMember: function(), //OwnerOnly (can be done in wallet - will postpone for now)
allEvents: function(), //Provides a log of all Events (like an event aggregator)
changeVotingRules: function(), //OwnerOnly (can be done in wallet - will postpone for now)
checkProposalCode: function(), //Doesn't seem to be used anywhere
debatingPeriodInMinutes: function(), //self explanatory, returns single integer
executeProposal: function(), //self explanatory, takes (uint proposalNumber, bytes transactionBytecode)
congressContract.executeProposal.sendTransaction(5, "", {from: "0xF6133E0611C27b99aba8bFA4E1f95b3E78Dbb5E4", gas:1000000})
majorityMargin: function(), //self explanatory, returns single integer
* memberId: function(), //revisit
* members: function(), //revisit
minimumQuorum: function(), //self explanatory, returns single integer
newProposal: function(),
congressContract.newProposal.sendTransaction("0xF6133E0611C27b99aba8bFA4E1f95b3E78Dbb5E4", "2", "TREMENDOUS IDEA", "", {from: "accountAddress", gas:1000000})
numProposals: function(), //returns integer representing the # of proposals ever made
owner: function(), //returns the address of the contract owner
* proposals: function(), //revisit
receiveApproval: function(), //Doesn't seem to be used anywhere
receivedEther: function(), //Doesn't seem to be used anywhere
receivedTokens: function(), //Doesn't seem to be used anywhere
removeMember: function(), //OwnerOnly (can be done in wallet - will postpone for now)
transferOwnership: function(), //OwnerOnly (can be done in wallet - will postpone for now)
vote: function(), //revisit
congressContract.vote.sendTransaction(5, "true", "Love it!!!!", {from: "accountAddress", gas:1000000}) //
TestCongress Events:
event ProposalAdded(uint proposalID, address recipient, uint amount, string description);
event Voted(uint proposalID, bool position, address voter, string justification);
event ProposalTallied(uint proposalID, int result, uint quorum, bool active);
event MembershipChanged(address member, bool isMember);
event ChangeOfRules(uint minimumQuorum, uint debatingPeriodInMinutes, int majorityMargin);
Set Up Congress Object:
Step 1: var congressAbi = eth.contract([ { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "proposals", "outputs": [ { "name": "recipient", "type": "address", "value": "0xf6133e0611c27b99aba8bfa4e1f95b3e78dbb5e4" }, { "name": "amount", "type": "uint256", "value": "2" }, { "name": "description", "type": "string", "value": "Really dank dapp idea" }, { "name": "votingDeadline", "type": "uint256", "value": "1489685502" }, { "name": "executed", "type": "bool", "value": false }, { "name": "proposalPassed", "type": "bool", "value": false }, { "name": "numberOfVotes", "type": "uint256", "value": "2" }, { "name": "currentResult", "type": "int256", "value": "2" }, { "name": "proposalHash", "type": "bytes32", "value": "0xf404df0dcd21fbbfc5d06045bd3cdf2d6e444791a58ad8c97f994cb5f2b61279" } ], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "targetMember", "type": "address" } ], "name": "removeMember", "outputs": [], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "proposalNumber", "type": "uint256" }, { "name": "transactionBytecode", "type": "bytes" } ], "name": "executeProposal", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "memberId", "outputs": [ { "name": "", "type": "uint256", "value": "0" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "numProposals", "outputs": [ { "name": "", "type": "uint256", "value": "3" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "members", "outputs": [ { "name": "member", "type": "address", "value": "0x0000000000000000000000000000000000000000" }, { "name": "name", "type": "string", "value": "" }, { "name": "memberSince", "type": "uint256", "value": "1489623844" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "debatingPeriodInMinutes", "outputs": [ { "name": "", "type": "uint256", "value": "3" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "minimumQuorum", "outputs": [ { "name": "", "type": "uint256", "value": "2" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "name": "", "type": "address", "value": "0x9ae6c8795c4158c73d5b7303ae39ed0a248f86cb" } ], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "_from", "type": "address" }, { "name": "_value", "type": "uint256" }, { "name": "_token", "type": "address" }, { "name": "_extraData", "type": "bytes" } ], "name": "receiveApproval", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "majorityMargin", "outputs": [ { "name": "", "type": "int256", "value": "0" } ], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "beneficiary", "type": "address" }, { "name": "etherAmount", "type": "uint256" }, { "name": "JobDescription", "type": "string" }, { "name": "transactionBytecode", "type": "bytes" } ], "name": "newProposal", "outputs": [ { "name": "proposalID", "type": "uint256" } ], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "minimumQuorumForProposals", "type": "uint256" }, { "name": "minutesForDebate", "type": "uint256" }, { "name": "marginOfVotesForMajority", "type": "int256" } ], "name": "changeVotingRules", "outputs": [], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "targetMember", "type": "address" }, { "name": "memberName", "type": "string" } ], "name": "addMember", "outputs": [], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "proposalNumber", "type": "uint256" }, { "name": "supportsProposal", "type": "bool" }, { "name": "justificationText", "type": "string" } ], "name": "vote", "outputs": [ { "name": "voteID", "type": "uint256" } ], "payable": false, "type": "function" }, { "constant": true, "inputs": [ { "name": "proposalNumber", "type": "uint256" }, { "name": "beneficiary", "type": "address" }, { "name": "etherAmount", "type": "uint256" }, { "name": "transactionBytecode", "type": "bytes" } ], "name": "checkProposalCode", "outputs": [ { "name": "codeChecksOut", "type": "bool", "value": false } ], "payable": false, "type": "function" }, { "constant": false, "inputs": [ { "name": "newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "payable": false, "type": "function" }, { "inputs": [ { "name": "minimumQuorumForProposals", "type": "uint256", "index": 0, "typeShort": "uint", "bits": "256", "displayName": "minimum Quorum For Proposals", "template": "elements_input_uint", "value": "10" }, { "name": "minutesForDebate", "type": "uint256", "index": 1, "typeShort": "uint", "bits": "256", "displayName": "minutes For Debate", "template": "elements_input_uint", "value": "30" }, { "name": "marginOfVotesForMajority", "type": "int256", "index": 2, "typeShort": "int", "bits": "256", "displayName": "margin Of Votes For Majority", "template": "elements_input_int", "value": "0" }, { "name": "congressLeader", "type": "address", "index": 3, "typeShort": "address", "bits": "", "displayName": "congress Leader", "template": "elements_input_address", "value": "" } ], "payable": true, "type": "constructor" }, { "payable": true, "type": "fallback" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "proposalID", "type": "uint256" }, { "indexed": false, "name": "recipient", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" }, { "indexed": false, "name": "description", "type": "string" } ], "name": "ProposalAdded", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "proposalID", "type": "uint256" }, { "indexed": false, "name": "position", "type": "bool" }, { "indexed": false, "name": "voter", "type": "address" }, { "indexed": false, "name": "justification", "type": "string" } ], "name": "Voted", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "proposalID", "type": "uint256" }, { "indexed": false, "name": "result", "type": "int256" }, { "indexed": false, "name": "quorum", "type": "uint256" }, { "indexed": false, "name": "active", "type": "bool" } ], "name": "ProposalTallied", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "member", "type": "address" }, { "indexed": false, "name": "isMember", "type": "bool" } ], "name": "MembershipChanged", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "minimumQuorum", "type": "uint256" }, { "indexed": false, "name": "debatingPeriodInMinutes", "type": "uint256" }, { "indexed": false, "name": "majorityMargin", "type": "int256" } ], "name": "ChangeOfRules", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "sender", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" } ], "name": "receivedEther", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "_from", "type": "address" }, { "indexed": false, "name": "_value", "type": "uint256" }, { "indexed": false, "name": "_token", "type": "address" }, { "indexed": false, "name": "_extraData", "type": "bytes" } ], "name": "receivedTokens", "type": "event" } ])
Step 2: var congressContract = congressAbi.at("0x6aC33c3D4073b39D2B57De2a4EF472371F7277AC")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment