Could not find (truffle) configuration file and want a guide of minting contract

Hi, abcoathup
Question 1:
Error: Truffle is currently using solc 0.5.12, but one or more of your contracts specify “pragma solidity ^0.4.17”.
Should I change the 0.5.12 in the coinfig file to 0.4.17,so,Where is the config file,I couldn’t find it.I even don’t know it’s name.:joy:

Question 2:
is there a contract sample for creating Tokens for a exist ERC721 contract I have made before? Better to tell me which and where the code should be change.

1 Like

Hi @hibro,

In Truffle, the compiler is specified in truffle.js/truffle-config.js in the compilers section.

See the Truffle documentation for more details: https://www.trufflesuite.com/docs/truffle/reference/configuration#compiler-configuration

I would recommend (if they aren’t already deployed) to upgrade your contracts to Solidity 0.5 due to the number of improvements made in the compiler


I assume your existing ERC721 has a minting function. So I am not sure what you are after. If you can, it would be good if you could share your smart contract code.

I am using the ERC721Full.sol of openzeppelin,maybe should I modify the contract file ERC721Mintable.sol and deploy it ? the question is where should I modify it.

1 Like

Hi @hibro,

Assuming that you want metadata associated with your token, then you may also want to inherit from ERC721MetadataMintable. So that you could call mintWithTokenURI.

https://docs.openzeppelin.com/contracts/2.x/
Warning
You should always use the installed code as-is, and neither copy-paste it from online sources, nor modify it yourself.

If you need different functionality, you should inherit from the OpenZeppelin contract and override any required functionality rather than modifying the OpenZeppelin contract.

The following is a SimpleERC721 (with GitHub imports) that you could use to play around with on Remix. When using on Truffle you would need to change the imports to "@openzeppelin/contracts/..."

pragma solidity ^0.5.5;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.4.0/contracts/token/ERC721/ERC721Full.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.4.0/contracts/token/ERC721/ERC721MetadataMintable.sol";

contract SimpleERC721 is ERC721Full, ERC721MetadataMintable {
    constructor() ERC721Full("Token", "TKN") public {
    }
}

Great,it’s working well,so what should I do if I 'd like to mine a token called TKN ?

1 Like

Hi @hibro,

You can mint by calling mintWithTokenURI via Remix, see the following for more details:

So,how to call it out?
I don’t know if this right,First I should use the call function in DEBUG TOOLS FOR REMIX PLUGINS,and fill in the 3 blanks with plugin name,function name and function args?
what is plugin name,function name and function args?

1 Like
pragma solidity ^0.5.0;

import "./ERC721Metadata.sol";
import "../../access/roles/MinterRole.sol";


/**
 * @title ERC721MetadataMintable
 * @dev ERC721 minting logic with metadata.
 */
contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole {
    /**
     * @dev Function to mint tokens.
     * @param to The address that will receive the minted tokens.
     * @param tokenId The token id to mint.
     * @param tokenURI The token URI of the minted token.
     * @return A boolean that indicates if the operation was successful.
     */
    function mintWithTokenURI(address to, uint256 tokenId, string memory tokenURI) public onlyMinter returns (bool) {
        _mint(to, tokenId);
        _setTokenURI(tokenId, tokenURI);
        return true;
    }
}

could I mine it with the contract above? do you have an Examples of this code,so I can mine it with it.

Hi @hibro,

You need Deploy & Run Transactions plugin enabled.
See the Remix documentation for how to use:

Once the contract is deployed, you can then show the functions and call mintWithTokenURI

You can then provide the to, tokenID and the tokenURI e.g. ‘0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1’, 1, ‘https://example.com/token/1

Very nice,I have mined 1 token already by following your guidance.
Thank you very much.@abcoathup
if I ask one more question,could I mine out more than one token in one time?

1 Like

With the current contract you can only mint one token at a time.