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
9
votes
1answer
653 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 ...
8
votes
1answer
5k 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 ...
7
votes
1answer
857 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 ...
6
votes
1answer
781 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 ...
4
votes
1answer
221 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
2answers
6k 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
1answer
1k 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 (...
3
votes
4answers
4k 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; ...
3
votes
1answer
983 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....
3
votes
2answers
3k 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(...
3
votes
2answers
849 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, '...
3
votes
2answers
84 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 ...
3
votes
1answer
2k 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,...
3
votes
1answer
177 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
2answers
2k 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 ...
3
votes
2answers
406 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 ...
3
votes
0answers
512 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. ...
2
votes
2answers
789 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
2answers
348 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(...
2
votes
1answer
596 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
2answers
3k 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 ...
2
votes
1answer
217 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,...
2
votes
1answer
264 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
2answers
555 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. ...
2
votes
1answer
103 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) ...
2
votes
1answer
2k 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 ...
2
votes
1answer
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
3answers
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/...
2
votes
1answer
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 ...
2
votes
1answer
105 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 ...
2
votes
1answer
57 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 ...
2
votes
1answer
198 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
1answer
270 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
1answer
83 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
1answer
418 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
2answers
836 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
1answer
169 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(...
2
votes
1answer
233 views

Wallets report 0 balance for address but balanceOf is right

Given this contract using Openzeppelin lib: contract Token is StandardToken, Ownable { string public name = ""; string public symbol = ""; uint8 public decimals = 18; constructor(...
2
votes
0answers
180 views

Using OpenZeppelin's increaseTime.js

I'm writing a test for a time-dependent solidity function. I'd like to use the increaseTime.js helper from v1.12.0 of OpenZeppelin's library. When I try to call this helper inside my test, I get an ...
1
vote
2answers
369 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. ...
1
vote
1answer
320 views

ERC721Token super._mint calls addTokenTo from the top level implementation

Based on Shawn's answer, super._mint calls addTokenTo from the top level implementation (ERC721Token). How does this work? super._mint calls _mint from ERC721BasicToken reads line addTokenTo ...
1
vote
2answers
114 views

Make a crowdsale reusable?

I have a pretty standard OpenZeppelin crowdsale. Now the issue is that I want to be able to use one crowdsale contract with multiple (~100) different ERC20 tokens. Ideally I want to put the ...
1
vote
2answers
6k views

File import callback not supported import "./IERC20.sol";

when I try to compile my contract I see errors like this : DemirelToken.sol https://eksiup.com/p/4z49413damc3 here's the code : pragma solidity ^0.5.0; import "node_modules/openzeppelin-...
1
vote
1answer
823 views

Importing in SOLC to deploy smart contract

I don't run an Ethereum framework like Truffle and I want to deploy a smart contract using infura node. The smart contract is very simple: pragma solidity ^0.5.2; import "http://github.com/...
1
vote
1answer
35 views

Copying interface and libraries from Openzeppelin vs including them with import statement

I've noticed many times that most of the contract do not import directly from Open zeppelin (for example IERC20 Interface, Ownable Interface, Safemath library and so on) but rather the full code is ...
1
vote
2answers
63 views

How can one access values returned via "return(0, returndatasize())"?

I was looking at the _delegate function in OpenZeppelin's Proxy.sol: /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will ...
1
vote
1answer
18 views

Interacting with contract via remix

I am following the code from 721 sample https://docs.openzeppelin.com/contracts/4.x/erc721 using remix, it compiles and deploys correctly to test network, now my question is how to interact with the ...
1
vote
1answer
380 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?
1
vote
1answer
432 views

Override inherited function visability

I have a contract that looks like this: pragma solidity ^0.6.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract SwappableToken is ERC20 { constructor(string memory name, ...
1
vote
1answer
4k views

How to implement "Mint" and "Own" in an ERC20 Token

So, I recently created a standard ERC20 token but I need to implement "mint" and "owner" functionality. I see that in older implementations but openzeppelin no longer has contracts ...