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 +-----------------+----------------------+----------...
Rodrigo Quelhas's 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(...
FFF's user avatar
  • 3,250
3 votes
Accepted

Why can I not subtract 2 local variables of type nat from each other and assign that result to another local variable in a view in smartpy?

Subtractions are implicitly taken as int due to the possibility of negative results. Therefore, the variable sub is of type int here. To resolve this, wrap sub as sp.as_nat(sub) on the dividend.
Anshu Jalan's user avatar
3 votes

Which hash function is used when converting an address from raw bytes?

It’s not hashed. You simply need to compute the base58 translation with the right prefix. Proof that it’s not hashed: this process is reversible.
FFF's user avatar
  • 3,250
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 ...
FFF's user avatar
  • 3,250
3 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.
FFF's user avatar
  • 3,250
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 ...
Rodrigo Quelhas's user avatar
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 ...
Rodrigo Quelhas's 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[...
JJJ's user avatar
  • 557
1 vote
Accepted

How can I assign values for a map-type in an archetype test script?

I think you should try with this: const tmdMap : Array<[ string, Bytes ]> = [[" ", tmdBytes]] In typescript, tuple and array have the same literal []. And here, it is a tuple into an ...
Guillaume Duhamel's user avatar
1 vote

How can I assign values for a map-type in an archetype test script?

The expected type reads "an array of pairs of string and bytes", and [" ", tmdBytes] is just a pair, hence I guess the following value should make ti: const tmdMap : Array<[ ...
Benoit Rognier's user avatar
1 vote
Accepted

How do you submit a pair when calling an entrypoint on a contract with Taquito?

Your code is correct, but you have to use the methodsObject property instead of methods if you want to use a JavaScript object as the parameter of the contract call. Alternatively, you can split the ...
Claude Barde's user avatar
1 vote
Accepted

Why does unpacking a record that has a key containing bounded data fail with `to_value sp.TBounded` in smartpy?

It is unsafe without a dynamic check. We need to determine what the most natural and/or appropriate decision is (very possibly: continue forbidding it).
FFF's user avatar
  • 3,250
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.
FFF's user avatar
  • 3,250
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....
Raphaël Cauderlier's 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 ...
Rodrigo Quelhas's 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 (...
Groxan's user avatar
  • 2,691
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 ...
Danny Willems's 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.
FFF's user avatar
  • 3,250

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