0

I made a conversion from Solidity 0.4.17 to 0.6.2 of a contract that have a MINT option.

The biggest problem here is that I am not sure if this function mint is okay (will return the correct id).

Look:

     function mint(string memory _outer, string memory _inner) public payable onlyOwner{
    Filio memory _filio = Filio({ outer: _outer, inner: _inner });
    filios.push(_filio);
    uint _filioId = filios.length - 1;
//    return _filioId;

    _mint(msg.sender, _filioId);

The full code are here:

pragma solidity ^0.6.2;

import 'openzeppelin-solidity/contracts/token/ERC721/ERC721.sol';
import 'openzeppelin-solidity/contracts/access/Ownable.sol';

contract FiliosToken is ERC721, Ownable {
    
    constructor() ERC721 ("FiliosToken", "FIL") public {
    
}

  struct Filio {
    string outer;
    string inner;
  }

  Filio[] public filios;

  function getFilio( uint _filioId ) public view returns(string memory outer, string memory inner){
    Filio memory _fili = filios[_filioId];

    outer = _fili.outer;
    inner = _fili.inner;
  }

  function mint(string memory _outer, string memory _inner) public payable onlyOwner{
    Filio memory _filio = Filio({ outer: _outer, inner: _inner });
    filios.push(_filio);
    uint _filioId = filios.length - 1;
//    return _filioId;

    _mint(msg.sender, _filioId);
  }
}

So, when I try to deploy the truffle return an revert error.

  • It appears to be correct. Do you get any error message? – Ismael Jun 25 '20 at 19:36
  • Hi Ismael, thanks for the answear! On tests with "truffle test" give em an error that only the owner can mint! But the first test was to mint and transfer the ownership to my address. – Leandro Machado Jun 26 '20 at 12:06
  • What does the tests look like? Truffle deploys new contract instances if tests are in separate unit test. – Ismael Jun 26 '20 at 17:14
  • The tests test all functions, the only function that I get errors are the "mint" Here the whole contract: github.com/machado-rev/Filio – Leandro Machado Jun 26 '20 at 21:10
  • There some problems with your project: the contract is named FiliosToken but the file is FilioToken.sol, it is referenced as FilioToken in tests so it loads a .json in build that doesn't match the compiled file. Also your code uses function tokensOf from ERC721, but it was removed in OpenZeppelin contracts. I see no problem with code or tests. – Ismael Jun 28 '20 at 0:29

Your Answer

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

Browse other questions tagged or ask your own question.