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?

1

There are 1 best solutions below

0
Zayd On
1.  Automate Data Compilation: Use Web3.jsor Web3.py to automatically track Transfer events of your ERC20 token. This generates a real-time list of holder addresses and balances, removing the need for manual updates.
2.  Off-chain Calculations: Perform the distribution calculations off-chain. Calculate how much each holder should receive based on their token balance.
3.  Use Merkle Tree for Distribution: Create a Merkle tree from your list of distributions. Deploy a smart contract that holds the Merkle root and allows token holders to claim their distribution by providing a Merkle proof. This minimizes on-chain data and gas costs.
4.  Batch Transactions for Distribution: Utilize a contract that supports batch transactions to distribute tokens to holders. This approach reduces the number of transactions and saves gas.