MetaMask - RPC错误:无效参数:必须提供以太坊地址



我正在尝试与DyDx协议集成,并试图在PrivateAPI上执行一些操作:

const client: DydxClient = new DydxClient(
DYDX_HOST,
{
networkId: 5,
web3: new Web3(window.ethereum),
},
);

调用APICredentials调用时,失败:

client.onboarding.recoverDefaultApiCredentials(
address,
).then((response) => {
console.log("response for api keys", response)
});

下面是错误:

"{
"code": -32602,
"message": "Invalid parameters: must provide an Ethereum address.",
"stack": "Error: Invalid parameters: must provide an Ethereum address.n    at new r (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-2.js:1:322950)n    at i (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-2.js:1:325706)n    at Object.invalidParams (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-2.js:1:326213)n    at p (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background-0.js:10:31397)n    at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background-0.js:10:29445n    at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:38021n    at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:38404n    at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:37125n    at new Promise (<anonymous>)n    at a._runMiddleware (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:36782)n    at a._runAllMiddleware (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:36688)n    at async chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:35360"
}
at new r (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-2.js:1:322950)
at i (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-2.js:1:325706)
at Object.invalidParams (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-2.js:1:326213)
at p (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background-0.js:10:31397)
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background-0.js:10:29445
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:38021
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:38404
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:37125
at new Promise (<anonymous>)
at a._runMiddleware (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:36782)
at a._runAllMiddleware (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:36688)
at async chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-6.js:19:35360"

我已经尝试将GoreliaTestNet地址转换为checkSum:

const address = Web3.utils.toChecksumAddress(accounts[0]);

但还是没有运气。

找到了解决方案,只好添加签名方法。

client.onboarding.recoverDefaultApiCredentials(
address,SigningMethod.MetaMask
).then((response) => {
console.log("response for api keys", response)
});

相关内容

  • 没有找到相关文章

最新更新