Hello,
I always get the the right error message (The conversion did not succeed) if I click the get quote button. But how I get the necessary quote as we see in the Video. I think I took exactly the same code mentioned in the video but it does not work
//Submission of the quote request
const fromDecimals = $selectedToken.dataset.decimals;
const fromTokenAddress = $selectedToken.dataset.address;
const [toTokenAddress, toDecimals] = document.querySelector('[name=to-token]').value.split('-');
try {
const quote = await Moralis.Plugins.oneInch.quote({
chain: 'polygon', // The blockchain you want to use (eth/bsc/polygon)
fromTokenAddress, // The token you want to swap
toTokenAddress, // The token you want to receive
amount: Moralis.Units.Token(fromAmount, fromDecimals).toString(),
});
const toAmount = tokenValue(quote.toTokenAmount, toDecimals);
document.querySelector('.js-quote-container').innerHTML = `
<p>
${fromAmount} ${quote.fromToken.symbol} = ${toAmount} ${quote.toToken.symbol}
</p>
<p>
Gas fee: ${quote.estimadGas}
</p>
`;
} catch(e) {
document.querySelector('.js-quote-container').innerHTML = `
<p class="error">The conversion did not succeed.</p>
`;
}
}