I am trying to make a smart contract that takes a bunch of addresses and their corresponding ownership of my ERC20. However, I cannot find a way to compile this data automatically so I am doing it manually now. So, the questions I have are:
1: Is there. a way to compile this automatically? 2: If not, is there a way to access the data without exceeding the gas limit? 3: Are there any other ways to proportionally distribute an ERC20 based off how much of an ERC20 an address owns?
Right now, I am trying to use an abstract contract to access everything from a controller.
abstract contract InterestInterface { ...
Inside it, there are 2 arrays:
string[] public holderAddresses = ['0x58ee92c366f197e434a1267a38e28e8c08cd27e7' ...
uint256[] private holderBalances = [50317379983, 24224355398, 5000000001,
These are manually collected and formatted in python, and it is taken from Etherscan. What I was hoping for was 100,000, the limit on Etherscan, but it can't even handle 500. I tried using things like bitquery, but I am not a company.
All there's left is the functions:
function _collectdistributiondata() public { ...
function _distribute() public { ...
The collectdistributiondata function is for seeing how much I need to distribute, and the distribute function is the distribution.
The way my process works is a for loop:
for (accountnumber = 1; accountnumber < holderAddresses.length && accountnumber < 100000; accountnumber++) {
currentaddress = address(bytes20(bytes(holderAddresses[accountnumber])));
currentbalance = (holderBalances[accountnumber]) / 128;
token.transfer(currentaddress, currentbalance * 10 ** 18);
}
I send the ERC20 to the address of the contract so then it can send it away, since transferFrom wasn't working.
It is all accessed in this:
import "contracts/InterestInterface.sol";
contract Interest is InterestInterface{
InterestInterface inter;
constructor (address interfaceaddress) {
inter = InterestInterface(interfaceaddress);
}
function collectdistributiondata() public {
inter._collectdistributiondata();
}
function distribute() public {
inter._distribute();
}
}
Is there anything I can do differently? Another way to distribute the coins?