15
votes
Accepted
What is IERC20?
contract ERC20 is IERC20
Interpret that this way:
ERC20 is an implementation of the Interface defined in IERC20.
IERC20 defines function signatures without specifying behavior; the function names, ...
13
votes
Slither Tool Error On Contract That Inherit From Openzeppeling
Slither use crytic-compile for compiling your contracts. If you specify the path to your contract crytic-compile will try to compile it using your installed solc version. solc can't resolve your "...
13
votes
Accepted
What does ERC721URIStorage actually mean?
It means that the tokenURIs are also stored in "storage". The base implementation in ERC721.sol reads the baseURI in memory and concatenates the resulting String on-the-fly, without storing ...
12
votes
Accepted
Function _setTokenURI() in ERC721 is gone in OpenZeppelin ^0.8.0 contracts
I raised this question to the OpenZeppelin forum and they quickly replied with the following feedback:
It is a Beta release and there may be small breaking changes prior to the stable release. There ...
12
votes
Accepted
Transfer only available for objects of type "address payable", not "address"
msg.sender is no longer a payable address anymore starting from Solidity 0.8.x. You can explicitly convert it to payable by using payable(msg.sender). That should resolve the error.
10
votes
safeTransferFrom is undefined in buidler test
Ran into this myself as well. Are you using ethers.js with Buidler?
The safeTransferFrom method is overloaded and generally with ethers.js the bare definition is the default method used.
If you run ...
8
votes
Accepted
How to override supportsInterface() function if contract needs to support many interfaces?
Your code already overrides the supportsInterface() method well and will cause all the extended contract's methods to be called. This method is also used by the OpenZeppelin Contracts Wizard.
If you ...
7
votes
Sign message with web3 and verify with openzeppelin-solidity ECDSA.sol
Rob, I see that you have already resolved (which is great).
For future readers:
For OpenZeppelin Contracts you can check the documentation for more information, in this case the Cryptography section:...
7
votes
Accepted
Understanding OpenZeppelin's Context contract
This question has been asked and answered on the OZ forum here : https://forum.openzeppelin.com/t/help-understanding-contract-context/10579.
The _msg.sender and _msg.data functions are in fact ...
6
votes
Accepted
Sign message with web3 and verify with openzeppelin-solidity ECDSA.sol
The problem is that eth.sign returns a signature where v is 0 or 1 and ecrecover expect it to be 27 or 28.
A note in the documentation for web3 v0.20 is clear:
Note that if you are using ecrecover,...
6
votes
Accepted
Missing artifacts for openzeppelin contracts with hardhat
gm. Have you tried with npx hardhat clean before compiling?
It will clear the cache and delete all artifacts.
Source
6
votes
Accepted
what does ERC721 _checkOnERC721Received do?
If is usually called after a token has been transferred (in same tx).
If the receiver of the token is a contract, it checks if the contract implements the onERC721Received interface.
If no, it reverts ...
6
votes
Accepted
How many storage gaps to add at the end of Base Upgradeable Contracts?
There is no optimal number as the use of storage gaps is just a convention.
I would suggest you use 50 as in the majority of the examples, but this is really up to you.
5
votes
What's the difference between Truffle Migrations and ZeppelinOS upgradeable contracts?
Smart contracts are immutable (code cannot be changed) by design.
Truffle and ZeppelinOS are platforms for the development of smart contracts for Ethereum based blockchains.
Truffle migrate manages ...
5
votes
Accepted
can etherscan.io show local ganache transaction details?
Etherscan will only show the details of the publicly available data relating to the public main and test networks.
ganache-cli runs an in-memory test framework that mimics a real blockchain on your ...
5
votes
Accepted
ERC20 not recognized by TokenTracker
Etherscan will recognize your contract once it will log its first Transfer event. This is how it works. Though, even before the first Transfer event was logged, you may view your contract in token ...
5
votes
How to implement "Mint" and "Own" in an ERC20 Token
They are still internal functions of the ERC-20 contract, see docs. So you can simply create a new contract that inherits from that one and add the mint function:
pragma solidity ^0.6.10;
import &...
5
votes
What's the difference between OpenZeppelin's IERC vs ERC contracts?
Short answer:
IERC is the Interface for the token contract.
ERC is the implementation of the token contract.
Interfaces are like blueprints, to make sure a Class (in our case, a Contract) ...
5
votes
What are Hooks and How are they used? Went thorough the explanation on the topic but can't wrap my head around it
Basically, it is a function for you to override; You can insert some checks here before the main execution code.
Or simply leave it as it is, it won't cost gas.
To read more about hook:
https://docs....
4
votes
Accepted
ERC721 how does tokenOfOwnerByIndex() list tokens owned by a user?
ERC721Token inherits from ERC721BasicToken.
When a new token is minted, _mint is called from ERC721Token, which then calls super._mint which is the _mint implementation from ERC721BasicToken.
super....
4
votes
Accepted
ERC721Token super._mint calls addTokenTo from the top level implementation
The solidity compiler does some "magic" when you include multiple files and do contract inheritance as is done in the ERC721 token contract. Ultimately it flattens the contract files into a ...
4
votes
How to test events that were sent by inner transaction / delegate call?
Use openzeppelin-test-helpers
Specifically use expectEvent.inTransaction
I created an example in the community forum for how to use:
https://forum.zeppelin.solutions/t/how-to-check-for-events-that-...
4
votes
Accepted
What's the difference between Truffle Migrations and ZeppelinOS upgradeable contracts?
In case of truffle the stored values will not remain in the upgraded contract whereas in proxy approach it is possible to obtain the stored values in the upgraded contract too.
In truffle upgrade a ...
4
votes
Accepted
Difference of using transfer vs _transfer in OpenZeppelin (same for dash functions)
The reason for function _transfer is simply code-reuse.
It is called from both functions transfer and transferFrom.
It can also be called from functions mint and burn, if you need to implement them.
...
4
votes
Accepted
Why does OpenZeppelin implement increaseAllowance and decreaseAllowance functions differently in their ERC20 contract?
In PR #2669 where those changes were made they mention Issue #2665. In that issue a comment by vladyan18 points that using unchecked reduces gas usage at deployment by 1723.
4
votes
Accepted
OpenZepplin simple crowdsale - can't buy tokens
Your token smartcontract is paused. Unpause it and repeat https://rinkeby.etherscan.io/token/0x327c24a16e028d5612b535a01f3d56d5f896cc2d#writeProxyContract
4
votes
How to use contracts from project dependencies in Brownie scripts?
You're close.
The dependencies section identifies where you want to download. You've correctly placed that part using github syntax. You want to download organization OpenZeppelin with repo ...
4
votes
Slither Tool Error On Contract That Inherit From Openzeppeling
For brownie
I was able to run slither scan directly on my .sol contract file (not on brownie project folder)
(Optional) I had to import dependencies in the project folder (as in my case brownie was ...
4
votes
Accepted
How can one access values returned via "return(0, returndatasize())"?
The solidity compiler (solc) will translate the return statements into return(ptr, size) opcodes.
The caller in order to access the callee returned data, in early EVM versions, had to pass a memory ...
4
votes
Accepted
Ownable in upgradeable contracts
You simply need to call the init method of OpenZeppelinUpgradesOwnable, which is __Ownable_init(), inside your initialize(...) method body. Also, remember to use the initializer to so as to restrict ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
openzeppelin-contracts × 304solidity × 163
openzeppelin × 121
erc-20 × 51
erc-721 × 48
contract-development × 26
remix × 23
truffle × 20
nft × 19
tokens × 18
hardhat × 17
proxy-contracts × 16
contract-upgrading × 15
crowdsale × 11
go-ethereum × 10
web3js × 9
blockchain × 9
ico × 9
upgrading × 8
solidity-0.8.x × 8
contract-design × 7
ethers.js × 7
erc-1155 × 7
contract-deployment × 6
inheritance × 6