I am relatively new to programming in solidity and trying to build my own auction platform for demonstrational purposes. What I am trying to do is, to send ETH to a contract and whenever the auction ends, the funds will get re transferred to the auctioneer. I am trying to make a small test contract which only does the payment to the smart contract and allows refund to users. The process of making a payment to the smart contract using a function however, does not work. This is the code I am using:
pragma solidity ^0.5.6;
contract testContract {
constructor () public payable{
}
function transferFunds () external payable {
// this method supposed to send ether to the contract address, however it doesnt
address(this).transfer(1 ether);
}
function refund () external payable {
msg.sender.transfer(address(this).balance);
}
function showBalance () public returns (uint256){
return address(this).balance;
}
function returnContractAdress () public returns (address){
return address(this);
}
}
The error I get is that address(this) is not a payable address, however I read online that it supposed to be a payable address. Whenever I try to convert it to a payable address it doesnt work. I spend so much time reading post on stackexchange and overflow but cant seem to figure out a solution. Can someone help me out?
To clarify, this is what I am trying to build: