Mint NFT Game Characters in One Click

Hi @ashbeech,

Great tutorial in 6 minutes: https://youtu.be/a3zIFrJl7UU
and code https://github.com/ashbeech/moralis-nft-game

In the .env (copy of .env-example) I have to fill in Moralis values, the 1st 3 are found at servers ‘View details’ -> ‘Server Details’: application_id, server_url and master_key.

For the ‘optional info’ it is clear to change the abipath to my local path and the others are only needed for a local (ganache) chain (which i not use)?

But not clear what to fill in for these:

REACT_APP_API_URL=
REACT_APP_API_KEY=
REACT_APP_CHAR_CONTRACT=

Can you explain?

Yes, no problem.

REACT_APP_MORALIS_APPLICATION_ID = Found in ‘View Details’ on your Moralis server instance you’ve created at Moralis Admin dashboard.

REACT_APP_MORALIS_SERVER_URL = Found in ‘View Details’ on your Moralis server instance you’ve created at Moralis Admin dashboard.

REACT_APP_MASTER_KEY= // <-- Found in ‘View Details’ on your Moralis server instance you’ve created at Moralis Admin dashboard.

REACT_APP_API_URL= // <-- Likely to be this URL: https://deep-index.moralis.io/api/v2/ipfs/uploadFolder found under Moralis Web3 API.

REACT_APP_API_KEY= // <-- Found under Moralis Web3 API reference.

REACT_APP_CHAR_CONTRACT=“0x…” // <-- Link to in-game asset contract, deployed locally via Truffle and Ganache or Remix

I hope this answers it for you.

Thank you, will check!
Found the values and app runs.

For contract in Truffle map I had to do next steps, to compile and deploy the contracts to ropsten or rinkebey testnet networks…

update truffle-config.js:

const { projectId, mnemonic } = require('./.secrets.json');
const HDWalletProvider = require('@truffle/hdwallet-provider');
// ProjectId: https://infura.io/docs/gettingStarted/chooseaNetwork
// npm install @truffle/hdwallet-provider

module.exports = {
  contracts_directory: "./contracts",

  // Uncommenting the defaults below
  // provides for an easier quick-start with Ganache.
  // You can also follow this format for other networks;
  // see <http://truffleframework.com/docs/advanced/configuration>
  // for more details on how to specify configuration options!
  //
  networks: {
    develop: {
      host: "127.0.0.1",
      port: 7545,
      chainId: 1337,
      network_id: 1337,
      deploymentPollingInterval: 10,
    },
    ropsten: {
      provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/${projectId}`),
      network_id: 3,       // Ropsten's id
      gas: 5500000,        // Ropsten has a lower block limit than mainnet
      confirmations: 2,    // # of confs to wait between deployments. (default: 0)
      timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
      skipDryRun: true,    // Skip dry run before migrations? (default: false for public nets )
      from: `${from}`
    },
    rinkeby: {
      provider: function() { 
       return new HDWalletProvider(mnemonic, `https://rinkeby.infura.io/v3/${projectId}`);
      },
      network_id: 4,
      gas: 4500000,
      gasPrice: 10000000000,
      from: `${from}`
    },
  },
  //
  // Truffle DB is currently disabled by default; to enable it, change enabled:
  // false to enabled: true. The default storage location can also be
  // overridden by specifying the adapter settings, as shown in the commented code below.
  //
  // NOTE: It is not possible to migrate your contracts to truffle DB and you should
  // make a backup of your artifacts to a safe location before enabling this feature.
  //
  // After you backed up your artifacts you can utilize db by running migrate as follows:
  // $ truffle migrate --reset --compile-all
  //
  // db: {
  //   enabled: true,
  //   host: "127.0.0.1",
  //   adapter: {
  //     name: "sqlite",
  //     settings: {
  //       directory: ".db",
  //     },
  //   },
  // },
};

Get an infura key as projectId : https://infura.io/docs/gettingStarted/chooseaNetwork

create the .secrets.json file (my values not shown) and this file added to a .gitignore file):

{
    "mnemonic": "..metamask secret words..",
    "projectId": "..infura project ID..",
    "from": "..my metamask address.."
}

run:
npm install @truffle/hdwallet-provider
truffle compile --reset
truffle deploy --network rinkeby

=> success.
Since contracts are not changed , the …/contracts/contractInfo.json does not to be updated with abi data of the deployed contract (see contract at its testnet explorer) and add contract address of Deployed Metacoin as REACT_APP_CHAR_CONTRACT in .env

to run:
yarn
yarn start