Hot answers tagged

4 votes
Accepted

How much storage do numbers take?

Integers have arbitrary precision, meaning that the only size limit is the gas_limit/storage_limit. $ ./tezos-codec describe ground.Z binary schema +-----------------+----------------------+----------...
user avatar
4 votes
Accepted

How can I avoid sp.TOption type when using sp.unpack()?

sp.unpack gives you an option (because Michelson gives an option when you call UNPACK) that you need to open. You can do it like this myBytes = sp.unpack(packedString, t = sp.TBytes).open_some(...
user avatar
  • 3,110
3 votes
Accepted

Is it possible to convert types in SmartPy?

Yes and no. There are no built-in convertors in Michelson. Some operations are doable nonetheless. For example, the string manipulations template demonstrates kind of extreme string manipulations in ...
user avatar
  • 3,110
2 votes
Accepted

Convert address to string in LIGO

You cannot convert an address to a string in Michelson. You could cheat by going through pack and inspecting the binary representation but it is unlikely something you would want to do.
user avatar
  • 3,110
2 votes
Accepted

Smartpy Michelson errors only on deployment (inconsistent_annotations, inconsistent_types)

That was fixed in granadanet by this merge request: https://gitlab.com/tezos/tezos/-/merge_requests/2815 You need to add self.add_flag("initial-cast") in the contract constructor to solve ...
user avatar
2 votes
Accepted

error Type sp.TInt / sp.TNat mismatch

Doing math on nats casts them to an int. The value needs to be casted back to a nat after the subtraction: self.data.shop_items[item_to_purchase.key].amount = sp.as_nat(self.data.shop_items[...
user avatar
  • 557
2 votes

What is a 'valid case' for bls12_381_fr?

Edo2net is not the default protocol in sandbox. You will need to provide the --protocol-hash arg: tezos-sandbox mini \ --size 1 \ --number-of-boot 2 \ --protocol-hash ...
user avatar
1 vote
Accepted

Receiving a "doesn't have a comparable type" error when returning a list from an on-chain view

You cannot compare lists in Tezos. However, you can use scenario.verify_equal.
user avatar
  • 3,110
1 vote
Accepted

Smartpy restrict entrypoint for originated addresses (KT1)

If you are specifically interested in the address of your caller there a simpler solution than the one proposed by @rodrigo-quelhas: sp.sender is an implicit account if and only if it is exactly sp....
user avatar
1 vote

Smartpy restrict entrypoint for originated addresses (KT1)

You can use: https://github.com/RomarQ/tezos-sc-utils Usage: Utils = sp.io.import_script_from_url("https://raw.githubusercontent.com/RomarQ/tezos-sc-utils/main/smartpy/utils.py"); # And ...
user avatar
1 vote
Accepted

value is invalid for type

As you can see in the explorer, the addLiquidity entrypoint accepts parameter of type (pair address (pair nat (pair nat timestamp)) But you pass (according to the original Dexter contract): (pair (...
user avatar
  • 2,252
1 vote

What is a 'valid case' for bls12_381_fr?

Can you give more information on your setup? Like which hash do you use? In the latest versions of BLS12-381 (used by Edo), it has been decided to pad the bytes for Fr elements. Some users requested ...
user avatar
1 vote
Accepted

What's the best way to convert from TMutez to TBytes?

You can use sp.pack on expressions of most regular types. It computes a serialized representation of your data.
user avatar
  • 3,110

Only top scored, non community-wiki answers of a minimum length are eligible