Metamask: function selector not found in hardhat node
Here is an article that explains the problem you are facing with the metamask functions, not found, has not found a mistake by calling an intelligent contract of your reactjs application:
Metamask function selector not found error
When decentralized applications (APPS) develop, it is common to interact with contracts based on Ethereum using web3 bookstores such as Ethers.js. However, a common problem that can arise is the error “functions of functions not found” in the Hardhat node.
In this article, we will deepen what causes this error and how you can resolve it by calling an intelligent contract of the REACTJS application using Metamask.
What is Metamask?
Metamask is an Ethereum portfolio that allows users to interact with Blockchain Ethereum. It provides a friendly interface to manage private keys, send transactions and access various Ethereum network features.
FUNCTION FUNCTOR NOT FOUND HARD HARDHAT
When using the Hardhat node to fill in and distribute intelligent contracts, Metamask must know which functions to use to interact with the contract. However, if this information is not provided or incorrect, you will find an error “functions of functions not found”.
Here is an example of what can go wrong:
`Javascript
Import {compile} of ‘hardhat-Tipescript’;
Const Compileconttract = async (contractant, ABB) => {
try {
Contract contract = waiting for compilation (counterattack);
Const Binascii = Buffer.from (Abb.Map ((Key) => Key.thpe) .join (‘,’, ‘));
Const Selector = ‘0x’ + Binascii;
Console.log (selector); // This must be the correct functions selector
// Now you are calling the contract with this selector
Waiting for contract.at (selector) .Call (‘GettkedePepostoMount’, Inputtken);
} Catch (error) {
console.error (error);
}
};
`
In this example,selector 'is a hexadecimal sequence that represents the bytecode Ethereum for the function' Gettkendepositount '. The
at () methodobject '' returns a new contract with the specified selector. However, if you use an intelligent contract from the Metamask collection, such as the "Sushiswap" contract, it will have a different bytecode.
What happens when using Metamask?
There are several reasons why it is possible to find an error "functions of functions not found":
- Have incorrect : If the intelligent contract is not correct or absent some functions, the Metamask may not determine the correct functions selector.
- Metamask
Collection: When using a Metamask Smart collection contract (e.g. SUSHISWAP), it is necessary to specify the correct bytecode in the functioncompilecrattract ‘.
3
Resolution of the problem
To solve this error, make sure:
- You have compiled and correctly implemented your intelligent contract using a tool such as Truffle or Vyper.
2
- Your Hardhat project has the necessary structures and settings.
Here is an updated example that uses the SUSHISWAP contract:
`Javascript
Import {compileconttract} of “Hardhat-Pedript”;
Import ‘@nomiclabs/hardhat-waffle’;
Const compile = asynchronous (contract name, have) => {
try {
Contract contract = waiting for compilation (counterattack);
Const Binascii = Buffer.from (Abb.Map ((Key) => Key.thpe) .join (‘,’, ‘));
Const Selector = ‘0x’ + Binascii;
// Now you are calling the contract with this selector
Return I expected contract.at (selector) .Call (‘GettkenDepositamunt’, Inputtken);
} Catch (error) {
console.