Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [virtual]

virtual is a keyword that is used the mark functions whose logic is meant to be overridden by inheriting contracts.

Filter by
Sorted by
Tagged with
1 vote
2 answers

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 ...
Mr.Snow's user avatar
  • 25
0 votes
1 answer

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 ...
ratib90486's user avatar
0 votes
1 answer

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 '...
ASumeet's user avatar
  • 15
0 votes
1 answer

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 >...
Sebi de la Mata's user avatar
1 vote
2 answers

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 ...
Aman's user avatar
  • 23
0 votes
1 answer

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 { ...
stringRay2014's user avatar
1 vote
1 answer

What is the difference between the abstract and virtual keywords in Solidity?

Solidity has the keywords abstract and virtual. What is the difference?
Shane Fontaine's user avatar
1 vote
1 answer

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 { ...
porton's user avatar
  • 1,804
53 votes
1 answer

What are the virtual and override keywords in Solidity?

Solidity 0.6.0 introduced the keywords virtual and override. What do they do?
Shane Fontaine's user avatar