calling a function using ethers shows not a function in react #1456
-
edited by @ricmoo; I've moved the relevant information from your linked issue.txt here The const ABI = [
// ...
{
"inputs": [
{
"internalType": "uint256",
"name": "shareId",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "buy",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "shareId",
"type": "uint256"
}
],
"name": "buy",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}
]
const provider = await new ethers.providers.Web3Provider(window.ethereum);
const signer = await provider.getSigner();
const nftreseller = await new Contract(
"0x8d0Fe38C4E0ba76c4070fB59D5659e5Bbb1072A3",
ABI,
signer
);
const tx = nftresellerr.buy(shareid, overrides); |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
Can you provide more details please? Code? ABI? Contract address? Network? :) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
pls refer this i have mentioned details in it |
Beta Was this translation helpful? Give feedback.
-
I am assuming you mean the method You have multiple definitions of // There are two "buy" methers, so you must specify which you mean:
// - buy(uint256)
// - buy(uint256,bytes)
contract["buy(uint256)"](shareId, overrides) If you trim down the ABI to exclude the ones you don't use, you will be able to have cleaner code (the code you have already would work) and you would cut about 2 megabytes off your application size, as most of that (massive) ABI is unused. :) Just a suggestion though. :) |
Beta Was this translation helpful? Give feedback.
-
I know this is a year old but I'm surprised how no one saw the mistype under
change nftresellerr to nftreseller and your code should be good to go. |
Beta Was this translation helpful? Give feedback.
I am assuming you mean the method
buy
?You have multiple definitions of
buy
in your ABI, so you need to specify which you mean. I highly recommend you trim down your ABI to just include the methods you use, but if you wish to keep the full ABI, you will need to use:If you trim down the ABI to exclude the ones you don't use, you will be able to have cleaner code (the code you have already would work) and you would cut about 2 megabytes off your application size, as most of that (massive) ABI is unused. :)
Just a suggestion though. :)