0

What do these two error messages mean ?

Warning Message:

Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> contracts/GabeCoin.sol:120:19:
|
120 | function mint(address account, uint256 id, uint256 amount)
| ^^^^^^^^^^^^^^^

Warning: Function state mutability can be restricted to pure
--> contracts/GabeCoin.sol:96:9:
|
96 | function uri(uint256 _tokenId) override public view returns (string memory){
| ^ (Relevant source part starts here and spans across multiple lines).

1 Answer 1

2

Both of the messages are warnings, not error messages.

The first warning specifies that you have an unused parameter in the function that is not used in the logic of the function definition. The compiler is trying to help you save gas and remove the unused parameter. If you don't want to remove it, you can ignore the warning.

The second warning specifies that the designated function doesn't read the state variable of the contract, also not make any modifications to the contract state variables. Pure functions are usually used with an arithmetic calculation without reading any contract state variables or use globally available properties (msg.data and msg.sender) or functions that do not make state changes (keccak256() and ripemd160()).

3
  • Thank you this is very helpful in me upstanding.
    – Frantz M.
    Nov 21, 2022 at 2:17
  • P, thxs! The unused parameters I would like to remove, what do you recommend I remove here. function mint (address account, uint256 id, uint256 amount) public payable { require(msg.value== publicPrice); _mint(msg.sender, id, amount, ""); }
    – Frantz M.
    Nov 21, 2022 at 2:43
  • This depends on your design. If you are minting NFT tokens, you can take a look at the ERC721 standard here: docs.openzeppelin.com/contracts/2.x/api/token/… Nov 21, 2022 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.