Metamask: International Json-RPC for Specific Welsh
How and ethers.js, which work on the Vyper counteract for Avalanche Fuji Testnet, with Svete, he, verifiable, test the problems that are assembled by access to the adverbial. In this state, we subtracted in, why you can get the intrauterine json-rpc at the call of the expiration of the counteract, but not the second very dim.
fall JSON-RPC and Ethers.js
We will be in the face of the
* JSON-RPC : Standard Protocol for Sweetie Intererbuts Network blockchain. This provides a free and efficient transfer of data.
* Ethers.js
: Popular Library JavaScript for mutuality with the ethereum network with the web3 or the large horns.
Problem: International Json-RPC
At the call of the expiration of the counteract on the Metamask Koshelek you have to do the intra-RPC, if the substantial is inappropriate. In some cases, however, this one can be protected, if you can get access to the same part -time counteract in one and the same test network.
That
In addition, you have a vyper contract, which defines the two expanded status: “Name of the Polish” and “E -mail”. You would want to release these expirations from the Svelte with Ethers.js: Metamask:
`Javascript
{Ethers} Import; Ethers;
Const Contractaddress = '0x ...';
Const Contractabi = [...]; // counteratta viper - abi
// Install attitudes with the Testnet contract
Async Function ConnectTocontract () {
Const Service provider = new ethers.poviders.web3Provider (Window.ethereum);
Avairats to the post. ConcT (Contractaddress);
}
// Call the first part -length counteract
FUNCTION GETUSERINFO () {
Const connection = Wait for ConnectTocontract ();
Ask {
Const User = Wait for Connection.getaccounts () [0];
console.log (user.username); // This is to work well
} Catch (error) {
IF (copy ethhers.error liner) {
Brating the scoop; // Intramentible json-rpc
}
}
}
// Call the acre
Function GetProfileeinfo () {
Const connection = Wait for ConnectTocontract ();
Ask {
Const User = Wait for Connection.getaccounts () [0];
console.log (user.email); // This is too much to work well
} Catch (error) {
IF (copy ethhers.error liner) {
Brating the scoop; // Intramentible json-rpc
}
}
}
As you can see, the function of GetUserinfo () successfully causes the substantial status. However, at the existence of
GetProfileeinfo (), the intracelling json-rpc:
Javascript
// This is not to work well
Function GetProfileeinfo () {
Const connection = Wait for ConnectTocontract ();
Ask {
Const User = Wait for Connection.getaccounts () [0];
console.log (user.email); // Intramentible json-rpc
} Catch (error) {
IF (copy ethhers.error liner) {
Brating the scoop; // Intramentible json-rpc
}
}
}
Why do I spin?
The problem is concluded as ets.js is accessible to the substantial status of the contract. When he calls a contract, he is asked to reach the 100th, using “contractabi”, and the hiding is the appropriate function of the installer.
However, if you have access to a similar part -styling of the other counteract in one and the same dust network, the method “Getacounts ()” Verut the empty massive for each new connection. It is concluded in that we do not have the fullness of the pre -trial record.
You can use the following decrees to resolve the problems:
1
Using the features of Ethers.js “Connect” : Failure to call “Getacounts ()”, Try Connect (). ('Connected', (Account) => {})
. This is connected with a new hacking and establishing an attack on the storage, when he is sublime.
2