[Question]: How to confirm transfer of NFT's was successful?

After following the example of transferring NFT’s between addresses https://docs.moralis.io/moralis-dapp/sending-assets/transfer-nfts#transferring-erc1155-tokens-semi-fungible, how would someone make sure that the transfer was successful - is there some sort of a callback?

Look at the Resolve Transfer link in the link you posted; you can use wait().

But that is a promise, the operation will be stuck until it is successful or fails. I am more interested in a way to get an update with an event eg. transferSuccess.

You could use then so it doesn’t block. What is it you’re wanting to do with the transaction status?

Other than directly listening to the contract’s events this would be the main way of confirming a transaction.

I want to fulfill the order only once the transfer of an NFT is successful.

“Other than directly listening to the contract’s events this would be the main way of confirming a transaction.”
Can you give an example (contract events?)?

You can use the Transfer event. ERC 721 - OpenZeppelin Docs

I am quite new to ERC1155 and ERC721 (NFTs). Would it be possible that you to share a code snippet on how this should look like please?

So you create an instance of the contract you’re interacting with and set up an event listener on the Transfer event.

Adapting a few examples from Moralis docs, something like

const ethers = Moralis.web3Library;

const address = addresshere;
const abi = abihere;
const contract = new ethers.Contract(address, abi, provider);

contract.on("Transfer", (from, to, tokenId, event) => {

With the wait() method from the transaction/transfer, that’s checking the transaction is successful vs checking for an emitted event from the contract saying that the transfer occurred.

This would work for one contract. What would you suggest to do if there are multiple contracts and you dont know what is the address of them on the app startup?

Scenario: We are building an app for NFT’s and users can create NFTs through out platform or any other platform like OpenSea and use it in our store. As both NFT’s dont use the same contract we cannot effectivly listen to transfers like you mentioned.

there is a table in moralis server database named BscNFTTransfers for bsc that has the NFT transfers

that table will include the NFT transfers for all the user addresses and for what addresses are added to watch address

I dont see this table in my moralis dashboard. How do I access it? Is there a triggered event when a new address is added to watch address?

if you add an address to watch (or if you authenticated with an address), and if that address has NFT transfers, then that table will appear on your server

Does this also work for test networks? I assume no event is triggered when a new address is added to the list?

it works for test networks too

now sure what you mean with an event in that sentence

Strange, because I authenticated with an address that has NFT’s (if I understand correctly). Do you mean authenticate with an address using Metamask + Moralis while using react-moralis?

Something similar to this events https://docs.moralis.io/moralis-dapp/web3/web3#moralis.onweb3enabled.

// What I was thinking
const unsubscribe = Moralis.onAddressAdded((result) => {
// result would be contract address and abi of the contract for example

I mean authenticating, like using Moralis.authenticate()

try this, it works even if you don’t authenticate: https://docs.moralis.io/moralis-dapp/automatic-transaction-sync/historical-transactions#sync-and-watch-address

OK then yes, authenticate was used and the user does have nfts in ropsten network. Still dont see the table in moralis dashboard. Can you send a screenshot where I would see the table just in case I missed something.

Tried to use .wait(1) in my case. It does not work for us, as it stops the user from interacting with the APP, because we want to execute another function after the transaction is complete. Now using the contract transform works ok, but as we are allowing custom contracts in our app we do not posses the contract address and abi on app launch, so we would need to store contract address somewhere in our DB and then add in per demand. From what we talked about here, there seems to be a table already in moralis that would give me the address and hopefuly the abi as well - BscNFTTransfers. Having trouble finding it in the dashboard, or if there is a way to view the data through some sort of API would be great to test.

It would be even better if there is a callback which we could use like logs that would give us the necessary information.

Tried with https://docs.metamask.io/guide/ethereum-provider.html#message, no luck.