If you're concerned about these kinds of spam transactions in an open blockchain, you need to use transaction fees as a mechanism to prevent spam. See the 'Native blockchain currency' parameters for ways to control the minimum fees required for a transaction to be relayed.