-1

So I'm programming a ERC20 token and want to have the ability to airdrop wrapped lite coin or another wrapped currency strait to the owners of the tokens based on the percentage that they own.

Say I have $1000 worth of lite coin or USDT or another token, and I want to divide it up by % owned, and have it automatically send those amounts to the owners, is that possible? How do I do it? It has a limited quantity of 100,000 coins representing 100%. Could I say, take the smallest possible quantity of tokens someone can own and represent that as a percentage, and send a certain amount per everyone of those percentages owned by someone?

Working with remix ide, and metamask wallet.

RIANIAN
  • 1
  • 1

1 Answers1

0

It is "doable" but it's absolutely not recommended.

That is one of the typical patterns that should be avoided.

The reason are multiples:

  • First, if you have to send to multiple addresses the gas cost of such a transaction can become quite big.

  • Second, as Solidity transactions are atomic, if one transfer was to fail the whole function would revert. (But the gas would be spent).

A pattern is recommended, it is the pull over push pattern. Instead of directly sending Ether or an ERC20, you set an allowed amount to withdraw for each address. And then users just need to claim their funds.

https://fravoll.github.io/solidity-patterns/pull_over_push.html

Torof
  • 561
  • 3
  • 17
  • I've taken a look at the GitHub repo, how would I actually add that functionality to my token? It's a little confusing just looking at it. What I'd like to do is have a simple NFT style website where people can go and withdraw their cut from a kitty, but I have no idea how I would add that functionality to my already created token. – RIANIAN Dec 02 '22 at 08:30
  • just to be clear, I do know how to make the website but adding that functionality to a button, I'm guessing a smart contract which holds the kitty and sends the percentage to someone? – RIANIAN Dec 02 '22 at 09:07