How Does a Transaction Get Added to the Mempool?
A transaction is created by a user and then broadcast to the network. Nodes that receive the transaction first validate it against a set of rules (e.g. correct format, valid signature, sufficient funds).
If valid, the node adds it to its local mempool and relays it to its peers.