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
0 votes
0 answers
7 views

Trouble with Solidity Compiler Version when combining Aave and Openzeppelin in Foundry

I'm trying to follow this tutorial by Patrick Collins on Flashloans but in Foundry: https://www.youtube.com/watch?v=Aw7yvGFtOvI&t=328s When in try to forge build I get the following error: : src\...
user avatar
  • 11
0 votes
1 answer
20 views

Private variables with public view functions

In the Openzeppelin ERC721.sol contract, there are private variables introduced: // Token name string private _name; // Token symbol string private _symbol; These variables are then assigned a ...
user avatar
  • 81
0 votes
0 answers
23 views

OpenZeppelin Context.sol, when to use & why?

When, and why is it better to use functions _msgSender() & _msgData() introduced by the Context.sol by OpenZeppelin, instead of msg.sender & msg.data?
user avatar
  • 81
0 votes
3 answers
29 views

Is automating the withdraw of a NFT smart contract a good idea? [closed]

Just wondering out ! Something like automatic withdraw after every 24 hours or something like withdraw after every mint on the contract. If its a good idea, sharing any ways or resources for me to do ...
user avatar
0 votes
2 answers
38 views

Function Max mint per wallet is not working

learning solidity and curious how i can limit the minting of my NFT to only 2 per wallet address. Trying to prevent people from minting more then 2 tokens during free mint phase using "mapping&...
user avatar
  • 11
3 votes
1 answer
34 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 ...
user avatar
  • 33
1 vote
1 answer
39 views

Initializing the implementation contract when using UUPS to protect against attacks

In OpenZeppelin's documentation, it's mentioned that we should be invoking the _disableInitializers function, otherwise our contract might be vulnerable to certain attacks. Can someone explain how ...
user avatar
1 vote
0 answers
29 views

Deploy Upgradable contract with factory contract

I have a simple contract below Swap.sol that is upgradable. // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/proxy/utils/...
user avatar
  • 73
0 votes
2 answers
49 views

ERC777 upgradeable deployment error: cannot estimate gas; transaction may fail or may require manual gas limit hardhat

Hi I could not deploy my ERC777 Upgradeable contract into Hardhat test network. My ERC777 contract: pragma solidity ^0.8.15; import "@openzeppelin/contracts-upgradeable/token/ERC777/...
user avatar
  • 1,460
0 votes
2 answers
39 views

How do you pass in a variable as a string to a constructor in solidity

I'm currently working on an NFT project, using the openzeppelin ERC721 standard for the nfts. When Inheriting the ERC721 NFT contract standard from openzeppelin you're required to pass in the "...
user avatar
0 votes
0 answers
31 views

TransferFrom Error - "not visible after argument-dependent lookup in contract Token"

I'm calling a transfer, transferfrom, approve contract following the open-zeppelin ERC20 source. I got not found issues. Maybe I'm omitting something. My Code: token.sol //SPDX-License-Identifier: MIT ...
user avatar
0 votes
1 answer
35 views

In My ERC-721 Contract, tokenURI Doesn't Return A String, It Returns A Promise

In my solidity contract, the function for tokenURI looks like this: function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), ...
user avatar
0 votes
1 answer
116 views

Does a minimal proxy contract that creates clones need an upgradeable smart contract

