-1

I encountered the following problem while creating a dApp using "React Js", "web3.js", and "web3-react".

This is Error message..

Returned error: rejected due to project ID settings

This is Error log.. enter image description here

I don't know why this error occurs. And even if I searched Google, it was hard to find the exact answer....

I made it using the following technology.

React Js, Web3.js, Web3-React, Solidity, Infura

My Contract URL

0xa8aa254fb5bB9DEd6de3e767b9A9Aa962bD98185

Problem Code .sol

struct SignBlock{
        uint no;
        string name;
        string date;
        string depart;
        string fileName;
        string filePath;
        address writerAddr;
    }
    SignBlock[] sb;
   
    uint no_cur = 0;
    
    function makeBlock(string memory name,string memory date,string memory depart,string memory fname, string memory fpath)  public {
        SignBlock memory tmp;
        tmp.no = no_cur++;
        tmp.name=name;
        tmp.date=date;
        tmp.depart = depart;
        tmp.fileName=fname;
        tmp.filePath=fpath;
        tmp.writerAddr=Owner;
        sb.push(tmp);
    }

Problem Code ../lib/mycontract.js

import Web3 from "web3";
export const web3 = new Web3(
    new Web3.providers.WebsocketProvider(
        "wss://ropsten.infura.io/ws/v3/c1df0953ad0a489fb24ab898d60a57c8"
    )
);
export const CONTRACT_ADDRESS = "0xa8aa254fb5bB9DEd6de3e767b9A9Aa962bD98185";
export const ABI =[<My ABI>];
export const Mycontract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

Problem Code ../lib/connectors.js

import { InjectedConnector } from "@web3-react/injected-connector";

export const injected = new InjectedConnector({
    supportedChainIds: [1, 3, 4, 5, 42],
});

Problem Code Signed.js

import React, { useState } from "react";
// Web3-react
import { useWeb3React } from "@web3-react/core";
import { Mycontract } from "../lib/mycontract";
function Signed() {
    const { account, active, deactivate } = useWeb3React();
let date = new Date();
    let now = date.toLocaleString();
    const [block_, setBlock] = useState({
        name: "",
        depart: "",
        time: "",
        fname: "",
        path: "",
    });
...
const makeSigned = () => {
       
        var s = `Block!\nname : ${block_.name}\ndepart : ${block_.depart}\ntime : ${block_.time}\nfname : ${block_.fname}\npath : ${block_.path}`;
        alert(s);
        document.getElementsByClassName("usr")[0].value = "";
        document.getElementsByClassName("dp")[0].value = "생산";
        document.getElementsByClassName("target_file")[0].value = "";
        document.getElementsByClassName("filepath")[0].value = "";
        Mycontract.methods
            .makeBlock(
                String(block_.name),
                String(block_.time),
                String(block_.depart),
                String(block_.fname),
                String(block_.path)
            )
            .send({ from: account, gas: 300000 });
    };

My Infura SECURITY setting enter image description here enter image description here enter image description here

I think there is a problem with the "send()" method, but I can't find a solution.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Pupba
  • 9
  • 2

1 Answers1

0

The error is specific to Infura. Remove the contract address from allowlist:

enter image description here

That should work.

Tahlil
  • 1,031
  • 1
  • 14
  • 26
  • Thank you for your help. But I ran into another problem. I met this error... "Error: The method eth_sendTransaction does not exist/is not available" – Pupba Aug 29 '22 at 08:20
  • I think the `account` variable is not defined. When is the `Signed` function called? – Tahlil Aug 30 '22 at 06:13
  • **Signed** function is call when user clicks button. Umm... I will only use **web3.js** instead of **web3-react** library – Pupba Aug 31 '22 at 02:09