Skip to main content
19 votes

What is the reason behind writing "using Counters for Counters.counters" when using the Counters openzeppelin library

Counters is a library. When we say using A for B, it means that we attach every function from library A to type B. Libraries are an efficient way to reduce gas fees, because they are deployed only ...
Ehsan Sarshar's user avatar
16 votes

HardhatError: HH700: Artifact for contract "Greeter" not found - clarification [Hardhat, openzeppelin]

Keep in mind that your solidity contract's name has to match, too. If you try to deploy with const License = await ethers.getContractFactory('License'); this works contract License {...} this doesn'...
r.beer's user avatar
  • 161
13 votes

Slither Tool Error On Contract That Inherit From Openzeppeling

Slither use crytic-compile for compiling your contracts. If you specify the path to your contract crytic-compile will try to compile it using your installed solc version. solc can't resolve your "...
Mauricio Perdomo's user avatar
13 votes
Accepted

What does ERC721URIStorage actually mean?

It means that the tokenURIs are also stored in "storage". The base implementation in ERC721.sol reads the baseURI in memory and concatenates the resulting String on-the-fly, without storing ...
Giehl Man's user avatar
  • 246
12 votes

What's the point of ERC721Receiver.sol and ERC721Holder.sol in OpenZeppelin's implementation?

I know this thread has been here for two years, but I think the question has not been fully answered. See another post I put up here. The real question is even having this onERC721Received function ...
Maxareo's user avatar
  • 683
12 votes
Accepted

Function _setTokenURI() in ERC721 is gone in OpenZeppelin ^0.8.0 contracts

I raised this question to the OpenZeppelin forum and they quickly replied with the following feedback: It is a Beta release and there may be small breaking changes prior to the stable release. There ...
Sergi Juanati's user avatar
12 votes

How to get implementation address after deployProxy()? (@open-zepplin/hardhat-upgrades)

You can also use the hardhat upgrades plugin for the same effect as the accepted answer: import { ethers, upgrades } from "hardhat"; const currentImplAddress = await upgrades.erc1967....
stevyhacker's user avatar
11 votes
Accepted

Error: Transaction reverted: function call to a non-contract account

It means, the interface is trying to call a contract that doesn't exist.
Richard's user avatar
  • 154
11 votes
Accepted

Difference between __init and __init_unchained

From OpenZeppelin's docs, there is the following section: Initializer functions are not linearized by the compiler like constructors. Because of this, each __{ContractName}_init function embeds the ...
Ahmed Ihsan Tawfeeq's user avatar
10 votes

Is it possible to include all the openzeppelin library files on Remix?

The easiest is to use remixd to share your build directory with remix. Here are indication how to configure it Accessing a shared folder in Remix IDE using Remixd. Another option is to use the remix ...
Ismael's user avatar
  • 30.4k
10 votes

safeTransferFrom is undefined in buidler test

Ran into this myself as well. Are you using ethers.js with Buidler? The safeTransferFrom method is overloaded and generally with ethers.js the bare definition is the default method used. If you run ...
Dan-Nolan's user avatar
  • 261
10 votes

Error: Transaction reverted: function call to a non-contract account

The following line in your contract is triggering the error. uint x = IERC20(0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa).balanceOf(address(this)); Looking at your hardhat config, you using a fresh ...
Soham Zemse's user avatar
  • 2,101
9 votes
Accepted

What's the point of ERC721Receiver.sol and ERC721Holder.sol in OpenZeppelin's implementation?