I want to understand a few things regarding the implementation of clone factory pattern in smart contract. Do we need an upgradeable smart contract to implement the cloning mechanism (the clones ...
user avatar
  • 812
0 votes
1 answer
21 views

OpenZeppelin Contracts

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol Why functionCall calls the other functionCall ? I don't understand why they do nested callings instead of ...
user avatar
0 votes
0 answers
20 views

Transactions reverting

So the thing is I am trying to make a smart contract with multi sig. However, it's showing this error when I am trying to transfer ownership: Transaction would revert. Check that permissions, ...
user avatar
  • 1
0 votes
1 answer
22 views

Can we assume that IERC20Metada will work with every ERC20 token?

I'm developing a contract that receives ERC20 tokens and need to know token name and token symbol. According to the IERC20 in OppenZeppelin there is no public symbol() or name() functions. I know that ...
user avatar
  • 705
0 votes
1 answer
36 views

Gas optimisation: maximum of two numbers

Any ideas if I can optimize the gas of the following function from Math library of OZ: function max(uint256 a, uint256 b) public pure returns (uint256) { return a >= b ? a : b; } *I checked ...
user avatar
0 votes
0 answers
26 views

Upgrade a contract mapping struct

I have an upgradable contract (openzeppelin): contract MyContract is OwnableUpgradeable { ... struct MyStruct { uint a; uint b; } ... mapping(address => ...
user avatar
0 votes
0 answers
68 views

EscrowUpgradeable triggers "Ownable: caller is not the owner."

I am newbie and am on Truffle/Openzeppelin stack. I am following the example/tutorial for Using Escrow Library at https://medium.com/@ethdapp/using-the-openzeppelin-escrow-library-6384f22caa99 and all ...
user avatar
0 votes
0 answers
32 views

Deploy a crowdsale contract for a previously deployed ERC20 token

I have deployed an upgradable ERC20 token using ^0.8.4 and I would like to set up an AllocatedCrowdsale from OpenZeppelin for said token. I have set up a second project for the crowdsale using ^0.5.0 ...
user avatar
1 vote
0 answers
285 views

Error: missing revert data in call exception on tokenOfOwnerByIndex and tokenByIndex from openzeppelin ERC721Enumerable

I'm getting a odd error across several calls out to openzeppelin that Error: missing revert data in call exception; Transaction reverted without a reason string I didn't change anything and am using ...
user avatar
0 votes
0 answers
59 views

How ERC 1155 standard prevents from "out of gas" error in batch operations?

I was checking the implementation of Openzeppelin's implementation of ERC-1155 standard and I'm curious about the use of _safeBatchTransferFrom function to transfer multiple tokens at once. The ...
user avatar
  • 705
0 votes
0 answers
11 views

Can I use Crowdsale with ERC20 Token created in OZ4.5.0?

Basically, I already have ERC20 token created, which is using solidity 0.8.2 and OpenZeppelin version 4.5.0. I know that Crowdsales supports only OpenZeppelin Contracts 2.x version. I am not sure if I ...
user avatar
0 votes
1 answer
684 views

function selector was not recognized error

I'm extending OpenZeppelins ERC20 to create a Token that I use for testing in another smart contract. Here's how it looks: //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@...
user avatar
0 votes
2 answers
58 views

Sending ERC20s to a Contract on deployment

I'm trying to send an amount of ERC20 on Contract deploy to the contract itself. I'm using Hardhat and OpenZeppelin Contracts. Contract Code: //SPDX-License-Identifier: Unlicense pragma solidity ^0.8....
user avatar
0 votes
0 answers
41 views

If I use the cloning pattern to launch erc721s, will it list on exchanges like a normal contract?

Hey I'm looking at implementing a basic minimal clone of an ERC721 contract (using the openzepplin cloning implementation), and I was wondering if it would make any difference in how the tokens are ...
user avatar
0 votes
0 answers
153 views

Can't import OpenZeppelin Ownable contract

I'm following freecodecamp's solidity course but am unable to import Ownable from OpenZeppelin into my contract. Using brownie, this is what I have so far: and in the config.yaml file: And when I ...
user avatar
0 votes
1 answer
73 views

Referencing OpenZeppelin in Solidity Contract, working with Etherscan

I think I am making a simple mistake, but I have been stuck for a while. I have a simple ERC-20 contract which I have publish on the Ethereum Mainnet and others on Polygon. This is a sample contract ...
user avatar
0 votes
1 answer
295 views

upgradeble openzeppelin contracts - why the __gap is needed if you can add variables to the end?

https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps 1: https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps explains why the __gap variable is needed, but https://docs....
user avatar
1 vote
0 answers
102 views

Solidity Advanced Transparent Proxy pattern

Proxy contract - The contract users are calling to use current implementation Admin Proxy Contract - Contarct to Update Current Implementation or current Structure Model Implementation Contract (where ...
user avatar
0 votes
1 answer
108 views

Imported Openzeppelin contract is different than on GitHub

I am trying to import the ERC2981.sol from the OpenZeppelin contracts repository. In their GitHub page the royaltyInfo is a public function. But for some reason when I import it in my project, this ...
user avatar
  • 138
0 votes
0 answers
286 views

How to burn erc721 token?

I am trying to burn erc721 token. I have inherited ERC721Burnable contract,but the transaction gets failed.While debugging I found that in ERC721URIStorage contract,it reverts back at: if (bytes(...
user avatar
1 vote
1 answer
217 views

How to test recoverSigner and splitSignature

I am currently trying to test a function that uses a recoverSigner inside and I'm not sure how to proceed. Here is the function: function claimToken(bytes32 message, bytes memory _signature, address ...
user avatar
1 vote
0 answers
56 views

Openzeppelin ERC1155 missing virtual function?

This is my ERC1155 contract: // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; pragma abicoder v2; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; contract ...
user avatar
0 votes
1 answer
336 views

How to use ERC721URIStorage and ERC721Royalty together (requires override)

I am initializing my contract as below: pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol";...
user avatar
  • 138
1 vote
0 answers
321 views

Transparent proxy tests - Error: missing revert data in call exception; Transaction reverted without a reason string;

I am trying to create a new token contract using the ERC20 Upgradeable contracts provided from Openzeppelin (OZ). I created the token contract and then made some basic unit tests. However, in one of ...
user avatar
  • 21
0 votes
0 answers
82 views

Approve and dis-approve ownership of erc721 tokens

I have created a contract which takes care of buy and sell of NFT's or ERC721 tokens. So i have approved the contract to sell the NFT. Now my questions are:- Once I have transferred the contract to a ...
user avatar
0 votes
0 answers
573 views

nft images not showing on opensea

I created 13 images and corresponding JSON files uploaded the images to pinata then changed the file_url in the JSON file to cid of the image "ipfs://cid/image.png" uploaded the json file as ...
user avatar
  • 11
0 votes
0 answers
33 views

Getting an error when I try to create a ERC20 token from another contract

I'm trying to create an upgradeable ERC20 contract from a Factory but I'm receiving an error, these are my contracts: The token contract // SPDX-License-Identifier: MIT pragma solidity 0.8.7; import &...
user avatar
  • 135
0 votes
0 answers
48 views

How can I create a factory of Upgradeable smart contracts?

I'm using OpenZeppelin hardhat plugin to deploy proxy contracts and I was asking myself how to achieve the same thing but from a contract. So for example I want to have a ProxyContractFactory that can ...
user avatar
  • 135
0 votes
2 answers
203 views

Solidity: Contract should be marked as abstract

I am trying to write a Smart Contract to generate Staking Rewards for an existing Cryptocurrency But I've been getting this error Contract "Stakeable" should be marked as abstract How do I ...
user avatar
0 votes
0 answers
46 views

Upgreadable ERC20 address cannot be passed as argument in another upgradeable contract

I created 2 smart contracts. contract A is ERC20 token and B is a contract that accepts ERC20 A as payment method. When deploying, contract A got deployed but when I passed the address where it was ...
user avatar
0 votes
1 answer
110 views

I can't deploy my Upgradeable contract using truffle plugins

I'm trying to deploy the following smart contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; ...
user avatar
  • 135
0 votes
0 answers
173 views

Upgrade ERC721 Contract

I've a question about an upgrade that I should apply to a contract that I deployed as upgradable (with openzeppelin Upgradable). I'm following the guidelines and best practices but I'm not sure the ...
user avatar
0 votes
1 answer
409 views

Deploy a contract passing data to the constructor

I'm trying to get familiarised with OpenZeppelin upgradable contracts but I find it difficult because there are not clear tutorials on how to do this kind of things so I'm using their docs to try to ...
user avatar
  • 135
0 votes
1 answer
111 views

Ownable Minimal Proxy (EIP-1167)

I'm trying to create a clone from a contract that has some privileged functions and inherits from Ownable. I realized that after cloning the owner variable is zeroed, so any privileged function, such ...
user avatar
  • 63
0 votes
1 answer
210 views

What's the point of OpenZeppelin Counters library

I've been studying ERC721 token smart contracts and saw Counters library. I can see it being used when token is being minted with .increment() and then you can check total supply with .current(). But ...
user avatar
  • 103
0 votes
1 answer
488 views

EnumerableSet vs Access Control in Openzeppelin

Openzeppelin offers RBAC whereby an address may be granted a specific set of responsibilities. I would like to know which might be considered a better practice - using Access Control Or using an ...
user avatar
0 votes
1 answer
223 views

How to Use OpenZeppelin's ERC721Votes in an NFT Minter Contract

I'm trying to incorporate the new draft-ERC721Votes in my NFT minter contract called NFTVotes.sol When draft-ERC721Votes.sol is inherited in the minter contract, VS Code is gives the following error: ...
user avatar
  • 103
0 votes
0 answers
103 views

Lazy minting multiple NFTs belonging to a collection

in my project right now we have implemented lazy minting using signed voucher messages the signer of which gets verified on chain and hence letting the purchaser pay for the gas fees of minting the ...
user avatar

1
2 3 4 5 6