How to transfer all sui

const tx = new TransactionBlock();
const [coin] = tx.splitCoins(tx.gas, [tx.pure(1000)]);

How to set gas to transfer all the balance in the wallet.
Alternatively, can we set gas as another wallet for payment?

We can use the RPC call unsafe_payAllSui to build the transaction bytes, and then sign and execute this transaction via the TS SDK.
I scaffolded a small ts-node project to test the whole flow in the following GitHub repo: https://github.com/John-Atha/sui-dev-forum/tree/main/transfer-all-sui