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
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, ...
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 ...
9
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 ...
9
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 ...
6
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:...
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
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,...
5
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 ...
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
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 ...
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 ...
3
votes
Accepted
How to burn non burnable ERC20?
Option 1 seems like the simplest option, but Ethereum has "precompiles" (hardcoded smart contract like keccak256 etc.) at some of those low-numbered addresses. If you want to avoid those, you could ...
3
votes
Accepted
Importing in SOLC to deploy smart contract
solc can't get things over a network - it can only import local files, which was your initial error.
I'm assuming your npm install step is still leading to failure because the compiler is still ...
3
votes
Make a crowdsale reusable?
This sounds like a perfect use case for the now finalized ERC-1155 token standard, which allows one to manage any number of fungible and non fungible tokens in a single contract.
3
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....
3
votes
Accepted
Compilation error using SafeMath
The reason you are getting that error is because num is of type uint8, and the sub() function of SafeMath is looking for type uint256. Additionally you declare using SafeMath for uint;, which confirms ...
3
votes
Accepted
low-level call failed
Potential areas to look at which could be causing your problem when using the default emission Crowdsale:
Set an appropriate rate
Need to transfer (enough) tokens to the Crowdsale
For information on ...
3
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 ...
3
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 &...
3
votes
Installation of openzeppelin/contracts Library
If you run npm uninstall @openzeppelin/contracts and then npm install @openzeppelin/contracts@2.3.0, then retry the import, then it should work.
Also, check your truffle-config.js file and see if the ...
3
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.
...
3
votes
why require() is checked after executing transfer()
First of all, a transaction will revert unless all conditions are successfully met. In this example, it means that you can perform the _transfer() successfully, but if the require afterwards fails, ...
3
votes
Accepted
Why are there two functions with the same name in ERC721 OZ contract?
You can have multiple functions with the same name, as long as their signature is not the same. The parameters are also part of the signature, so the function signature of those two functions is ...
3
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.
3
votes
Error HH411: The library openzeppelin-solidity is not installed. Try installing it using npm (for old 0.5.0 solidity code)
Thanks to @zmy comment, pointing to https://www.npmjs.com/package/openzeppelin-solidity.
2.3.0 is earliest version on npm registry as "@openzeppelin/contracts"
https://www.npmjs.com/package/@...
3
votes
Why does Openzeppelin's CountersUpgradeable library wrap arithmetic in an unchecked block?
It's cheaper to use unchecked blocks and check for overflows and underflows manually than let Solidity do it. Refer to Is the modulo operation cheaper in unchecked arithmetic? for more details.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
openzeppelin-contracts × 236solidity × 124
openzeppelin × 86
erc-20 × 46
erc-721 × 44
contract-development × 20
truffle × 20
nft × 20
remix × 17
tokens × 15
crowdsale × 11
contract-upgrading × 10
go-ethereum × 9
ico × 9
proxy-contracts × 9
web3js × 8
contract-design × 8
brownie × 7
contract-deployment × 6
hardhat × 6
blockchain × 5
truffle-migration × 5
truffle-contract × 5
inheritance × 5
import × 5