I'm learning SmartPy and I'm trying to make a simple escrow contract. I read that contract.balance can be used to access the balance of a contract. In that case, how would I go about receiving XTZ to the contract's balance and sending it from the contract's balance?

1 Answer 1


To receive XTZ, you simply avoid refusing it: you need an entry_point that will simply accept XTZ by literally not sending an exception.

You can see the number of XTZ sent by looking at sp.amount.

To send XTZ, you need to use either sp.send for simple XTZ transfers or sp.transfer for general transfers.

See https://smartpy.io/reference.html#_contracts_and_addresses for the details.

  • What if many people send XTZ at the same time? How would I distinguish between the different amounts that people send?
    – flash76
    Dec 5, 2020 at 3:08
  • With any transaction to any of your entry points, you have parameters so you may require your users to send this information and you also have access to the sender with sp.sender.
    – FFF
    Dec 5, 2020 at 11:30
  • This is my deposit function: pastebin.com/gvZcp8jX. Does calling an entry point initiate a transaction?
    – flash76
    Dec 6, 2020 at 13:20
  • Yes. Calling an entry point is synonymous to sending a transaction to the contract.
    – FFF
    Dec 6, 2020 at 18:05
  • Thanks! So that means the amount of XTZ sent when calling an entry point can be customised?
    – flash76
    Dec 7, 2020 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.