Ethereum Asked by Shabdank Bhanawat on August 26, 2021
I have write a small smart contract. however there is problem. please see below full code
pragma solidity ^0.5.16;
import "./x.sol";
contract xSale {
address admin;
x public tokenContract;
uint256 public tokenPrice;
uint256 public tokensSold;
event Sell(address _buyer, uint256 _amount);
constructor (x _tokenContract, uint256 _tokenPrice) public {
admin = msg.sender;
tokenContract = _tokenContract;
tokenPrice = _tokenPrice;
}
function multiply(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x);
}
function buyTokens(uint256 _numberOfTokens) public payable {
require(msg.value == multiply(_numberOfTokens, tokenPrice));
require(tokenContract.balanceOf(address(this)) >= _numberOfTokens);
require(tokenContract.transfer(msg.sender, _numberOfTokens));
tokensSold += _numberOfTokens;
emit Sell(msg.sender, _numberOfTokens);
}
function endSale() public {
require(msg.sender == admin);
require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))));
// UPDATE: Let's not destroy the contract here
// Just transfer the balance to the admin
admin.transfer(address payable(this).balance);
}
}
getting error
xSale.sol:40:32: ParserError: Expected ‘,’ but got ‘payable’
admin.transfer(address payable(this).balance);
^—–^
Change admin.transfer(address payable(this).balance);
to : admin.transfer(address(this).balance);
.
Answered by clement on August 26, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP