'TypeError: Type is not callable - on compile
I have created a game where I have an interface and a contract with a Game function But when I compile it throws an exception:
TypeError: Type is not callable myGameContract.depositPlayer(0, msg.value)();
It is clear that it refers to the fallback after: msg.value)();
But, I don't know how to fix the interface.
interface Game{
function depositPlayer(uint256 _pid, uint256 _amount) external payable;
function myGame(address _reciever) external payable {
addressBoard = payable(_reciever);
myGameContract= Game(addressBoard );
myGameContract.depositPlayer(0, msg.value)();
I need in this case it to contain a fallback ();
More bellow:
For more clarification, comment as the answer indicates, only the call function contains a fallback
Solution 1:[1]
This is an easy error to make when you accidentally make an argument shadow a function. Here's an easy to understand place this error would pop up:
constructor(address owner, address[] memory defaultOperators) ERC777("Shipyard", "SHIP", defaultOperators) {
transferOwnership(owner);
ico = address(new ShipICO(this));
_mint(owner(), INITIAL_SUPPLY, "", "");
_pause();
}
Note that the argument owner has the same name as the function called in the _mint(owner()) line. Because of the argument having the same name, you're now trying to call the argument owner, which is of type address, as if it were a function. (Note that in this case, owner() is a function inherited from the OZ Ownable contract, making it especially easy to miss.
Easy, common convention is to add an underscore. In this case, _owner may already be taken, so you may add an underscore to the end (owner_ ) for the argument.
As to the OP's question:
This means that myGameContract.depositPlayer is not a function. Go figure out why you think it is, and the compiler thinks it isn't.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kyle Baker |
