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
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 ...
Mr.Snow's user avatar
  • 25
0 votes
1 answer
30 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 ...
ratib90486's user avatar
0 votes
1 answer
356 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 '...
ASumeet's user avatar
  • 15
0 votes
1 answer
118 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 >...
Sebi de la Mata's user avatar
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 ...
Aman's user avatar
  • 23
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 { ...
stringRay2014's user avatar
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?
Shane Fontaine's user avatar
1 vote
1 answer
274 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 { ...
porton's user avatar
  • 1,804
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?
Shane Fontaine's user avatar