I have got through this tutorial up to the point making a book purchase nears the end, everything works.
The purchase modal pops up, I put in the Delivery address and click purchase, metamask opens and I click confirm and it seems to execute fine. In the video, he goes to the Moralis database and there is a table called Transactions, where the new purchase details appear, together with the book title and delivery address put in by the user. There is also a table called PolygonTransactions (since weβre using Matic on the Mumbai network).
In my case, the Transactions table (document?) does not appear, but the transaction is recorded in the Polygon Transactions table, with the correct idβs etc, but not with the book title and delivery address.
Any insights, grateful!
from discord:
function Purchase({book}) {
const [isModalVisible, setIsModalVisible] = useState(false);
const [delivery, setDelivery] = useState("");
const {Moralis, account, chainId} = useMoralis();
const handleOk = async () => {
// Get The Price of MATIC
const options = {
address: "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0",
chain: "eth"
};
const price = await Moralis.Web3API.token.getTokenPrice(options);
const priceMatic = book.price / price.usdPrice;
// Send Matic to book store owenr address
const options1 = {
type: "native",
amount: Moralis.Units.ETH(priceMatic),
receiver: "xxxxx"
}
let result = await Moralis.transfer(options1)
//Save Transaction Details to DB
const Transaction = Moralis.Object.extend("Transaction");
const transaction = new Transaction();
transaction.set("Customer", account);
transaction.set("Delivery", delivery);
transaction.set("Product", book.name);
transaction.save()
setIsModalVisible(false);
If this tutorial needs to increase the amount of watch hours, top4smm platform can be used as a promotional tool.