when i try get data from mapping with a struct, i am getting Indexed expression has to be a type, mapping or array (is uint256) error

my code is

struct Investor {
uint256 balance;
address iaddress;
}

mapping(uint256 => Investor) public investorsBalance;

function asd(uint256 s) public view returns (address) {
return investorAmount[s].iaddress;
}

why im getting this error, how can i access data?

Feb 1, 2023, 7:52 PM
bro...
read the variable name you used for the mapping
Feb 1, 2023, 7:55 PM
dude... really...
i will kill myself
Feb 1, 2023, 7:58 PM
You used investorsBalance for the name of the mapping, and in the asd(), you are calling a non-existent investorAmount mapping
Feb 1, 2023, 8:05 PM
function distributeTokens(IERC20 token) public onlyOwner {
while (i <= investorAmount) {
i++;
token.transferFrom(msg.sender, investorsBalance[i].iaddress, 100);
}
}

The transaction has been reverted to the initial state.
Reason provided by the contract: "ERC20: transfer to the zero address".
Debug the transaction to get more information.
here is my code

https://paste.ofcode.org/zj3yxVf5urFDtti9GmzJF7

same problem again
Feb 1, 2023, 8:09 PM
the error says anything
Feb 1, 2023, 8:14 PM
error says i am trying to transfer my tokens to zero address but i am sending my tokens to custom address. so i think function cannot get address. but why?
Feb 1, 2023, 8:15 PM
here you use a cycle
all the addresses in that mapping are non zero address?
Feb 1, 2023, 8:18 PM
I limit the cycle
does not transfer to any address, no output from main account
any idea?
Feb 1, 2023, 8:24 PM
do you have any idea of what that function does?
one of the address in that mapping is zero
nothing else
instead of <=
do <
Feb 1, 2023, 8:27 PM
no logic error? I thought there was a mapping item defined for the i number as well.
Feb 1, 2023, 8:31 PM
try please what I said
and increment the iterator at the end of the cycle
Feb 1, 2023, 8:32 PM

© 2024 Draquery.com All rights reserved.