html 未捕获(在承诺中)错误:'args.method'必须是非空字串

kuarbcqp  于 2022-12-02  发布在  其他
关注(0)|答案(1)|浏览(134)

1.当我尝试连接metamask钱包与我的本地网站时,我得到这个错误
1.我正在使用eth_requestAccounts方法,但遇到了向下错误

inpage.js:8 Uncaught (in promise) Error: 'args.method' must be a non-empty string.
    at o (inpage.js:8:31826)
    at Object.invalidRequest (inpage.js:8:32276)
    at l.request (inpage.js:1:37391)
    at HTMLButtonElement.Connect (index.js:13:27)

这是在我的控制台上打印的错误

// HOW TO CONNECT YOUR METAMASK TO YOUR FRONTEND

const button = document.getElementById("ConnectButton");
//button.addEventListener('click',connect);
if (button) {
  console.log("button successfully imported");
} else {
  console.log("BUtton is not imported");
}

const Connect = async () => {
  if (typeof window.ethereum !== "undefined") {
    await window.ethereum.request({ methord: "eth_requestAccounts" });

    button.innerHTML = "Connected";
  } else {
    button.innerHTML = "Pls install metamask";
  }
};

button.addEventListener("click", Connect);

我的索引. js

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FUND ME</title>
</head>
<body>
    <h1>HELLO WORLD
    </h1>
    <button id="ConnectButton">Connect</button>
    <script src="index.js"></script>
</body>
</html>

我的索引. html

jv4diomz

jv4diomz1#

可能是打字错误。您使用的是methord而不是method

相关问题