const balanceBefore = await getBalance(provider, tokenAddress, recipientAddress);
const txHash = await serverClient.transfer({ params: { ... } });
// Wait for the tx to be included in a block
await provider.waitForTransaction(txHash);
const balanceAfter = await getBalance(provider, tokenAddress, recipientAddress);
if (balanceAfter <= balanceBefore) {
throw new Error("Balance did not increase — transfer may have failed");
}
async function getBalance(provider, token, account) {
const result = await provider.callContract({
contractAddress: token,
entrypoint: "balance_of",
calldata: [account],
});
return BigInt(result[0]) + (BigInt(result[1]) << 128n);
}