New answers tagged

1

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 sp.now which gives the current block timestamp.


1

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 ...


1

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.


3

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) ...


2

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....


1

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: https://github.com/Hover-Labs/murmuration/blob/main/smart_contracts/token.py You can see an example in dao.py that shows how you can read data out of the token snapshots.


Top 50 recent answers are included