Questions tagged [openzeppelin-contracts]

OpenZeppelin Contracts is a library for secure smart contract development. It provides implementations of standards like ERC20 and ERC721 which you can deploy as-is or extend to suit your needs, as well as Solidity components to build custom contracts and more complex decentralized systems.

Filter by
Sorted by
Tagged with
14 votes
1 answer
2k views

Understanding OpenZeppelin's Context contract

I'm new to solidity and trying to understand OpenZeppelin's Context contract. At the time of writing, the documentation says: While these are generally available via msg.sender and msg.data, they ...
10 votes
1 answer
9k views

What is IERC20?

I understand the ERC20 standards which includes the functions like totalSupply() balanceOf() allowance() transfer() approve() transferFrom() When I check the openzeppelin, I could see "contract ...
  • 693
7 votes
1 answer
1k views

safeTransferFrom is undefined in buidler test

I have started using buidler for testing/compiling my contracts. In one test i have setup a scenario that a owner attempts to transfer a token to another wallet address. My contract is inheriting from ...
  • 171
6 votes
2 answers
8k views

Sign message with web3 and verify with openzeppelin-solidity ECDSA.sol

I'm trying to get a little example working with ECDSA.sol here: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/cryptography/ECDSA.sol This contract: Generate a random(...
  • 52.5k
6 votes
2 answers
4k views

What does ERC721URIStorage actually mean?

The official docs say ERC721 token with storage based token URI management. If someone could elaborate more on what exactly this means and when to use it, I'd be grateful.
6 votes
1 answer
1k views

Is there a way to test an onlyOwner function from a Truffle/Solidity unit test?

I have a contract with a function marked as onlyOwner (from OpenZeppelin, so only the address that deployed the contract can call it). pragma solidity ^0.4.17; import "./Ownable.sol"; contract ...
  • 339
5 votes
1 answer
410 views

Why does OpenZeppelin implement increaseAllowance and decreaseAllowance functions differently in their ERC20 contract?