When using the safeTransferFrom function to send ERC721 tokens to a contract address, it will fail unless the receiving contract properly implements the ERC721TokenReceiver interface. (See the ERC721 ...
AnAllergyToAnalogy's user avatar
8 votes

An unexpected error occurred: Error: Cannot find module '@nomiclabs/hardhat-waffle' [Hardhat, openzeppelin]

The problem could be that you have not installed the hardhat waffle package. You should do: npm install -D @nomiclabs/hardhat-waffle ethereum-waffle then edit the hardhat.config.js file and add ...
phydy's user avatar
  • 146
8 votes
Accepted

How to override supportsInterface() function if contract needs to support many interfaces?

Your code already overrides the supportsInterface() method well and will cause all the extended contract's methods to be called. This method is also used by the OpenZeppelin Contracts Wizard. If you ...
Qwerty's user avatar
  • 221
8 votes
Accepted

What's the benefit of using SafeERC20?

SafeERC20 is a wrapper library around ERC20 calls that make safe the interaction with someone else’s ERC20 token, in your contracts. What makes SafeERC20 better than then normal ERC20 is that the ...
Yongjian P.'s user avatar
  • 4,268
7 votes
Accepted

How to get implementation address after deployProxy()? (@open-zepplin/hardhat-upgrades)

Try the below, import { getImplementationAddress } from '@openzeppelin/upgrades-core'; const currentImplAddress = await getImplementationAddress(provider, proxyAddress);
Keerthana Ramalingam's user avatar
7 votes
Accepted

Missing artifacts for openzeppelin contracts with hardhat

gm. Have you tried with npx hardhat clean before compiling? It will clear the cache and delete all artifacts. Source
Alvaro's user avatar
  • 186
6 votes

Why Transfer(0x0, _to, _amount) after Minting Tokens

That is not a transfer operations but an event notification. This is done that way so block explorer and wallets that only interpret the 'Transfer' event can show the operation to the user. There ...
Ismael's user avatar
  • 30.4k
6 votes
Accepted

Error encountered, bailing. Network state unknown. Review successful transactions manually

The origin of the issue is because you're trying to deploy the contract from the file migrations/1_initial_migration.js that is supposed to be used only for the deployment of Migration.sol. To deploy ...
Greg Jeanmart's user avatar
6 votes
Accepted

How many storage gaps to add at the end of Base Upgradeable Contracts?

There is no optimal number as the use of storage gaps is just a convention. I would suggest you use 50 as in the majority of the examples, but this is really up to you.
Falcon Stakepool's user avatar
5 votes

Should INITIAL_SUPPLY & totalSupply be returned in Wei?

According to the ERC20 standard totalSupply returns an uint. Hence, this should be the amount of tokens in the smallest unit your token offers. This is not in Wei or any Ether unit, this is just the ...
SmCaterpillar's user avatar
5 votes

How to user SafeERC20 from zeppelin-solidity

The library SafeERC20 is to safely interact with a third party token. It is not to be used inside your own token contract. OpenZeppelin contracts already have require to check for preconditions so ...
Ismael's user avatar
  • 30.4k
5 votes

How does the SafeMath library of OpenZeppelin protect your code from integer overflow?

How do you use it to protect your code? Functions of SafeMath check logic conditions of math operations. function sub(uint256 a, uint256 b... assert(b <= a); // otherwise, subtracting b when (...
Roman Frolov's user avatar
  • 3,177
5 votes
Accepted

SafeMath library vs SafeMath contract on the inheritance chain

SafeMath's functions are all declared as internal. That means that the library doesn't actually have to be deployed, as the functions are 'inlined' by the compiler: their code is just copied from the ...
Henk's user avatar
  • 4,281
5 votes

How do I import from / install OpenZeppelin properly?

Here are the full steps starting from a blank truffle project. You could replace truffle init with truffle unbox <package> if you want to start from a Truffle box. Create a new directory ...
Shawn Tabrizi's user avatar
5 votes

Does OpenZeppelin make security audits?

No, OpenZeppelin doesn't make security audits. OpenZeppelin is a community project that builds a framework of reusable smart contracts. The project doesn't offer any auditing services for things not ...
elopio's user avatar
  • 452
5 votes

Zeppelin OS: revert Cannot call fallback function from the proxy admin

Their documentation isn't the clearest on this one. https://docs.zeppelinos.org/docs/deploying.html Note that we are using a specific address for the --from option which is different to the default ...
Dmitri DB's user avatar
  • 151
5 votes
Accepted

ERC20 not recognized by TokenTracker

Etherscan will recognize your contract once it will log its first Transfer event. This is how it works. Though, even before the first Transfer event was logged, you may view your contract in token ...
Mikhail Vladimirov's user avatar
5 votes

Pros and Cons of smart contract upgradable patterns

OpenZeppelin uses the "unstructured storage" proxy pattern. See the documentation for details: https://docs.openzeppelin.com/sdk/2.5/pattern OpenZeppelin in the proxy patterns blog post (https://blog....
abcoathup's user avatar
  • 1,348

Only top scored, non community-wiki answers of a minimum length are eligible