I have a contract that contains a simple mapping; let's say mapping(address => uint256) balances;
I want to be able to somehow get all the participants of this smart contract. The simplest way seems to have an additional dynamic array of addresses and iterate over them. But searching for an address on each token transfer or payable function call looks overcomplicated.
Is there a way to have something like a set()
in Python, i.e. an array of unique addresses?
Best Answer
There's no native set in solidity but you can work something simpler with an array and a mapping.
It is very simple, but have the disadvantage it is append only set, you cannot easily delete an element from it.