Add the @stacks/transactions and @stacks/network packages to your project using your preferred package manager.
Build the transaction for a STX transfer
To set up a STX token transfer transaction, use the makeSTXTokenTransfer function. This function requires a senderKey, recipient address, amount to be sent (denominated in uSTX), a network instance, and an anchorMode.
The senderKey is the private key of the sender's wallet.
There are a few optional fields for a STX transfer transaction, including memo, nonce, and fee:
You can use memo to add a message as part of the transaction. If you don't want the builder to fetch the nonce and fee from a Stacks node, you can manually set these fields.
Broadcast the transaction
Once you've constructed a valid transaction, you can broadcast it to the network using the broadcastTransaction function.
Upon success, this will return a StacksTransaction object that contains information about the transaction, including the txid.