Can anyone help me with how to transfer tokens manually in bulk?as i have to transfer tokens to multiple ETH addresses but cannot waste time transferring it one by one.
-
do it in the contract constructor – Badr Bellaj♦ Apr 23 '18 at 10:53
-
@kryproniq please can you tell me how to use this? What do I need to do after I write this on remix.ethereum.org? Can I perform transfers with MetaMask? Where do I need to write addresses to send? – D.Ada Aug 2 '18 at 21:41
-
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review – Richard Horrocks Aug 3 '18 at 8:32
The below contract code will allow you to send tokens to multiple eth addresses. Works best with parity.
pragma solidity ^0.4.16;
contract Ownable {
address public owner;
function Ownable() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
}
interface Token {
function transfer(address _to, uint256 _value) public returns (bool);
function balanceOf(address _owner) constant public returns (uint256 balance);
}
contract AirDrop is Ownable {
Token token;
event TransferredToken(address indexed to, uint256 value);
event FailedTransfer(address indexed to, uint256 value);
modifier whenDropIsActive() {
assert(isActive());
_;
}
function AirDrop () public {
address _tokenAddr = 0x0F513fFb4926ff82D7F60A05069047AcA295C413; //here pass address of your token
token = Token(_tokenAddr);
}
function isActive() public constant returns (bool) {
return (
tokensAvailable() > 0 // Tokens must be available to send
);
}
//below function can be used when you want to send every recipeint with different number of tokens
function sendTokens(address[] dests, uint256[] values) whenDropIsActive onlyOwner external {
uint256 i = 0;
while (i < dests.length) {
uint256 toSend = values[i] * 10**18;
sendInternally(dests[i] , toSend, values[i]);
i++;
}
}
// this function can be used when you want to send same number of tokens to all the recipients
function sendTokensSingleValue(address[] dests, uint256 value) whenDropIsActive onlyOwner external {
uint256 i = 0;
uint256 toSend = value * 10**18;
while (i < dests.length) {
sendInternally(dests[i] , toSend, value);
i++;
}
}
function sendInternally(address recipient, uint256 tokensToSend, uint256 valueToPresent) internal {
if(recipient == address(0)) return;
if(tokensAvailable() >= tokensToSend) {
token.transfer(recipient, tokensToSend);
TransferredToken(recipient, valueToPresent);
} else {
FailedTransfer(recipient, valueToPresent);
}
}
function tokensAvailable() public constant returns (uint256) {
return token.balanceOf(this);
}
function destroy() public onlyOwner {
uint256 balance = tokensAvailable();
require (balance > 0);
token.transfer(owner, balance);
selfdestruct(owner);
}
}
https://github.com/crowdstartcapital/XSC/blob/master/XSC_AirDrop_public_functions.sol
Do you have control over the contract itself (before it's deployed)? If yes, you can just write a function to do it for you.
If not and the contract doesn't support bulk functionality (as is probably the case) you don't have many options. You just have to use whatever functionality the contract provides and this is probably only the transfer
function. So you have to script calling it somehow. Or maybe write your own contract which executes the token transfers.