An Ethereum transaction refers to an action initiated by an externally-owned account, in other words an account managed by a human, not a contract. For example, if Bob sends Alice 1 ETH, Bob's account must be debited and Alice's must be credited. This state-changing action takes place within a transaction.
As usual, we need provider, private key and wallet to send a transaction.
Create a raw transaction object that is ready to be signed and sent.
A transaction object needs to be signed using the sender's private key. This proves that the transaction could only have come from the sender and was not sent fraudulently. We use wallet.signTransaction() to sign the transaction. The signedTx is the signed transaction in Recursive Length Prefix (RLP) encoded form.
Submit transaction to the network to be mined. The transaction must be signed, and be valid (i.e. the nonce is correct and the account has sufficient balance to pay for the transaction).
Eureka! We can reduce the code using wallet.sendTransaction(). This method helps us do a lot of work, such as populating all fields in a transaction, signing it and sending it to the network.