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
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 });
};
I think there is a problem with the "send()" method, but I can't find a solution.