The function would be something like this:
pragma solidity >=0.8.0;
function withdraw() {
payable(msg.sender).transfer(address(this).balance);
}
Just make sure you only allow yourself to access it
I was able to deploy your FinalizableCrowdsale
SampleCrowdsale
after I removed the FinalizableCrowdsale()
call from the constructor.
I used the following parameters in the constructor call:
1511030956, 1511117356, 1, 100, 200, "0x01", "0x02"
I deployed my contract using Remix, so I modified the code slightly to this (especially since I didn't have the TestToken code):
pragma solidity ^0.4.15;
import "github.com/OpenZeppelin/zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol";
import "github.com/OpenZeppelin/zeppelin-solidity/contracts/crowdsale/FinalizableCrowdsale.sol";
import "github.com/OpenZeppelin/zeppelin-solidity/contracts/crowdsale/RefundableCrowdsale.sol";
import "github.com/OpenZeppelin/zeppelin-solidity/contracts/token/MintableToken.sol";
contract SampleCrowdsale is CappedCrowdsale, FinalizableCrowdsale {
MintableToken public testToken ;
function SampleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet, address _tokenContractAddress)
CappedCrowdsale(_cap)
Crowdsale(_startTime, _endTime, _rate, _wallet)
{
testToken = MintableToken(_tokenContractAddress);
}
function createTokenContract() internal returns (MintableToken) {
return testToken;
}
}
One thing that I noticed is that RefundableCrowdsale
requires one argument for its constructor, where as FinalizableCrowdsale
does not and it isn't necessary to call a parent's constructor if it doesn't take any arguments.
I suspect that this minor detail is the cause of the problem.
Best Answer
You need to keep WETH in the contract I believe to make the swaps.
To withdraw, you can call the
call(_to, _value, _data)
function with:_to = WETH_ADDRESS
_value = 0
_data
:with
MY_ADDRESS
your wallet address, andWETH_AMOUNT_IN_WEI
the amount in the contract you want to withdraw.Basically with this method your contract will call WETH to make a transfer to your wallet.