2022 Developer Survey is open! Take survey.
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 ...
user avatar
  • 29.3k
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 ...
user avatar
  • 261
9 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 ...
user avatar
  • 429
9 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 ...
user avatar
9 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 ...
user avatar
  • 1,041
9 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 ...
user avatar
  • 206
9 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'...
user avatar
  • 91
7 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.
user avatar
  • 204
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 ...
user avatar
  • 29.3k
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 ...
user avatar
6 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 ...
user avatar
6 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 ...
user avatar
6 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 ...
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 ...
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 ...
user avatar
  • 29.3k
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 ...
user avatar
  • 3,926
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 ...
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 ...
user avatar
  • 432
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 ...
user avatar
  • 151
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....
user avatar
  • 1,278
5 votes
Accepted

Best way to list all tokens of user in Solidity

This can be achieved by the following: Declare storage variables at the contract level mapping(address => uint256[]) public userOwnedTokens; mapping(uint256 => int256) public tokenIsAtIndex; ...
user avatar
4 votes
Accepted

TxReceipt Status fail sending ETH to Contract on Rinkeby

We had some of the same problems as you did. What we figured out was the following: startTime and endTime must be set so that when you call the contract, you are in fact buying tokens when the sale ...
user avatar
4 votes

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

Check any abstract/interface methods are being implemented correctly. I get this issue, where it compiles but won't deploy, when I fail to implement abstract/interface methods correctly in inheriting ...
user avatar
  • 1,608
4 votes
Accepted

Pausable Contract in OpenZeppelin

The Pausable contract you're inheriting from just adds pause and unpause, which updates a state variable paused. But that's all it does by itself. You'll need to use the modifiers whenPaused and ...
user avatar
  • 26.2k
4 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 (...
user avatar
  • 3,017
4 votes
Accepted

How do you compile a contract that uses Open Zeppelin's Standard Token in Truffle?

OZ has updated their code besides restructuring some of the folders. Old Answer (pre 2.X.X release) Look here: https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/...
user avatar
  • 1,216
4 votes
Accepted

Type address is not implicitly convertible to expected type contract ERC20

Change token = 0x0f26c1c05f1bbBC7Eff0488F1a98619e8a9758cf; To token = ERC20(0x0f26c1c05f1bbBC7Eff0488F1a98619e8a9758cf); token is of type ERC20, and you are trying to assign it a value of type ...
user avatar
  • 3,790
4 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 ...
user avatar
4 votes
Accepted

Using OpenZeppelin merkle proof library

Using example https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/ proof would be the yellow hashes. root is 6c0a... leaf is the green hash. Of course if your leaf is different, the proof ...
user avatar
  • 78k
4 votes

Best way to list all tokens of user in Solidity

In the first answer, as you declare "mapping(address => uint256[]) public userOwnedTokens", it expects an address and an uint (position in the array) in the call function. That was my ...
user avatar
  • 41

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