Questions tagged [virtual]
virtual is a keyword that is used the mark functions whose logic is meant to be overridden by inheriting contracts.
8
questions
0
votes
1
answer
13
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
144
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 '...
0
votes
1
answer
99
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 >...
1
vote
2
answers
993
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 ...
0
votes
1
answer
127
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 {
...
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
254
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 {
...
53
votes
1
answer
48k
views
What are the virtual and override keywords in Solidity?
Solidity 0.6.0 introduced the keywords virtual and override. What do they do?