I have a Token-based game in Solana. Users usually transfer tokens from one wallet to another all the time.
I have managed to make this process work very well but everytime my code reach this step:
it often takes a LOT OF TIME to finish
Sometimes…it even gets longer than 60 seconds, causing a timeout.
Watching the solana website, it says it does about 1.7k transactions per seconds…sometimes even more sometimes less. And i can see they usually dont get more than 2k transactions per second. Meaning my transactions should end in 2 seconds…5 seconds tops.
So why this command
Hi @torugor, it might be that you need to set the commitment mode of your connection so that it doesn’t wait for transactions to finalize, just for them to be confirmed by one node in the chain.
It’s technically possible for a block that has only been “confirmed” to become reverted later, as if it never happened, but it’s unlikely, so waiting for the transaction to be confirmed by one node is probably enough for you to register the transaction as a success to your users.
When creating a new Solana connection with the web3.js API try doing this:
const connection = new Connection(rpcServerUrl, 'confirmed');
This tells the API to only wait for the transaction to get confirmed by one node before returning success. If ‘confirmed’ is not specified, it will default to waiting for a supermajority of the blockchain nodes to all validate the the transaction and finalize it, which isn’t necessary unless you require absolute certainty that the transaction has been irreversibly committed to the chain.