Created
July 14, 2016 20:40
-
-
Save CJentzsch/f0da62e4ff0ea8a2a3f4c81c2c50753a to your computer and use it in GitHub Desktop.
create a list of all child DAOs and its extraBalance account (plus main DAO and its extraBalance account)
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
var address = '0xbb9bc244d798123fde783fcc1c72d3bb8c189413'; | |
// define the dao-contract | |
var abi = [ | |
{name:"getNewDAOAddress", "type":"function","outputs":[ | |
{"type":"address","name":"_newDAO"}],"inputs":[ | |
{"type":"uint256","name":"_proposalID"}],"constant":true}, | |
{name:"numberOfProposals","type":"function","outputs":[ | |
{"type":"uint256","name":"_numberOfProposals"}],"inputs":[],"constant":true}, | |
{name : "extraBalance", "constant" : true, "inputs" : [], "type" : "function", | |
"outputs" : [{ "name" : "", "type" : "address" } ]} | |
]; | |
var contract = web3.eth.contract(abi).at(address); | |
// find all successfull splits | |
var allProposals = contract.numberOfProposals().toNumber(); | |
var result = []; | |
for (var i=1;i<=allProposals;i++) { | |
var newDAO = contract.getNewDAOAddress(i); | |
if (newDAO=="0x" || web3.toDecimal(newDAO)==0) continue; | |
var extraBalanceAccount = web3.eth.contract(abi).at(newDAO).extraBalance(); | |
result.push({ | |
address : newDAO, | |
extraBalanceAccount : extraBalanceAccount | |
}); | |
} | |
var newDAO = '0xbb9bc244d798123fde783fcc1c72d3bb8c189413'; | |
var extraBalanceAccount = web3.eth.contract(abi).at(newDAO).extraBalance(); | |
result.push({ | |
address : newDAO, | |
extraBalanceAccount : extraBalanceAccount | |
}); | |
console.log(JSON.stringify(result)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment