I have deployed a Crowdsale contract and now I need to send my Tokens to a list of addresses using remix and injected web3. I am using below code for Airdrop but when I send tokens to multiple contracts, then I faced the same error i.e "Gas Estimation Failed". Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
I am using the following parameters on Ropsten Test net:
"0xc7B64B7F81EC1A6692B747697425C0f7d30F5f37",["0x5bd6a15D5DB703e1C498Ec8B6f79839F1bA491e7","0xE4D4aaD83EF6b27bd91Dd9E16Ee3BfF4CB04dd6c"],["100000000000000000000","200000000000000000000"]
Sending 100 tokens to first Address and 200 tokens to second address. Any help will be appreciable.
contract ERC20 {
function transfer(address _recipient, uint256 _value) public returns (bool success);
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Airdrop is Ownable {
function distributeBulk(ERC20 token, address[] recipients, uint256[] values) onlyOwner public {
for (uint256 i = 0; i < recipients.length; i++) {
token.transfer(recipients[i], values[i]);
}
}
function distribute(ERC20 token, address recipient, uint256 value) onlyOwner public {
token.transfer(recipient, value);
}
}
transfer
so it assumes you first have given the contract a token balance.