Questions tagged [virtual]
virtual is a keyword that is used the mark functions whose logic is meant to be overridden by inheriting contracts.
9
questions
53
votes
1
answer
50k
views
What are the virtual and override keywords in Solidity?
Solidity 0.6.0 introduced the keywords virtual and override. What do they do?
1
vote
1
answer
3k
views
What is the difference between the abstract and virtual keywords in Solidity?
Solidity has the keywords abstract and virtual. What is the difference?
1
vote
1
answer
270
views
Does a virtual function increase gas usage?
Suppose we replace every expression balances[user] with a call myBalance(user) where
mapping(address => uint256) balances;
function myBalance(address user) returns (uint256) virtual internal {
...
1
vote
2
answers
1k
views
How to override ERC20 _beforeTokenTransfer and _afterTokenTransfer functions if there is no need of this in my contract
I am trying to use openzepplin's ERC20 token and because of this two functions _beforeTokenTrandfer and _afterTokenTransfer I has to use abstract in my smart contract and because of abstract its not ...
1
vote
2
answers
31
views
How to Resolve TypeError with Overriding Functions in Solidity Inheriting from Two Contracts?
I have a situation where my contract (C) inherits from two other contracts (A and B). Both of these base contracts have a function with the same name and parameters but different return types. Here's ...
0
votes
1
answer
117
views
Inheritance issue using virtual and override (probably): Member not found
I'm trying to work through a course that is covering virtual and override and seem to be getting an error due to inheritance. Below is the code:
//SPDX-License-Identifier: GPL-3.0
pragma solidity >...
0
votes
1
answer
129
views
Unable to call the OZ PaymentSplitter release method from my tests
I'm using hardhat, chai to write my tests for an nft sample project im working on.
Have set up the PaymentSplitter like so ...
contract MyNft is ERC721A, Ownable, MerkleWhitelist, PaymentSplitter {
...
0
votes
1
answer
27
views
Function with both override and virtual keywords
What I understood from this is that if a function has virtual keyword, it can be overridden. And if a function has the keyword override means it is overriding another function. So, does the function ...
0
votes
1
answer
307
views
Using the _mint() function from an ERC20 contract marked 'internal virtual'
I have an existing ERC20 token / contract that I would like to be able to provide rewards that could be minted to the supply. The existing contract already has a _mint() function, but it's labeled as '...