import { useOneInchSwap, useMoralis } from "react-moralis";
export default function Quote() {
const { isAuthenticated, logout, user } = useMoralis();
const { swap, data, isFetching, isLoading, error } = useOneInchSwap();
const options = {
chain: 'bsc', // The blockchain you want to use (eth/bsc/polygon)
fromTokenAddress: '0x0da6ed8b13214ff28e9ca979dd37439e8a88f6c4', // The token you want to swap
toTokenAddress: '0x6fd7c98458a943f469e1cf4ea85b173f5cd342f4', // The token you want to receive
amount: 1000,
fromAddress: '0x6217e65d864d77DEcbFF0CFeFA13A93f7C1dD064', // Your wallet address
slippage: 1,
}
return (
<div>
{error && <>{JSON.stringify(error)}</>}
<button onClick={()=> swap(options)}>Swap</button>
</div>
);
}
this is the code (a copy and paste was originally me testing one inch Quote but i get the same issue).
this is the error i’m getting.
Im fairly new to code in general but ive been getting interested in web3 and most of moralis is pretty much straight forward.
could someone guide me on how to get this swap to work correctly and not throw an error? the same thing happens when i try to get oneInchQuote but there is barely anything covering this in next.js/react format.
thank you