const Airdrop = await hre.ethers.getContractFactory('Airdrop');
const airdrop = await Airdrop.deploy(token.address);

await airdrop.deployed();
console.log('[deployAirdrop] deployed airdrop to: ', airdrop.address);

await token.transfer(airdrop.address, hre.ethers.utils.parseEther('2200000'));
const balance = await token.balanceOf(airdrop.address);
console.log('balance = ' +balance);

Jul 28, 2021, 9:01 PM
I'm trying to send tokens to airdrop smart contract
but somehow balance stays 0
[deployAirdrop] deployed airdrop to: 0x8313023A49e79C83987Dce1e98d508a14871FE29
balance = 0
also tried with signers
const [deployer] = await hre.ethers.getSigners();
const Airdrop = await hre.ethers.getContractFactory('Airdrop');
const airdrop = await Airdrop.deploy(token.address);

await airdrop.deployed();
console.log('[deployAirdrop] deployed airdrop to: ', airdrop.address);

await token.transfer(airdrop.address, hre.ethers.utils.parseEther('2200000'));
console.log('balance = ' +await token.balanceOf(airdrop.address));
Jul 28, 2021, 9:03 PM
Check smart contract need implement standard erc20 for a deposit
Jul 28, 2021, 9:04 PM
btw I'm using Hardhat
I'm using ERC20 mock of Openzeppelin
Jul 28, 2021, 9:04 PM
Check your crowsale because maybe are missing erc20 standard
Jul 28, 2021, 9:05 PM
const [deployer] = await hre.ethers.getSigners();
const ERC20Mock = await hre.ethers.getContractFactory("ERC20Mock");
const token = await ERC20Mock.deploy(
"ERC20 test",
"ERC20",
deployer.address,
hre.ethers.utils.parseEther('200000000')
);
Jul 28, 2021, 9:05 PM
Or some function
Jul 28, 2021, 9:05 PM
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

// mock class using ERC20
contract ERC20Mock is ERC20 {
constructor(
string memory name_,
string memory symbol_,
address initialAccount,
uint256 initialBalance
) payable ERC20(name_, symbol_) {
_mint(initialAccount, initialBalance);
}

function mint(address account, uint256 amount) public {
_mint(account, amount);
}

function burn(address account, uint256 amount) public {
_burn(account, amount);
}

function transferInternal(
address from,
address to,
uint256 value
) public {
_transfer(from, to, value);
}

function approveInternal(
address owner,
address spender,
uint256 value
) public {
_approve(owner, spender, value);
}
}
do I need to use { from: deployer} using Hardhat?
Jul 28, 2021, 9:06 PM
who is the sender, and are you sure the sender has enough balance?
as far as I remember you need to mint to get balance
Jul 28, 2021, 9:13 PM
ERC20Mock deployed to: 0x41552b911Afc1D17AAea6FCa2e8a0eccbf21Dc1F
BigNumber { _hex: '0xa56fa5b99019a5c8000000', _isBigNumber: true }
this works:
await token.transfer(airdrop.address, hre.ethers.utils.parseEther('2200000'));
console.log('balance = ' +await token.balanceOf(airdrop.address));
sorry I mean this one
const [deployer] = await hre.ethers.getSigners();
const ERC20Mock = await hre.ethers.getContractFactory("ERC20Mock");
const token = await ERC20Mock.deploy(
"ERC20 test",
"ERC20",
deployer.address,
hre.ethers.utils.parseEther('200000000')
);

await token.deployed();

console.log("ERC20Mock deployed to:", token.address);
console.log(await token.balanceOf(deployer.address));
so the deployer got the balance
Jul 28, 2021, 9:15 PM

© 2024 Draquery.com All rights reserved.