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
1
vote
1answer
32 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 ...
0
votes
1answer
24 views

error: type address payable is not implicitly convertible to expected type contract "IERC20""

So I'm testing out deploying a crowdsale contract (using remix). First I deployed the token contract (I tried multiple versions, but here's one contract example taken from the openzeppelin forums): // ...
0
votes
0answers
36 views

How do I set initial supply for a ERC-1155?

In my smart contract I set 2 different token types: uint256 public constant COIN = 0; uint256 public constant OBJECT_NFT = 1; And my constructor has the initial mint for a specific address, but when ...
1
vote
1answer
24 views

Cloning while providing arguments for construction function

I am trying to clone my contract by using Clones.sol from OpenZeppelin. The cloning procedure is successful, although I cannot pass them my desired arguments which should be provided for construction ...
0
votes
1answer
93 views

ERROR: Contract should be marked as abstract [duplicate]

Hi I am following a tutorial on Chainlink NFTs but I get this error below which reads: Contract should be marked as abstract. Now I see this same question was asked before however in that person's ...
0
votes
1answer
23 views

ERC20 Decimals In Transfer

I got it why we need decimals in ERC20s. But the thing I can't get it: When we are using transfer() method, should we write amount in wei (for ERC20s decimals count) or just integere. For example: If ...
0
votes
2answers
62 views

how to transfer tokens from user to smart contract using methods in the smart contract?

i have an erc20 token called TokenA, i want the user to be able to call a function from my smart contract that does some calculations and then transfers X amount of TokenA to the smart contract. the ...
0
votes
1answer
36 views

Overriding a function does not work as expected

I'm not sure I understand how overriding a function works in solidity. I am working on an ERC721 token based on the OpenZeppelin implementation. OpenZeppelin's ERC721.sol contains the following ...
0
votes
0answers
57 views

How does EIP-2891 handle royalties?

I want to add secondary royalties to my smart contract for OpenSea and Rarible and also have royalties for the artist after every mint. I've been reading up on royalties implementations, specifically ...
1
vote
1answer
37 views

Can I send ETH to an Smart Contract address?

I'm developing an Smart Contract based in the Openzeppelin's Crowdsale one. When I test the Crowdsale Smart Contract manually, sending ETH with metamask, the SC returns me the correct amount of tokens....
1
vote
1answer
60 views

Counters.Counter vs totalSupply

Creating my first contract and was taking a look at the Open Zeppelin wizard. I notice that it includes a Counters.Counter private _tokenIdCounter;, which tracks the amount of tokens minted. When I ...
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 ...
0
votes
1answer
28 views

How Contract Method Works in Changing State Variable?

So, I'm trying to implement openzeppelin ERC721Enumerable contract. I want to override _beforeTokenTransfer method. Because it was a Hook, I have to call super method like this function ...
0
votes
1answer
32 views

Error: DeclarationError: Undeclared identifier while using IERC20

Code: pragma solidity ^0.6.2; import "@opengsn/gsn/contracts/BaseRelayRecipient.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract MyContract is ...
1
vote
1answer
68 views

OpenZeppelin Context.sol smart contract is abstract, why?

I was digging into this OZ smart contract: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol As you may see, it has only two functions to deal with metatxs....
0
votes
1answer
33 views

It is safe to use OpenZeppelin v2.5 contracts (Solidity 0.5.0) in 2021?

I was checking some pretty old contract samples of OpenZeppelin v2.5, and they are in Solidity 0.5.0, and I am not sure if it is a safe version, or not. If I extend these types of contracts, it makes ...
0
votes
0answers
52 views

How to access upgradeable contract using golang

Recently I'm writing some UUPS pattern proxy contract with upgradeable features. Due to some limitations of my works, I need to deploy both proxy and implementation contract in golang. However, ...
0
votes
1answer
381 views

ERC-721 token metadata not displayed on NFT marketplaces when using IPFS

I have the following contract deployed to the Rinkeby testnet: https://rinkeby.etherscan.io/token/0x2d29fc6c1b20c35669fb55fa3144cdd529302256 I deployed the metadata and images using IPFS. When I try ...
2
votes
1answer
249 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/...
0
votes
0answers
17 views

Where to find SafeMath pragma solidity ^0.6.6?

While trying to use SafeMath to compute the modulo of a uint256 like shown in this video:https://www.youtube.com/watch?v=JqZWariqh5s (without SafeMath) I'm having some trouble finding a pragma ...
0
votes
2answers
270 views

Ownable in upgradeable contracts

I'm trying to get my head around the Ownable role in Upgradeable contracts in open zeppelin. It seems there have been a lot of updates recently and most tutorials and answers are therefore outdated. I'...
0
votes
0answers
12 views

SafeMath Utility Error in Ethereum Document 'Unique Digital Asset' Code

