Sending native tez to one or multiple address

The following question has been asked on Telegram:

Can u send tokens to other people’s wallets in smartpy for example keep a map of everyone that has purchased tokens the. send a percentage of tokens to them on another entry point?

You can use sp.send(<receiver>, <amount>) to send tokens to wallets but pay attention to the sending to multiple addresses flaw described here:

The best practice is to create a withdraw entrypoint so anyone can withdraw its tokens.
For example:

import smartpy as sp

def main():
    class MyContract(sp.Contract):
        def __init__(self, receivers):
            sp.cast(receivers, sp.big_map[sp.address, sp.mutez])
   = receivers

        def withdraw(self):
            amount =, error="NotInReceivers")
            sp.send(sp.sender, amount)

if "templates" not in __name__:
    def test():
        alice = sp.test_account("alice")
        sc = sp.test_scenario(main)
        receivers = sp.big_map({alice.address: sp.tez(5)})
        c1 = main.MyContract(receivers)
        sc += c1