i try to create a map with (address => bool) with web3js. I want to know if the address is a contract owner. So, i have to call "owners" function in my solidity contract. As you can see below :
let allAccountInfo = new Map();
let localAccount = web3.eth.accounts;
for(account in localAccount){
MyContract.owners(localAccount[account],function(error,result){
if(error){
console.log(error);
}
else {
allAccountInfo.set(account,result);
}
});
}
console.log(allAccountInfo);
Because MyContract.Function return a promise, this code don't work. I have to wait the promises end before loop... with "await" ?
let allAccountInfo = new Map();
let localAccount = web3.eth.accounts;
for(account in localAccount){
result = await MyContract.owners(localAccount[account])
allAccountInfo.set(account,result);
}
console.log(allAccountInfo);
But when i do this, i get this error :
Error: The MetaMask Web3 object does not support synchronous methods like eth_call without a callback parameter.
Do you know a solution ? Thanks,
.call(...)
or.send(...)
at the end of that line (depending on whether this function is constant or state-changing).