New answers tagged


sp.timestamp_from_utc_now() is a helper function that only works at compilation time, meaning that it produces a constant and doesn't update at runtime. timestamp_from_utc_now() should be moved to sp.utils soon, which should avoid confusion. You want to use the instruction which gives the current block timestamp.


There is no instruction in Michelson to interpret arbitrary bytes as numbers. The simplest way to achieve what you want is to use a constant table (as a Michelson map) from bytes of length 1 to their values (between 0 and 255). Then, depending on how uniform you need your distribution to be, you can either take a modulo on the value of the last byte of your ...


The reason for that error is the invalid address you are using for originating the contract. Below is an example of how to update the initial storage from the origination page.


You can do this by simply adding a time check. import smartpy as sp class TimedCall(sp.Contract): def __init__(self): self.init( time_limit = sp.timestamp_from_utc_now().add_days(365), val = sp.nat(5) ) @sp.entry_point def timed_method(self, param): sp.set_type(param, sp.TNat) ...


For the example provided by Rafael, you can do the following in SmartPy. import smartpy as sp class Creator(sp.Contract): def __init__(self): self.init(address = sp.none) @sp.entry_point def generate_address(self): # Generate the address but don't append the operation contract = sp.create_contract_operation(sp....


We've implemented a version of this for Murmuration DAO, and I think it's a pretty valid and cool idea. Our code is here: You can see an example in that shows how you can read data out of the token snapshots.

Top 50 recent answers are included