Addresses and contracts
Addresses
Addresses in SmartPy are of type sp.address
. They are written as e.g. sp.address("tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU")
or sp.address("KT1AafHA1C1vk959wvHWBispY9Y2f3fxBUUo")
.
The address can carry an entrypoint name, for example: sp.address("KT1AafHA1C1vk959wvHWBispY9Y2f3fxBUUo%approve")
.
- sp.self_address() → sp.address
sp.self_address()
returns the address of the contract onto which it is used.
Contracts
For contract definition, see Overview#Contracts.
Contracts are represented with the type sp.contract
and are constructed with the sp.contract(type, address, entrypoint)
instruction.
- sp.contract(type, address) → sp.option[sp.contract[t]]
- sp.contract(type, address, entrypoint) → sp.option[sp.contract[t]]
Returns a
sp.Some(sp.contract[t])
if this contract exists,None
otherwise.If given, the
entrypoint
parameter must be named and be a constant string. For example,sp.contract(sp.nat, sp.address("KT1xxxx"), entrypoint="approve")
If the
entrypoint
parameter is absent, the entrypoint is taken from the address. If the address doesn't contain one, the entrypoint is"default"
.