In order to ensure that the first transaction has been processed and the wallet has received the TON coins before attempting to send the jetton, you should wait for a confirmation of the first transaction.
The amount of time it takes for a transaction to be confirmed can vary depending on factors such as network congestion and transaction fees. Generally, you should wait for at least one confirmation, which typically takes around 1-2 minutes on the TON network.
When sending the TON coins programmatically, you can include a callback or use a library that waits for the transaction to be confirmed before proceeding with the second transaction. This will ensure that the second transaction is only sent once the wallet has received the TON coins.
It's also important to note that API rate limits may apply when sending transactions programmatically. You should check the documentation for the API you're using to determine the appropriate rate limit and adjust your code accordingly to avoid being banned. For example, using the "https://testnet.toncenter.com/api/v2/jsonRPC", you could send a transaction about once every 10 seconds without exceeding the API rate limit.