I refer to the example code 'Unique Digital Asset' code in Ethereum Doc (https://ethereum.org/en/developers/docs/smart-contracts/anatomy/#unique-digital-asset) line 60. uint256 id = SafeMath.sub(...
1
vote
2answers
61 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 ...
0
votes
1answer
622 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.
0
votes
2answers
231 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/...
3
votes
2answers
77 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 ...
0
votes
2answers
30 views

How to use Rinkeby to display web3 front end of smart contract other than localhost

Is there some functionality with Rinkeby to display my smart contract on something other than localhost so that other members of my team can access the frontend? Will I have to make my own server or ...
2
votes
1answer
54 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 ...
0
votes
1answer
47 views

BalanceOf(address) method returning an Array of several values rather than a single one after a transfer

The Token challenge on Ethernaut - function returning Arrays in console - why? // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract Token { mapping(address => uint) balances; uint ...
1
vote
1answer
63 views

How do Abstract classes help prevent reentrancy for multiple accounts?

I was reading through the openZeppelin contracts and saw the ReentrancyGuard contract, and realized I don't know how the EVM deals with these contracts. Assuming you have a class: contract someClass ...
0
votes
0answers
59 views

:38:14: ParserError: Expected '(' but got identifier, got this error when trying to compile this code, can someone help please,thank you

pragma solidity 0.6.6; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol"; contract AdvancedCollectible is ...
0
votes
1answer
157 views

totalSupply() count issue

I'm writing an NFT minting contract with openZeppelin and have 2 functions that can mint tokens. mint and reserveMint. Each function can be invoked independent of each other in various order at ...
0
votes
0answers
208 views

TypeError: Type function (uint256) pure returns (string memory) is not implicitly convertible to expected type string memory

In Remix I'm getting this strange error while calling Strings.sol library: TypeError: Type function (uint256) pure returns (string memory) is not implicitly convertible to expected type string memory. ...
2
votes
2answers
529 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. ...
0
votes
0answers
74 views

Import Open Zepplin Contracts from Github

I'm trying to write a simple aggregator for aave, (I couldn't find a good example for one which uses aave V2) So I decided to cheat, and piece meal things together off of Polycats Github I noticied ...
0
votes
0answers
237 views

Try to setup an 1155 token to be render with all its metadata (name, description, image) to opensea.io

I have the smart contract below pragma solidity ^0.8.2; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/...
0
votes
2answers
702 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 ...
0
votes
1answer
138 views

@openzeppelin/contracts: Why can't I use a Gnosis Safe as the crowdsale wallet?

I have a crowdsale contract which inherits the following contracts from openzepplin: contract MyCrowdsale is Crowdsale, TimedCrowdsale, AllowanceCrowdsale, PostDeliveryCrowdsale, ...
0
votes
1answer
161 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 { ...
0
votes
1answer
45 views

What does variable _allowances mean?

i was trying to understand this ERC20 Contract in OpenZeppelin. In 36th line there is a mapping which defines _allowances, it is being used in multiple lines (120, 155, 177, 196, 311) and i don't get ...
0
votes
1answer
15 views

Can I change the code in openzeppelin library in the node modules?

I am doing nft platform like opensea using openzeppelin. There are some limitations in openzeppelin like only the owner can send the token to anyone. I don't want to use approve function. If I comment ...
0
votes
1answer
17 views

wrapping state variables in struct

I asked this question in OZ forum and I'm asking it here again. The question is Why a state variable is wrapped in a struct in their Counters library. Please see the question in that post. Thanks.
0
votes
1answer
131 views

OpenZepplin simple crowdsale - can't buy tokens

I have a very simple OpenZepplin (v2.5.1) crowdsale contract deployed on Rinkeby Testnet. But when I try to buy tokens it fails with SafeERC20: low-level call failed Why? pragma solidity ^0.5.5; ...
1
vote
0answers
120 views

Transferring NFT Tokens without the ownership of the tokens but approving the contract address as operator

https://github.com/ProjectOpenSea/opensea-creatures/blob/master/contracts/ERC721Tradable.sol Someone please explain me the function at line 91
0
votes
0answers
35 views

Contract's admin keys/ownership relations

I have debated with myself about smart contract's admin keys and ownership and how this can occur in different ways. I will try to point some of the findings that I have found: OpenZepellin community ...
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 ...
0
votes
0answers
418 views

Get the error "ERC1155: caller not owner or approved" even after calling setApprovalForAll function

I have a question about the openzeppelin erc1155.sol contract. It is regarding operator approval and the safeTransferFrom() function. I am trying to do an ERC1155 token transfer and keep getting the ...
3
votes
1answer
941 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....
0
votes
0answers
111 views

What's the purpose of 'initializing' and 'initialized' in OpenZeppelin's Initializable contract?

The OpenZeppelin Initializable.sol contract includes a modifier initializer() that shows: modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance ...
1
vote
2answers
53 views

How can I do an internal transfer using OpenZeppelin code?

I have a contract that holds all its tokens. Now I need to transfer tokens to an user that sends some BNB to its "receive" fallback. So... in OpenZeppelin derived contracts we have no access ...