minter-dapp icon indicating copy to clipboard operation
minter-dapp copied to clipboard

CATCH ERROR: ERROR STATUS: 403 on npm run deploy_contract

Open alvaranz83 opened this issue 3 years ago • 3 comments

Version

  • [X] Yes

General Question

  • [X] No

What happened?

I generate images, Json, ipfsMetas, ipfsMetasGeneric, genericJson and also updated config.js accordingly as per tutorial and all is good, but when I try to run deployContract.js script I get the following catch error. CATCH ERROR: ERROR STATUS: 403

I get the error right after confirming "y" prompt.

I see that the code runs ok inside the first try because I can see the log console.log(PREREVEAL_TOKEN_URI);

Code Below:

const basePath = process.cwd();
const fs = require("fs");
const yesno = require('yesno');

const {
  fetchNoRetry,
} = require(`${basePath}/utils/functions/fetchWithRetry.js`);
let {
  CHAIN,
  GENERIC,
  CONTRACT_NAME,
  CONTRACT_SYMBOL,
  METADATA_UPDATABLE,
  ROYALTY_SHARE,
  ROYALTY_ADDRESS,
  MAX_SUPPLY,
  MINT_PRICE,
  TOKENS_PER_MINT,
  OWNER_ADDRESS,
  TREASURY_ADDRESS,
  PUBLIC_MINT_START_DATE,
  BASE_URI,
  PREREVEAL_TOKEN_URI,
  PRESALE_MINT_START_DATE,
  PRESALE_WHITELISTED_ADDRESSES
} = require(`${basePath}/src/config.js`);

const deployContract = async () => {
  const ok = await yesno({
    question: `Is all REQUIRED contract information correct in config.js? (y/n):`,
    default: null,
  });

  if(!ok) {
    console.log("Exiting...");
    process.exit(0);
  }

  if(GENERIC) {
    try {
      let jsonFile = fs.readFileSync(`${basePath}/build/ipfsMetasGeneric/_ipfsMetasResponse.json`);
      let metaData = JSON.parse(jsonFile);
      if(metaData.response === "OK") {
        if(!PREREVEAL_TOKEN_URI) {
          PREREVEAL_TOKEN_URI = metaData.metadata_uri;
          console.log(PREREVEAL_TOKEN_URI);
        }
      } else {
        console.log('There is an issue with the metadata upload. Please check the /build/_ipfsMetasGeneric/_ipfsMetasResponse.json file for more information. Running "npm run upload_metadata" may fix this issue.');
      }
    } catch (err) {
      console.log(`/build/_ipfsMetasGeneric/_ipfsMetasResponse.json file not found. Run "npm run upload_metadata" first.`);
      console.log(`Catch: ${err}`);
      process.exit(0);
    }
  } else {
    try {
      let jsonFile = fs.readFileSync(`${basePath}/build/ipfsMetas/_ipfsMetasResponse.json`);
      let metaData = JSON.parse(jsonFile);
      console.log ("hello");
      if(metaData.response === "OK") {
        if(!BASE_URI) {
          BASE_URI = metaData.metadata_directory_ipfs_uri;
        }
      } else {
        console.log('There is an issue with the metadata upload. Please check the /build/_ipfsMetas/_ipfsMetasResponse.json file for more information. Running "npm run upload_metadata" may fix this issue.');
      }
    } catch (err) {
      console.log(`/build/_ipfsMetasGeneric/_ipfsMetasResponse.json file not found. Run "npm run upload_metadata" first.`);
      process.exit(0);
    }
  }

  if (!fs.existsSync(path.join(`${basePath}/build`, "/contract"))) {
    fs.mkdirSync(path.join(`${basePath}/build`, "contract"));
  }

  try {
    const url = `https://api.nftport.xyz/v0/contracts/collections`;
    const contract = {
      chain: CHAIN.toLowerCase(),
      name: CONTRACT_NAME,
      symbol: CONTRACT_SYMBOL,
      owner_address: OWNER_ADDRESS,
      metadata_updatable: METADATA_UPDATABLE,
      royalties_share: ROYALTY_SHARE,
      royalties_address: ROYALTY_ADDRESS,
      max_supply: MAX_SUPPLY,
      mint_price: MINT_PRICE,
      tokens_per_mint: TOKENS_PER_MINT,
      treasury_address: TREASURY_ADDRESS,
      public_mint_start_date: PUBLIC_MINT_START_DATE,
      presale_mint_start_date: PRESALE_MINT_START_DATE,
      base_uri: BASE_URI,
      prereveal_token_uri: PREREVEAL_TOKEN_URI,
      presale_whitelisted_addresses: PRESALE_WHITELISTED_ADDRESSES
    };
    const options = {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify(contract),
    };
    const response = await fetchNoRetry(url, options);
    fs.writeFileSync(`${basePath}/build/contract/_deployContractResponse.json`, JSON.stringify(response, null, 2));
    if(response.response === "OK") {
      console.log(`Contract deployment started.`);
    } else {
      console.log(`Contract deployment failed`);
    }
    console.log(`Check /build/contract/_deployContractResponse.json for more information. Run "npm run get_contract" to get the contract details.`);
  } catch (error) {
    console.log(`CATCH: Contract deployment failed`, `ERROR: ${error}`);
  }
};

deployContract();```






### What have you tried?

I've checked that my.env is correct with my NFT port API key correctly written
I've checked my config.js file is correct and I've updated accordingly
I Googled and asked on Stackoverflow

### Relevant log output

```shell
PS C:\Users\alvar\Desktop\NFTs\minter-dappv2-main\backend> npm run deploy_contract

> [email protected] deploy_contract
> node utils/nftport/deployContract

Is all REQUIRED contract information correct in config.js? (y/n): y
ipfs://bafkreiarlczb5b2fy73ok5ygcu2reavxktirx3uvtkgkfw2whif3z34vkm
CATCH ERROR: ERROR STATUS: 403

Protect your information

  • [X] I Agree

alvaranz83 avatar Apr 30 '22 23:04 alvaranz83

did you find the problem ? There is an issue with the metadata upload. Please check the /build/_ipfsMetasGeneric/_ipfsMetasResponse.json file for more information. Running "npm run upload_metadata" may fix this issue. CATCH ERROR: ERROR STATUS: 403

cepums112 avatar May 07 '22 14:05 cepums112

did you find the problem ? There is an issue with the metadata upload. Please check the /build/_ipfsMetasGeneric/_ipfsMetasResponse.json file for more information. Running "npm run upload_metadata" may fix this issue. CATCH ERROR: ERROR STATUS: 403

I'm getting the same error no matter how many times I run "npm run upload_metadata".... :(

andrei653popa avatar May 09 '22 20:05 andrei653popa

if you wait a few seconds after each "enter" maybe it could be fixed. I think your actions should be slow.

Phosedious avatar Jun 20 '22 19:06 Phosedious