Details
I have created Crowdsale contract with PausableCrowdsale
, AllowanceCrowdsale
.
Some investors send other tokens then ETH to created contract address. I would like to give it back but without results. I wondering if it is possible ?
Code to reproduce
How I try do it via truffle on UNI tokens
deployerWallet = '0x...' /* main wallet address - creator of crowdsale */
from = '0x...' /* crowdsale contract address */
to = '0x ...' /* some client */
abi = JSON.parse('[{ ... abi copied from etherscan ...}]')
token_address = '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984'
contract = new web3.eth.Contract(abi, token_address)
amount = await contract.methods.balanceOf(from).call()
await contract.methods.transferFrom(from, to, amount).send({ from: deployerWallet })
after that the transaction has been created and stuck as pending. In from
is deployerWallet, in Interacted With (To):
is 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984 (token_address). Without to
field.
Crowdsale.sol
pragma solidity ^0.5.0 < 0.7.0;
import "@openzeppelin/contracts/crowdsale/Crowdsale.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/crowdsale/emission/AllowanceCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/validation/PausableCrowdsale.sol";
contract AwesomeCrowdsale is PausableCrowdsale, AllowanceCrowdsale {
uint256 private _changeableRate;
constructor(
uint256 _rate,
address payable _wallet,
ERC20 _token,
address _tokenWallet
)
Crowdsale(_rate, _wallet, _token)
AllowanceCrowdsale(_tokenWallet)
public
{
_changeableRate = _rate;
}
function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
return weiAmount.div(_changeableRate);
}
}
Environment
Truffle v5.1.42 (core: 5.1.42)
Solidity - 0.5.5 (solc-js)
Node v14.9.0
Web3.js v1.2.1
openzeppelin/contracts: 2.5.1