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
1answer
8 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
16 views

What are the under-the-hood mechanics for locking an ERC-20 token?

I have some idea of what "locking ether" means, but I need to understand for sure. AFAIK, tokens exist at some address, but according to many sources, the token is locked in a smart ...
1
vote
1answer
457 views

How do I call the burnFrom() function once my contract is deployed?

I'm using the Openzeppelin library in my contract where MyToken is StandardBurnableToken. Once I deploy that and I want to burn a set amount of the initial supply how do I call the function? I don't ...
0
votes
0answers
39 views

Transfer Failing in Solidity Smart Contract

I am calling the following function from a front-end on a Solidity smart contract, but it is not transferring the price and commission amounts properly with the call functions, although the ownership ...
0
votes
3answers
63 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; ...
1
vote
2answers
127 views

OpenZeppelin contract not working on Kovan testnet

I created a simple smart contract using OpenZeppelin and deployed the contract to the Kovan testnet. However, when I send KEth to the contract using MetaMask, nothing happens (I believe the buyTokens ...
0
votes
0answers
14 views

Creating upgradable child contract

I am creating a contract fabric program in which if a new user comes, i will deploy a child contract for that user. My parent contract is openzepplin upgradable contract. Checking whether i can ...
0
votes
1answer
17 views

How to get address of an upgradeable smart contract in another smart contract

I have the following two contracts contract MyNFT is ERC721Upgradeable, OwnableUpgradeable { function initialize() initializer public { __ERC721_init_unchained("My NFT", "MNF"...
0
votes
1answer
77 views

ERC20Mintable contract call return wrong number

I use OpenZeppilin ERC20Mintable contract and add MaxSupply parameter to contraint the ERC20 token amount allowed to issue. what I want is only permit contract ower to view MaxSupply info, my ...
1
vote
1answer
45 views

Node version upgrade for contract deployment throws error

I wrote a solidity contract using version 0.4.24 using OpenZeppline-solidity version 1.12.0. This used to deploy using the Nodejs version 8.12. The Nodejs version 8 is no longer being maintained from ...
0
votes
0answers
21 views

What is the difference between SafeERC20.sol VS ERC20.sol

Need to understand the safeERC20.sol and ERC20.sol from openzeppelin I was reading the medium articles and unable to understand why safeERC20.sol has been used Please help me understand this Thanks
0
votes
0answers
17 views

Implementing Roles using OpenZeppelin's AccessControl.sol

First time poster so please go easy! I'm new to Solidity. Have been programming about 2-3 years & I'm working on an Ethereum supply chain dapp for a college project. I've got to the point where I ...
0
votes
1answer
15 views

Initialize function is not invoked during deployment of upgradeable contract

This is initialize function of my upgradeable contract contract MyContract is Initializable, ERC20PresetMinterPauserUpgradeable, OwnableUpgradeable { function initialize(string ...
1
vote
1answer
24 views

registerInterface and parent constructors in Solidity

The openzeppelin ERC721.sol file contains the following code: constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _registerInterface(...
0
votes
1answer
19 views

Using openzeppelin-test-environment to test upgradeable contract

openzeppelin-test-environment is quite a new package, it doesn't tell how to initialize the upgradeable contract https://github.com/OpenZeppelin/openzeppelin-test-environment Just a basic example from ...
0
votes
2answers
136 views

(Truffle) how to call finalize() function after finishing crowdsale

I would like to call token.transferOwnership(msg.sender) after finishing timed crowdsale. So, I inherited FinalizableCrowdsale contract, then override finalization() function to call transferOwnership ...
0
votes
1answer
19 views

Using openzeppelin Interfaces

If I import an openzeppelin Interface using @openzeppelin/contracts/token/ERC721/IERC721.sol, do I still need to declare the functions I wish to use found in the Interface, or the import statement is ...
2
votes
2answers
129 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 ...
0
votes
1answer
40 views

how to set tokenid in erc721 openzeppelin? [closed]

First of all, sorry if I'm asking an obvious question. In ERC721 openzeppelin API, to manage a token you always need to refer to a tokenId. Are you supposed to define a global variable, or a mapping ...
2
votes
1answer
33 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) ...
0
votes
1answer
25 views

Truffle build dont find _mint and _burn -DeclarationError: Undeclared identifier. Did you mean “mint”? _mint(to, amount);

after some trouble with remix I'm back at a npm/truffle/ganache setup... The reason why I tried out remix was: DeclarationError: Undeclared identifier. Did you mean "mint"? _mint(to, ...
0
votes
1answer
17 views

Why Transfer function doesn't check for allowance comparing to TransferFrom?

Why Transfer function doesn't check for allowance comparing to TransferFrom? Do I need to call increaseAllowance each time before calling TransferFrom? Ex implementation of Transfer without allowance ...
0
votes
2answers
259 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. ...
1
vote
1answer
109 views

ERC721 Metadata and Items

i'm new to ERC721 tokens so this may be a stupid question. Following the Opensea docs and other docs (for example openzeppelin ones), I just create a simple ERC721 token that i called "avatar" which ...
0
votes
1answer
137 views

My contract is deployed but instance is undefined

I have deployed a contract on the ganache blockchain successfully using truffle. In the truffle console, I can call the contract fine truffle(development)> MyCoin [Function: TruffleContract] { ...
0
votes
0answers
48 views

Ether Transaction failed to crowdsale contract

I have deployed a token on ropsten. it works and i can transfer tokens. Now i deployed crowdsale contract but when i send ether to crowdsale contract the transaction fails. I am using remix and ...
0
votes
1answer
522 views

Error in creating instance of deployed contract using truffle console

I deployed Token and Crowdsale contract in separate migration files. During Migration, there was no error. Migration logs are share: Running migration: 2_deploy_token.js Deploying DappToken... ......
1
vote
1answer
20 views

OpenZeppelin balanceOf(address) function Vs Mapping

The OpenZeppelin ERC-721 library has a function called balanceOf(address owner), which enables one to know how many tokens an address owns. Furthermore, one can also use a mapping in order to keep ...
0
votes
0answers
17 views

How to use signed message and prevent replay attack when using openzeppelin ERC20 contract?

openzeppelin ERC20 provide building blocks to quickly build ERC20 smart contract. Here is an simple example: pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/token/ERC20/ERC20....
2
votes
1answer
495 views

openzeppelin,VM Exception while processing transaction: revert

using openzeppelin-solidity to create crowdsale. Then I use this statement to Buy Token: MyCrowdsaleInstance.sendTransaction({ from: purchaser[1], value: web3.utils.toWei("0.5", "ether"), ...
0
votes
1answer
17 views

can a developer delete balances trough a contract update using openzeppelin

I am new to this and just have some arbitrary questions regarding upgradeable smart contracts. If a Developer would update his contract, could he modify all mappings / variables entirely? Wipe ...
0
votes
1answer
46 views

Abstract contract not inheriting constructor from parent abstract contract

I'm using solidity 0.7.1 and I seem to be running into issues while inheriting from an abstract contract. Specifically with the open zeppelin library, now I'm not creating an issue there because their ...
0
votes
2answers
285 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 ...
0
votes
0answers
97 views

ERC721 Token Transfer Outside Smart Contract

I am using OpenZeppelin ERC721 implementation for my non fungible tokens. Basically I have a smart contract which inherits from the OZ ERC721.sol. I am just wondering is the tokens only transferable ...
0
votes
1answer
171 views

npm install - - global @openzeppelin/cli not working

Guys I have node js and npm installed. But when I try to install OpenZeppelin sdk using the command: npm install --global @openzeppelin/cli It doesn't install. I don't know what is wrong. But I think ...
0
votes
1answer
17 views

Call method of another contract from one contract in upgradable smartcontract

I have two contracts Vase and Box contract Vase { uint256 public vase1; event VaseValueChanged(uint256 newValue); function createVase(uint256 newValue) public { vase1 = newValue; ...
0
votes
0answers
246 views

Gas estimation fail

I am using remix and ganache and metamask and I encounter a confusing error. I compiled and deployed USDT at 0xdac17f958d2ee523a2206206994597c13d831ec7 on ganache with no problem. In order to do ...
0
votes
1answer
69 views

Is it possible to put the initial ERC20 supply into a contract holding address that is not the token creators address?

With the standard open zeppelin ERC20 contracts, a fixed supply can be created by minting all of the new tokens to the contract creator. But this does not 'look good' and has the risk of the contract ...
3
votes
1answer
112 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 ...
0
votes
1answer
89 views

buyTokens throws error when is is getting called

Whenever I the buyTokens function is getting executed, I am getting below error Reason provided by the contract: "ERC20: transfer amount exceeds allowance". Debug the transaction to get more ...
1
vote
1answer
706 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 ...
2
votes
1answer
86 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 ...
0
votes
1answer
34 views

OpenZeppelin default FixedSupply contract not sending balance to sender

I'm deploying a very standard openzeppelin ERC20 contract with the following code: pragma solidity ^0.6.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract ERC20FixedSupply is ERC20 ...
2
votes
1answer
33 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 ...
0
votes
1answer
54 views

How to structure a contract for future upgrades

Imagine I have a contract I have implemented and deployed like this: pragma solidity ^0.6.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters....
0
votes
1answer
45 views

Does a symbol have to be unique in ERC721? How to find out a unique symbol?

As per the ERC-721 contract on OpenZeppelin, you can create a token with this constructor: constructor(string _name, string _symbol) public {} Does the "_symbol" have to be unique across the ...
1
vote
1answer
144 views

Dynamic Delegate Proxy contract

I'm familiar with proxy contracts in solidity using the 'delegatecall' to separate out the proxy contract from the logic contract. Is there a simple way to choose the logic contract based on an ...
1
vote
1answer
112 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 ...
3
votes
1answer
526 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,...
0
votes
0answers
47 views

Token transfer lock after crowdsale

I am faced with a problem regarding the ICO and Token smart contracts (SCs). I am currently using OpenZeppelin SCs to create my token and ICO and everything is working fine. Now I would like to add a ...