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.
316
questions
0
votes
1
answer
46
views
Is it possible for two users to receive the same nonce-generated ID in a Solidity smart contract?
I have a smart contract deployed on the Ethereum blockchain where each user who interacts with a specific function is assigned an ID based on a nonce value stored in the contract. The nonce is ...
0
votes
1
answer
29
views
ERC721Enumerable - Getting all tokens owned by an address using balanceOf(owner) and tokenOfOwnerByIndex(owner, index)
I've been looking for a solution to retrieve all tokens from an address using ERC721Enumerable Openzeppelin extension. Please note that my purpose is not to get ALL tokens owned by an address, but all ...
0
votes
1
answer
12
views
How to execute a transaction on a Gnosis Safe using Governor.sol? (getting GS020 error)
I'm trying to use a Governor.sol DAO to execute a passed proposal to transfer tokens from a Gnosis Safe. The Safe is a 1-of-2 with one of the signers being the DAO.
The last argument to safe....
1
vote
1
answer
13
views
Can I use the OZ Ownable contract with a multisig wallet if I want some functions to require varying voting thresholds?
Some functions like the mint() will require unanimous approval from contract owners, while others will only require simple majority of contract owners. I want to use Safe Wallet or some other ...
0
votes
1
answer
10
views
Issues due to openzeppelin updated versions
Im building defi token Im developing it with reference cource in which the educator is using openzeppelin version 4.8.3 in which ERC20Mock contract takes 4 parameters , but right now there is only ...
0
votes
2
answers
27
views
Trying to override non-virtual function. Did you forget to add "virtual"?
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract OC is ERC20, Ownable {
uint256 ...
0
votes
1
answer
21
views
Truffle test error "VM exception" ERC721
I have just created a .sol contract inheriting from openzeppelin ERC721. I have also written some tests, but I get the following errors:
Here is the code for .sol file:
// SPDX-License-Identifier: ...
0
votes
0
answers
17
views
Runtime error webpack-dev-server, solidity, openzeppelin
I'm working on a project using Truffle, solidity and openzeppelin. For web, I'm using the webpack-dev-server.
With Truffle, everything works, it compiles and migrates. Then I start the frontend with ...
0
votes
0
answers
11
views
Governance execute proposal of the governance contract itself or any other contract or restrict functions to come from a proposal only in the erc20
Is it possible to have a proposal that executes a function from the governance contract itself?
namely i would like to have every expense of the dao to come from a proposal.
does the target have to be ...
1
vote
1
answer
69
views
Help Needed: Resolving "EIP2612: Invalid Signature"
I am encountering an error message "EIP2612: invalid signature" when testing the permit function in my contract.
This is my contract:
// @inheritdoc IPayments
contract Payments is IPayments {...
0
votes
1
answer
48
views
How to use Access Control in different facets if a Diamond Contract
I am looking to change the design of my contract into diamond proxy. For that i have split up my contract into 3 parts. the issue i am facing is while setting up access control. When i am using OZ ...
0
votes
0
answers
26
views
MAX TOTAL SUPPLY ON ETHERSCAN IS 0
I deployed my token to MetaMask and it did not reflect the token name or the decimal. I manually had to input it. After I deployed to etherscan it is showing MAX TOTAL SUPPLY: 0 HOLDERS 0 TOTAL ...
1
vote
1
answer
82
views
TESTS FOR MY ERC20 TOKEN IS NOT WORKING
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/...
0
votes
1
answer
50
views
Two or more base classes define function with same name and parameter types
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol&...
3
votes
1
answer
23
views
What can be the workaround to work with the new `Initializable` contract?
If we are using the initializable contract before OZ 0.5.0 for our transparent Upgradeable proxy.
It had two variables in slot 0.
uint8 private _initialized;
bool private _initializing;
Now in OZ 0.5....
0
votes
1
answer
72
views
An ERC1155 token metadata is not visible in polygonscan and etherscan
I have deployed a basic ERC1155 importing the Openzeppelin libraries.
Here is my smart contract.
// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8....
0
votes
1
answer
62
views
"ContractExecutionError: Error happened while trying to execute a function inside a smart contract" after calling it via mint button
Contract Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/...
0
votes
1
answer
47
views
Openzeppelin ERC721Enumerable getTokenIdsOfOwner reverts and I don't know why
I am trying to implement a staking contract, I wanted to map all the owned NFTs by a certain address, so came across ERC721Enumerable and getTokenIdsOfOwnerfunction, however whenever I call my ...
0
votes
1
answer
203
views
Upgrading Smart Contracts with New Fields: How to Safely Modify Storage Layout
I'm working on upgrading my Ethereum smart contract, which utilizes upgradable smart contract patterns. Currently, I have a struct named GovernorCountingSimpleStorage with existing fields, and I want ...
0
votes
2
answers
81
views
Smart contract creation
I just joined because I am trying to learn how to create Solidity contracts using OpenZepplin.
I am using also claude AI to guide me but it has a limit and it's going in circles now.
Until now I ...
0
votes
1
answer
43
views
ERC721 Transfer Event in Constructor
I thought that when you mint an ERC721 Token in the Constructor of your smart-contract it will not emit the Transfer event.
I'm thinking this cause of what's written in the official ERC721 EIP ...
1
vote
2
answers
351
views
UUPS vs Beacon proxy pattern
I am delving into UUPS(Universal Upgradeable Proxy Standard) and Beacon proxy patterns.
I believe they serve distinct purposes, but I am unsure about the right use cases for each.
It seems that UUPS ...
3
votes
0
answers
82
views
How to get admin address while deploying transparent upgradeable proxy from OZ
After OZ version 5, the admin contract is deployed from within the constructor of the proxy.
And the admin address is emitted in the events of the deployment transaction. To get the admin address we ...
1
vote
1
answer
43
views
Can I use safeTransfer from OpenZeppelin to send ETH along with ERC20 token?
My contract holds tokenA + ETH. Right now I pay users this way:
tokenAcontract.safeTransfer(wallet, amountTokenA); // tokenA
Address.sendValue(wallet, amountETH); // ETH
Can I do it in one single ...
1
vote
1
answer
83
views
Proxy Contracts Initializing problems
Good afternoon. I’ll be brief - there is a Module in my ecosystem, the module is initialized by the proxy factory DeployProxy.sol and then the proxy contract address is entered into the Core contract ...
0
votes
1
answer
34
views
Getting "insufficient allowance" error
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./TokenA.sol";
import "./TokenB.sol";
contract ...
0
votes
0
answers
435
views
Anti Sniper / anti Snipe Bot for newly listed token on pancakeswap
Can Somebody explain how to have Bot Protection enabled against sniper bot for a token contract which is going to launch on pancakeswap or on any other decentralised exchange.
do we have to create ...
2
votes
1
answer
295
views
OZ transparent upgradeable proxy admin reverts when trying upgrade an implementation
I have this transparent upgradeable proxy deployed on sepolia - 0x2dFC2A866eac363cAFF516b5ce7aCd6bae1F21C1
This is the admin contract - 0x6d429719f78b146892403d06df677afa6f968d91
When I try to call ...
1
vote
0
answers
116
views
Handling Conflicting @openzeppelin/contracts Versions in Hardhat Project
I am currently working on a Hardhat project that requires the integration of two custom dependencies, namely custom-dep-a and custom-dep-b. Unfortunately, these two dependencies rely on different ...
0
votes
0
answers
15
views
Issues in the ERC20 token Contract burn
I was just going through this contract and that the _balances[account] is being deducted before the require statement. Is this still correct?
also there was no else and seemed like it will be ...
0
votes
1
answer
104
views
Problem with "Openzeppelin ERC20Votes delegate function"
I hope you're doing great. I have been tinkering with ERC20Votes and creating a DAO for my Vendor contract. The issue I'm facing is that whenever I try to delegate my GovernanceToken contract to the ...
0
votes
1
answer
9
views
new release of ERC1155SupplyUpgradeale has compilation issues
The new contracts lib from OZ, specifically ERC1155UspplyUpgradeable
has compilation issues before even inheriting it in any child contract (check screenshot below) any idea why? or how to fix it?
...
0
votes
0
answers
19
views
Construction of OpenZeppelin voting contract with ٍERC777 token
I managed to easily create governor and implement voting with erc20 token, but now I have erc777 token that I need to do this with, please guide me how I can I have to do this because when I introduce ...
0
votes
1
answer
188
views
OpenZeppelin: Update UUPS proxy contract
I have such proxy:
import { upgrades } from "hardhat";
proxy = await upgrades.deployProxy(
Contract,
[
address,
flags,
],
{
initializer: "...
0
votes
1
answer
63
views
Does the OpenZeppelin nonReentrant modifier block calling all functions that have the modifier on them, or it keeps a separate state for each function
Would the nonReentrant modifier from the OpenZeppelin ReentrancyGuard library prevent the user from calling stake() when the unstake() function hasn't yet been fully processed (in the example below)?
...
1
vote
0
answers
205
views
Create3 deployment with proxy contract ownership?
I have deployed an upgradable proxy contract with create3factory from solmate.
In my contract i transfer ownership to an address. But still the owner ship is not on that address. Its a differant ...
1
vote
1
answer
150
views
Property 'PROPOSER_ROLE' does not exist on type 'BaseContract'
TimeLock contract extends from TimelockController from OpenZeppelin Contracts.
contract TimeLock is TimelockController {
constructor(
uint256 minDelay,
address[] memory proposers,
...
1
vote
1
answer
1k
views
Property 'address' does not exist on type 'BaseContract'
I have TimeLock contract that extends TimelockController from OpenZeppelin contracts:
contract TimeLock is TimelockController {
constructor(
uint256 minDelay,
address[] memory proposers,
...
0
votes
1
answer
27
views
Issue with DynamicSvgNft Contract: getHighSVG() and getLowSVG() Functions Returning Incorrect Values
Hello Stack Exchange community!
I am currently working on a project that involves an NFT contract called DynamicSvgNft. The contract is designed to change the SVG image URI of the NFT based on a ...
0
votes
1
answer
33
views
1155URIStorage not available in npm package but is available on OpenZeppelin Github
I can import
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol"; on Remix.
But it throws an error in Hardhat.
I have attached a picture of node_modules and it ...
0
votes
2
answers
101
views
UUPS proxy and file level constants, enums and structs compatibility
If i use UUPS upgradeable pattern and i define a couple of constants, enums and structs at the contract level, will those values still be available after an upgrade?
I have 3 contracts and all 3 are ...
0
votes
1
answer
25
views
How to limit canceller role in OpenZeppelin governance?
In openzeppelin governance contracts, a proposal can be cancelled by a wallet that has the canceller role. As the deployer of the DAO, I want to ensure the security of my DAO, hence I want to be able ...
3
votes
1
answer
1k
views
Do we need OpenZeppelin's Counter with Solidiity 8 any more?
According to Solidity documentation:
Prior to Solidity 0.8.0, arithmetic operations would always wrap in
case of under- or overflow leading to widespread use of libraries that
introduce additional ...
1
vote
1
answer
237
views
Is there still any reason to use SafeERC20Upgradeable with the ERC20Upgradeable?
From the ERC20Upgradeable docs:
"We have followed general OpenZeppelin Contracts guidelines:
functions revert instead returning false on failure. This behavior is nonetheless
conventional and ...
0
votes
1
answer
75
views
What are the pros and cons of using OpenZeppelin ERC20Votes?
I want to use this extension for an ERC20 token.
What are the pros and cons (if any) of adding this to it?
1
vote
1
answer
693
views
How can i pass constructor args to test solidity contracts in Hardhat?
I am using openzepplin with role based access control to create erc-20 token
constructor(address minter, address burner) ERC20("ArtPlace Token", "ARTP") {
_mint(msg.sender, ...
1
vote
1
answer
121
views
Help me to make my idea clean on initializer, reinitializer and disableinitializer
Openzeppelin has a solidity script initializable.sol which has some modifiers and internal functions. I wanna clear my idea on these. I am describing what i know about it, correct me if i am wrong.
...
0
votes
1
answer
471
views
Derived contract must override function "supportsInterface". Two or more base classes define function with same name and parameter types
TypeError: Derived contract must override function "supportsInterface". Two or more base classes define function with same name and parameter types.
--> royalty.sol:9:1:
|
9 | contract ...
0
votes
1
answer
44
views
how to receive values from openzeppelin royaltyInfo function
trying to implement like this
uint[2] memory royalty = royaltyInfo(_tokenId, price);
payable(royalty[0]).transfer(royalty[1]);
but getting error
TypeError: Different number of components on the left ...
2
votes
1
answer
576
views
onlyInitializing vs initializer in OpenZeppelin Upgradeable Contracts
I'm reading the OpenZeppelin documentation about upgradeable contracts, and I'm getting a bit confused with these modifiers:
initializer
onlyInitializing
I think I understand how initializer works. ...