This is copied from their ERC20 contract from github (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol): function increaseAllowance(address spender, ...
4 votes
4 answers
10k views

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

We had the following mapping to manage the URIs for ERC721 tokens in OpenZeppelin contracts until pragma ^0.7: // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; ...
4 votes
1 answer
2k views

Transfer only available for objects of type "address payable", not "address"

I am reading the book Mastering Blockchain Programming With Solidity by Jitendra Chittoda published by Packt Publishing. On page 129 it has a sample contract to deploy using the Remix IDE and MetaMask....
  • 143
4 votes
5 answers
2k views

Slither Tool Error On Contract That Inherit From Openzeppeling

Hey Guys Hi ALl ! *I'm trying to use SLITHER (analizy tool ) but when i try to use it on a contract what inherit from Openzeppelin it give me this error(photo) Error: Source "@openzeppelin/...
4 votes
2 answers
2k views

How to use contracts from project dependencies in Brownie scripts?

I want to deploy a contract directly accessible in OpenZeppelin/openzeppelin-contracts@4.2.0 Brownie package without changes, namely ERC1967Proxy and other non-abstract contracts from Brownie console. ...
  • 721
4 votes
1 answer
981 views

Missing artifacts for openzeppelin contracts with hardhat

I'm using hardhat to write a dapp. As I'm compiling my dapp I'm getting an error: Error HH700: Artifact for contract "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:...
  • 553
4 votes
2 answers
5k views

Installation of openzeppelin/contracts Library

I have created a node.js project, within which I have created a truffle directory and initialised its project. I have installed the openzeppelin (npm install @openzeppelin/contracts) library in this ...
  • 281
4 votes
2 answers
8k views

low-level call failed

I'm using the crowdsale contract (https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/crowdsale/Crowdsale.sol). I have deployed a detailedERC20 smart contract. When I send the ...
4 votes
1 answer
2k views

Compilation error using SafeMath

I am trying to do subtraction operation using the SafeMath library. The following is my code: pragma solidity ^0.5.1; library SafeMath { function sub(uint256 a, uint256 b) internal pure returns (...
  • 1,294
4 votes
2 answers
3k views

TypeError: Derived contract must override function “_beforeTokenTransfer”

I am trying to implement an ERC20 token that inherits ERC20.sol, ERC20Detailed.sol, ERC20Burnable.sol, ERC20Mintable.sol, and ERC20Pausable.sol. contract DemoContract is ERC20,ERC20Detailed,...
4 votes
2 answers
3k views

Can't override ERC20 Methods

I try to override ERC20 methods ... The doc says it should be possible but I get the error: CompileError: @openzeppelin/contracts/token/ERC20/ERC20.sol:96:5: TypeError: Trying to override non-virtual ...
  • 261
3 votes
2 answers
1k views

ERC721 standard - What should you pass in the name and symbol arguments passed to the constructor?

I've been confused about the ERC721 standard. We pass a name and symbol to the constructor. What do they represent? In the source code, it just says token name and token symbol. Are they the name and ...
3 votes
1 answer
3k views

can etherscan.io show local ganache transaction details?

I am purchasing tokens on my sample Dapp with ganache-cli account using metamask. Metamask shows the confirm message and deduct the ether from total balance but in token section it still not update ...
3 votes
2 answers
1k views

How to test events that were sent by inner transaction / delegate call?

Usually, using truffle I can check for events like this: let { logs } = await myContract.doSomethingImportant( xxx ); // 1500 tokens are expected to get expectEvent.inLogs(logs, '...
  • 275
3 votes
1 answer
942 views

what does ERC721 _checkOnERC721Received do?

function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to)....
3 votes
1 answer
2k views

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

I'm creating a basic ERC721 token that extends ERC721, ERC721Enumerable, AccessControlEnumerable. I want it to support ERC721Enumerable and AccessControlEnumerable interfaces. Is it enough to call ...
  • 152
3 votes
2 answers
620 views

Why does Openzeppelin's CountersUpgradeable library wrap arithmetic in an unchecked block?

I was reading through the source code for Openzeppelin's CountersUpgradeable library v4.3.0 and realised that the arithmetic operation in the increment / decrement functions is wrapped by an unchecked ...
  • 362
3 votes
2 answers
230 views

Difference of using transfer vs _transfer in OpenZeppelin (same for dash functions)

In openzeppelin contracts in same cases we have 2 types of functions for the same functionality, one of them preceded by a dash symbol (_). That is the case of transfer(x, y, z)/_transfer(x, y, z) ...
  • 745
3 votes
1 answer
1k views

What's the difference between OpenZeppelin's IERC vs ERC contracts?

I'm using the contracts OpenZeppelin provides, but I don't understand why there is 2 version of the same one. Why is there an I version vs non-I?
  • 392
3 votes
1 answer
196 views

Call smart contract function from another smart contract

I am new to Solidity and I'm having some trouble when calling a function of a smart contract from another one. Basically I have smart contract A, which extends ERC20 and the Ownable contract from ...
  • 33
3 votes
0 answers
64 views

hevm doesn't see file

When running a 'seth call' that crashes and puts me into the hevm debugger, after putting in my etherscan API key, I get: hevm: @openzeppelin/contracts/drafts/IERC20Permit.sol: openBinaryFile: does ...
3 votes
1 answer
228 views

deploying a simple ERC721 contract: transaction could not be decoded: could not recover secp256k1 key: calculated Rx is larger than curve P

You can check out the code here: https://github.com/lopeselio/Chainlink-VH-DynamicNFT Command: truffle migrate --reset --network rinkeby -f 3 Then response is as follows: Compiling your contracts... =...
3 votes
2 answers
490 views

OpenZeppelin crowdsale token ownership

Using the non-modified OpenZeppelin code to create a mintable and burnable ERC20 token and a crowdsale contract, once ownership of the token is transferred to the crowdsale contract, is it possible to ...
  • 33
3 votes
0 answers
634 views

Questions on MinterRole contract in openzeppelin

I am using the openzeppelin for creating the ICO contract. I am concerned about the MinterRole here. After I develop Token contract, I added the sale contract as a minter using "addMinter" function. ...
  • 693
2 votes
2 answers
940 views

What's the difference between Truffle Migrations and ZeppelinOS upgradeable contracts?

It was my understanding that Truffle migrations will move updated contracts to new addresses. As a developer, you can use this feature to update already deployed contracts with new code. ZeppelinOS ...
2 votes
2 answers
544 views

ERC20 not recognized by TokenTracker

I have deployed ERC20 with reference to // File: openzeppelin- zos/contracts/token/ERC20/DetailedMintableToken.sol I called the initialized function with owner, name, symbol and decimal value. ...
  • 383
2 votes
2 answers
598 views

why require() is checked after executing transfer()

From OpenZeppelin's ERC721 contract: function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(...
  • 1,582
2 votes
5 answers
1k views

File outside of allowed directories on brownie compile command

trying to import to files from openzeppelin and chainlink in my contract file like so: import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@chainlink/contracts/src/v0.6/...
2 votes
2 answers
5k views

Error HH411: The library openzeppelin-solidity is not installed. Try installing it using npm (for old 0.5.0 solidity code)

I have solidity project with files like pragma solidity ^0.5.0; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; When I try to compile, I get error on not installed library ...
2 votes
1 answer
1k views

Why are there two functions with the same name in ERC721 OZ contract?

I'm looking at the OpenZeppelin ERC721 contract, and the function _safeMint is defined twice: /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* ...
2 votes
1 answer
275 views

How to burn non burnable ERC20?

Suppose you received 250 HELLOCoins and you want to burn them. Unfortunately, HELLOCoins uses OpenZeppelin ERC20 which implements the following function: function _transfer(address from, address to,...
  • 574
2 votes
2 answers
260 views

Brownie deployment – KeyError: 'OpenZeppelin/openzeppelin-contracts@4.4.0/Address'

I'd been building with v3.4 of Zeppelin contracts for a while without issues. I just started a new project using v4.4.0 and I'm getting the following error when I try and publish my contract ...
  • 155
2 votes
1 answer
579 views

ERC-20 Token Smart Contract Redeployment

Hello everyone am wondering how can someone redeploy ERC-20 Token Smart contract thats already deployed? I have already deployed few contracts both on Ropsten Test Network and on Main ETH Network ...
2 votes
1 answer
2k views

Truffle compile gives Parser Error: Error parsing openzeppelin-solidity/contracts/ownership/Ownable.sol

I installed the latest version of truffle, solc, node and also installed new version of openzeppelin-solidity library in my project. Changed the truffle-config.js to use new solc version. My contract ...
2 votes
3 answers
2k views

Basic Crowdsale Contract

I am learning to develop smart contract using Solidity. Currently, I am working and test the feature of following crowdsale contract. https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v1.8.0/...
  • 45
2 votes
1 answer
2k views

What is the most used ERC20 implementation?

I understand ERC20 is a specification. I found some implementations like the following: https://theethereum.wiki/w/index.php/ERC20_Token_Standard https://github.com/ConsenSys/Tokens I want to create ...
  • 1,433
2 votes
1 answer
246 views

Best practice to call onlyOwner function from remote system

About I am having an ERC721 contract (implementation). I want to run a script on a remote system (e.g. a docker container hosted in the cloud) that calls a function which writes to the contract and ...
  • 123
2 votes
1 answer
255 views

Remix VM error when deploying

I'm trying to deploy this code. // contracts/GLDToken.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC777/ERC777.sol"; contract ...
  • 123
2 votes
1 answer
929 views

Reading private variable of mapping(address => uint256) using getStorageAt

I'm trying to access a private variable in my contract using getStorageAt(). OpenZepplin's PostDeliveryCrowdsale has the following (taken as-is): contract PostDeliveryCrowdsale is TimedCrowdsale { ...
2 votes
1 answer
424 views

How does ERC2309 implementation differ or change a standard ERC721

My understanding of the ERC721 minting process is that it follows three basic steps, it updates the owners balance (mapping _balances), it makes a record, associating the tokenId to the owners address ...
2 votes
1 answer
529 views

Visual Studio Code's Solidity extension shows unecessary warnings/errors

I am using Juan Blanco's Solidity extension for VSC. I am noticing it is showing just too many warnings everywhere, including the OpenZeppelin contracts in the node_modules folder. Is there any ...
2 votes
1 answer
151 views

Why doesn't CryproKitties contract use Enumerable.sol?

I am going through the Cryptokitties code, which does not include the optional Enumerable contract, but the KittyBase contract basically declares equivalent indexation and functions. Why did ...
2 votes
2 answers
980 views

ERC721 exchange logic

I'm trying to allow NFT holders to sell their tokens by listing prices (ETH) and allow others to buy those listed tokens. I used openzeppelin and succesfully implemented and tested my token creation. ...
2 votes
1 answer
213 views

Issue in understanding MintedCrowdsale in the ICO contract from openzeppelin

I am trying to understand the openzeppelin code for writing ICO contract. In MintedCrowdsale, mint() function in ERC20Mintable is called as mentioned below. ERC20Mintable(address(token())).mint(...
  • 693

1
2 3 4 5 6