contract ERC20 {
function transfer(address _recipient, uint256 _value) public returns (bool success);
}

contract Airdrop {
function drop(ERC20 token, address[] recipients, uint256[] values) public {
for (uint256 i = 0; i < recipients.length; i++) {
token.transfer(recipients[i], values[i]);
}
}
}


To use it, first transfer the tokens you want to aidrop to the contract address then send a transaction to drop() with the arrays of the recipients and numbers of tokens.

Can someone explain me how to send the a tx into drop() ?

May 14, 2021, 2:40 AM
I'm new at Soldity
May 14, 2021, 2:40 AM
is it already deployed?
May 14, 2021, 2:41 AM
nope
May 14, 2021, 2:42 AM
so the data you would pass to drop would look like contract.drop(address, ["address1","address2"],[value1,value2]).send
May 14, 2021, 2:43 AM
And how can I send it to drop?
Sorry, I'm a noob
May 14, 2021, 2:45 AM
what are you developing in
May 14, 2021, 2:45 AM
solidity 0.5.16
May 14, 2021, 2:45 AM
on your computer?
May 14, 2021, 2:45 AM
On Remix
May 14, 2021, 2:45 AM
well you will deploy the airdrop contract and your token contract. the air drop contract will have an address,
you can then transfer function on the erc20 to send to the airdrop contract, then you can call drop
contract ERC20 {
function transfer(address _recipient, uint256 _value) public returns (bool success);
}
May 14, 2021, 2:47 AM
That will stay the same, right?
May 14, 2021, 2:48 AM
if this is your attempt at making a token, you should go watch a video, because its not a token
i think you should just use IERC20
May 14, 2021, 2:48 AM
Nope, it's already deployed using a template
It's live on testnet
May 14, 2021, 2:48 AM
ok it should be fine then, my bad im a little new too
try what i said above
May 14, 2021, 2:48 AM
contract Airdrop {
function drop(ERC20 token, address[] recipients, uint256[] values) public {
for (uint256 i = 0; i < recipients.length; i++) {
token.transfer(recipients[i], values[i]);

can you explain here again please?
May 14, 2021, 2:49 AM
what didnt make sense about what i already said
Does anyone know is it possible to read the response of something like : "function() external returns (uint amountA, uint amountB)"
May 14, 2021, 2:50 AM
i didn't understood this very well
function drop(ERC20 token, address[] recipients, uint256[] values) public {
for (uint256 i = 0; i < recipients.length; i++) {
token.transfer(recipients[i], values[i]);
May 14, 2021, 2:52 AM
is it possible to get a return value from a non-constant external contract interaction (not a view obviously)
in web3, not inside of solidity
await greeter.connect(addr1).setGreeting("Hallo, Erde!");
its impossible to get a response from this even if the function returns huh?
May 14, 2021, 3:40 AM

© 2024 Draquery.com All rights reserved.