Metamask: Internal JSON RPC error for variables of the state
Assert Ethers.js User Doloying Absorption A Vyper infects Avalanche Fuji Tests Surg, in this article we will delve into the way you can get an internal json-rpc.
non-spine json-rpc and ethers.js
Before diving, let’s review the bases:
* JSON-RPC : The report of communication standards between nodes is a blockchain network. It enables Securre and efficient data transfer.
* Ethers.js : Popular JavaScript Library for integration with Ethereum networks using Web3 or Truffles.
Problem: JSON-RPC internal error
When you call a variable that you have a metamas wall, Shuold you get an internal relationship of the Json-RPC monkey, it is not possible. How, I don’t have the most common Syr.
Here is an explanation how it can manifest this:
The supplement has a Vyper contract `user ', which specifies the span variable:
Username' 'and' e -mail '' YOUSE Weser these variables from Svelte's subsection using ethers.js in Metamask:
Javacript
Import {Ethers} with "Ethers";
constadddress = '0x ...';
Const Contactabi = [...]; // Your Contract Vyper Abi
// recovery
Async Connecttocontract () {function
Const Provider = New Ethers.provids.web3Provider (Window.ethereum);
Return Expectal Provider.connect (Contractddress);
}
// Call the first variable condition outside the contract
Function getuserinfo () {
Connection = expectation Connecttocontract ();
to try {
Const Wer = Wait for the.GETACCOUNTS () [0] connection;
console.log (user.username); // This Shuold works well
} catch (error) {
if (Ethers.error error instance) {Right
Throwing error; // International JSON-RPC earring
}
}
}
// Call a sexy variable from the contract
Getprophilinfo () function {
Connection = expectation Connecttocontract ();
to try {
Const Wer = Wait for the.GETACCOUNTS () [0] connection;
console.log (user.email); If
} catch (error) {
if (Ethers.error error instance) {Right
Throwing error; // International JSON-RPC earring
}
}
}
re
Functions "Getteustuserinfo () variable states. However, during "GetProfileinfo (), the international JSON-RPC circle:
Javacript
// this shuold does not work well
Getprophilinfo () function {
Connection = expectation Connecttocontract ();
to try {
Const Wer = Wait for the.GETACCOUNTS () [0] connection;
console.log (user.email); // International JSON-RPC earring
} catch (error) {
if (Ethers.error error instance) {Right
Throwing error; // International JSON-RPC earring
}
}
}
re
Distinction?
The problem is how Ethers.Ss manual variables are in contracts. When you call your contract with a variable, you don't have to demand to pay Surue The Themes.
However, while taking out similar versions, he must dominate the tests themselves, it is a network with a new ceremony.
To solve this problem, you can do it.
- Use the Ethers.jsConnect’s : Instet a Calling
Getaccounts () [0]
, try to use Connect (). He (‘Connected’, (concent) => {}). This will contain a new knot and configure the advertising list.
2.
HELP HELP UNDERSTAND CYCLES CRYPTOCURRENCIES