Error: transaction failed [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (transactionHash="0xbb66d1e3f26ae14e1e18e03f765631edac474e18337ed6626da3aedb5627dbb5", transaction={"hash":"0xbb66d1e3f26ae14e1e18e03f765631edac474e18337ed6626da3aedb5627dbb5","type":2,"accessList":null,"blockHash":null,"blockNumber":null,"transactionIndex":null,"confirmations":0,"from":"0x4640B7F438E9F136704D47C754cDea1A61edf686","gasPrice":{"type":"BigNumber","hex":"0x59682f15"}, #5891
Replies: 1 comment 7 replies
-
the Card Component with the Code `import React, { useEffect, useState } from 'react'; const customStyles = { const shortenAddress = (address) => { const Card = ({ item , Contract }) => { useEffect(() => {
}, [item]); function openModal() { function closeModal(){
}; return ( NFT ID: {item.tokenId} Seller: {shortenAddress(item.seller)} Price: {item.price} {/* CSS Flexbox container /} NFT ID: {item.tokenId}Seller: {shortenAddress(item.seller)} Price: {item.price} {/ Flex container for the buttons */} Buy ); }; export default Card; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Unable to Debug this error in my marketplace project im conforming the transaction from wallet but its reverting it everytime i did checked the parameters and all variables being passed but still the transaction is being reverted everytime
card.js:70 An error occurred while buying the NFT: Error: transaction failed [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (transactionHash="0xbb66d1e3f26ae14e1e18e03f765631edac474e18337ed6626da3aedb5627dbb5", transaction={"hash":"0xbb66d1e3f26ae14e1e18e03f765631edac474e18337ed6626da3aedb5627dbb5","type":2,"accessList":null,"blockHash":null,"blockNumber":null,"transactionIndex":null,"confirmations":0,"from":"0x4640B7F438E9F136704D47C754cDea1A61edf686","gasPrice":{"type":"BigNumber","hex":"0x59682f15"},"maxPriorityFeePerGas":{"type":"BigNumber","hex":"0x59682f00"},"maxFeePerGas":{"type":"BigNumber","hex":"0x59682f15"},"gasLimit":{"type":"BigNumber","hex":"0x07a120"},"to":"0xA0Db67C5A14a2805B4157d8799449EA0B271188f","value":{"type":"BigNumber","hex":"0x06f05b59d3b20000"},"nonce":2,"data":"0x0e8ea80f0000000000000000000000009ae05d7e0da0c1ddeeb82d106a72cf18a6e84d880000000000000000000000000000000000000000000000000000000000000012","r":"0x4bdb21a4e822f7a27ed230e4f5d49bef4171ac6c2f42a93d4ff17c73ffb5e03d","s":"0x12d0f7ea291cb92388558a8f63187e1ada29dd5ce8636eef01de0245390f6e8e","v":1,"creates":null,"chainId":0}, receipt={"to":"0xA0Db67C5A14a2805B4157d8799449EA0B271188f","from":"0x4640B7F438E9F136704D47C754cDea1A61edf686","contractAddress":null,"transactionIndex":12,"gasUsed":{"type":"BigNumber","hex":"0x016f02"},"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000002000000000000000000000000000000000000000000000000000800000000000000000040100000000000000000000000000000000000000000000000000000000000080000000040000000000000000000000000000000080000000000000000000000000000000000000200000000000000000000000000000000000000000000000000040000000004000000000000000000001000000000000000000000000000000100000000000000000000000000000000000000000080000000000000000000000000000100000","blockHash":"0xa772f584ba1573c771368257cf1e9ab4d3cc439647d7a879c187ee72e505efe5","transactionHash":"0xbb66d1e3f26ae14e1e18e03f765631edac474e18337ed6626da3aedb5627dbb5","logs":[{"transactionIndex":12,"blockNumber":38084602,"transactionHash":"0xbb66d1e3f26ae14e1e18e03f765631edac474e18337ed6626da3aedb5627dbb5","address":"0x0000000000000000000000000000000000001010","topics":["0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63","0x0000000000000000000000000000000000000000000000000000000000001010","0x0000000000000000000000004640b7f438e9f136704d47c754cdea1a61edf686","0x000000000000000000000000c275dc8be39f50d12f66b6a63629c39da5bae5bd"],"data":"0x0000000000000000000000000000000000000000000000000000802d0e315e000000000000000000000000000000000000000000000000000ddfb6598ad363c000000000000000000000000000000000000000000000122a447bad2ee8a11f6d0000000000000000000000000000000000000000000000000ddf362c7ca205c000000000000000000000000000000000000000000000122a447c2d5bf6d27d6d","logIndex":49,"blockHash":"0xa772f584ba1573c771368257cf1e9ab4d3cc439647d7a879c187ee72e505efe5"}],"blockNumber":38084602,"confirmations":3,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x216521"},"effectiveGasPrice":{"type":"BigNumber","hex":"0x59682f0f"},"status":0,"type":2,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.7.2) at Logger.makeError (index.ts:269:1) at Logger.throwError (index.ts:281:1) at Web3Provider.<anonymous> (base-provider.ts:1549:1) at Generator.next (<anonymous>) at fulfilled (base-provider.ts:1:1) buyNft @ card.js:70 await in buyNft (async) callCallback @ react-dom.development.js:4164 invokeGuardedCallbackDev @ react-dom.development.js:4213 invokeGuardedCallback @ react-dom.development.js:4277 invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4291 executeDispatch @ react-dom.development.js:9041 processDispatchQueueItemsInOrder @ react-dom.development.js:9073 processDispatchQueue @ react-dom.development.js:9086 dispatchEventsForPlugins @ react-dom.development.js:9097 (anonymous) @ react-dom.development.js:9288 batchedUpdates$1 @ react-dom.development.js:26140 batchedUpdates @ react-dom.development.js:3991 dispatchEventForPluginEventSystem @ react-dom.development.js:9287 dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js:6465 dispatchEvent @ react-dom.development.js:6457 dispatchDiscreteEvent @ react-dom.development.js:6430
MY contract .sol on Mumbai polygon address : 0xA0Db67C5A14a2805B4157d8799449EA0B271188f
`//SPDX-License-Identifier:MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
/* Interface */
interface IERC721Extended is IERC721 {
function tokenURI(uint256 tokenId) external view returns (string memory);
}
/* errors */
error Marketplace__PriceShouldbeGreaterThanZero();
error Marketplace__Address_notApproved();
error Marketplace__NftAlreadylisted(address nftAddress, uint256 tokenId);
error Marketplace__Only_NftListed();
error Marketplace__isnotListed();
error Marketplace__PriceNotmet();
error Marketplace__noProceeds();
error TransactionReverted();
contract Marketplace is ReentrancyGuard{
struct Listing {
uint256 price;
address seller;
string tokenURI;
}
/* State Variables */
mapping(address => mapping(uint256 => Listing)) private s_listings;
//
mapping(address => uint256) private s_proceeds;
/* Modifiers */
modifier listed(address nftAddress, uint tokenId) {
Listing storage listing = s_listings[nftAddress][tokenId];
if (listing.price <= 0) revert Marketplace__isnotListed();
_;
}
modifier Not_listed(
address nftAddress,
address seller,
uint tokenId
) {
Listing storage list = s_listings[nftAddress][tokenId];
if (list.price > 0)
revert Marketplace__NftAlreadylisted(nftAddress, tokenId);
_;
}
modifier only_owner(address nftcontractAddress, uint tokenId) {
IERC721 nft = IERC721(nftcontractAddress);
address owner = nft.ownerOf(tokenId);
if (owner != msg.sender) revert Marketplace__Only_NftListed();
_;
}
/* Events */
event Itemlisted(
address indexed seller,
address indexed nftAddress,
uint indexed tokenId,
uint price,
string tokenURI
);
event Itembought(
address indexed nftcontractaddress,
address indexed soldto,
uint indexed tokenId,
uint256 price
);
event Itemcancelled(
address indexed seller,
address indexed nftcontractaddress,
uint256 tokenId
);
event ListingUpdated(
address indexed nftcontractaddress,
uint256 indexed tokenId,
uint256 indexed newprice
);
function ListNfts(
address NftcontractAddress,
uint tokenID,
uint Price
)
external
Not_listed(NftcontractAddress, msg.sender, tokenID)
only_owner(NftcontractAddress, tokenID)
{
if (Price == 0) revert Marketplace__PriceShouldbeGreaterThanZero();
}
function BuyNfts(
address nftcontractAddress,
uint256 tokenId
) external payable listed(nftcontractAddress, tokenId) nonReentrant {
Listing storage listing = s_listings[nftcontractAddress][tokenId];
if (listing.price > msg.value) revert Marketplace__PriceNotmet();
s_proceeds[listing.seller] = s_proceeds[listing.seller] + msg.value;
delete (s_listings[nftcontractAddress][tokenId]);
IERC721(nftcontractAddress).safeTransferFrom(
listing.seller,
msg.sender,
tokenId
);
emit Itembought(nftcontractAddress, msg.sender, tokenId, listing.price);
}
/* Cancel listing */
function Cancelisting(
address nftcontractaddress,
uint256 tokenId
)
external
only_owner(nftcontractaddress, tokenId)
listed(nftcontractaddress, tokenId)
{
delete (s_listings[nftcontractaddress][tokenId]);
emit Itemcancelled(msg.sender,nftcontractaddress,tokenId);
}
/* A good practice is to use push ver pull
Don't send the money to the user but let them withdraw the money
*/
/* update Listing */
function UpdateListing(address nftcontractaddress,uint256 tokenId,uint newlistingPrice) external only_owner(nftcontractaddress, tokenId) listed(nftcontractaddress, tokenId){
s_listings[nftcontractaddress][tokenId].price = newlistingPrice;
emit ListingUpdated(nftcontractaddress,tokenId,newlistingPrice);
}
/* Withdraw function to withdraw the money after selling the nft */
function withdrawProcess() external {
uint256 proceeds = s_proceeds[msg.sender];
if(proceeds <= 0) revert Marketplace__noProceeds();
s_proceeds[msg.sender] = 0;
(bool success,) = payable(msg.sender).call{value:proceeds}("");
if(!success) revert TransactionReverted();
}
/* Getter functions */
function Getlisting(address nftcontractaddress,uint tokenId) external view returns(Listing memory){
return s_listings[nftcontractaddress][tokenId];
}
function GetProceeds(address sender) external view returns(uint256){
return s_proceeds[sender];
}
}
Frontend codes App.js
import React, { useState } from 'react';import './App.css';
import Header from './components/header';
import MainSection from './components/mainContent';
import RecentlyListedSection from './RecentlyListedSection';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import RecentTransactionsSection from './RecentTransactions';
import SellNFTPage from './components/Sell-nft';
import abi from "./Constants/Marketplace.json"
import WithdrawSection from './components/WithdrawSection';
import { ApolloProvider } from '@apollo/client';
import { ethers } from 'ethers';
import { client } from './apollo';
function App() {
const [Contract,SetContract] = useState(null);
const [isConnected, setIsConnected] = useState(false);
const [address, setAddress] = useState('');
const [Signer,setSigner] = useState('');
const handleConnectDisconnect = async () => {
try {
if (window.ethereum) {
if (isConnected) {
await window.ethereum.request({ method: 'eth_requestAccounts' });
setIsConnected(false);
setAddress('');
SetContract(null);
} else {
const provider = new ethers.providers.Web3Provider(window.ethereum);
if (provider) {
window.ethereum.on("accountsChanged", () => {
window.location.reload();
});
window.ethereum.on("chainChanged", () => {
window.location.reload();
});
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner();
setSigner(signer);
const address = await signer.getAddress();
console.log("Address",address);
setAddress(address);
const marketplace = new ethers.Contract("0xA0Db67C5A14a2805B4157d8799449EA0B271188f", abi.abi, signer);
console.log("MARKETPLACE"+ marketplace.address);
SetContract(marketplace);
}
setIsConnected(true);
alert ("wallet Connected baby");
}
} else {
console.error('Metamask not installed');
}
} catch (error) {
console.error('Error connecting/disconnecting wallet:', error);
}
};
return (
<Route path="/" element={} />
<Route path="/Sell-nft" element={} />
{isConnected ? (
) : (
Recently Listed NFT
Connect your wallet to view recently listed NFTs
)}
);
}
export default App;
`
**We are dealing with the BuyNfts function the of the App.js **
The RecentlyListedSection Component
`import React from 'react';
import { useQuery, gql } from '@apollo/client';
import Card from './components/card';
const ACTIVE_ITEMS_QUERY = gql
query { activeitems(first: 10) { id tokenId nftAddress seller price tokenURI } }
;export default function RecentlyListedSection({Contract}) {
const { loading, error, data } = useQuery(ACTIVE_ITEMS_QUERY);
if (loading) return
Loading...
;if (error) return
Error: {error.message}
;return (
Recently Listed NFTs
{data.activeitems.map((item) => )}
);
}
`
Every thing is correctly being fetched from the Subgraph
The card Component used in the Above RecentlyListedSection component
The Transaction is successfully being created from the wallet but getting reverted everytime with the above mentinoed error im unable to debug the error pls help me out with this
Beta Was this translation helpful? Give feedback.
All reactions