Hot answers tagged

10 votes
Accepted

Ethereum/Solidity dev here, looking to migrate some Solidity contracts onto Tezos. Was hoping to have some light shed on a few questions

In response to question 4: Reuse and modularity We discuss reuse and modularity, of which inheritance is one of many mechanisms: Michelson has no mechanism for code reuse, except for calling existing ...
user avatar
  • 2,348
7 votes
Accepted

How to retrieve data from smart-contract using javascript?

As of the current Babylon protocol and the upcoming Carthage, the RPC only provides you the ability to retrieve the value for a known key that you provide to the RPC. But even in this scenario you ...
user avatar
  • 1,979
6 votes

Ethereum/Solidity dev here, looking to migrate some Solidity contracts onto Tezos. Was hoping to have some light shed on a few questions

Here is a complement to Arvid's answer regarding Archetype: Reuse and modularity Indeed Archetype's extensions are reusable codes to add features to a contract. For example, using the 'transferable' ...
user avatar
5 votes

Ethereum/Solidity dev here, looking to migrate some Solidity contracts onto Tezos. Was hoping to have some light shed on a few questions

Do Archetype/Ligo provide everything that Michelson can currently do, or are there limitations with either? I think if something is possible in Michelson and not in Ligo, it is probably a bug worth ...
user avatar
5 votes
Accepted

Why does smartpy use sp.for/sp.while instead of the default loops provided by python?

Your understanding is quite correct. SmartPy is a Python library, not a Python-inspired language so we use Python everywhere and overload Python's constructions. This approach is called meta-...
user avatar
  • 3,185
4 votes
Accepted

Where are the API docs for SmartPy?

I believe what you are looking for is this: sp.send(sp.address("tz1"), sp.tez(420)) I can't find much documentation for sp.send but I have seen many SmartPy examples with sp.send and sp.amount
user avatar
4 votes

Ethereum/Solidity dev here, looking to migrate some Solidity contracts onto Tezos. Was hoping to have some light shed on a few questions

With respect to question 3, following @ezy remark, SmartPy has some inlining capabilities including with new opcodes as shown in the Inline Michelson template (of the new version, currently https://...
user avatar
  • 3,185
4 votes
Accepted

How to create a mapping in smartpy ? Do we need to define the datatypes of the key & value like in solidity?

No, you do not need to specify the type of the keys of values. Instead, without needing the declare the map, you simply use it and the types are inferred. To construct a mapping called m, use m = sp....
user avatar
  • 2,348
4 votes

How to retrieve data from smart-contract using javascript?

We maintain an index of all historic bigmap data at TzStats. To fetch all current keys and values in a bigmap call https://api.tzstats.com/explorer/bigmap/:id/values If your bigmap is very large you ...
user avatar
4 votes
Accepted

Taquito default entrypoint not found

The contract you point to takes a single parameter of type address. Thus, as you write, it only has the default entrypoint. In taquito, the main entry point can be call through contract.methods.main. ...
user avatar
  • 2,348
4 votes

Is it possible to use natural logarithmic in your smartpy code?

You have to do it manually... Here's one approach for compute log(x) assuming you are representing x as a fraction find integer m through binary search such that 2^m <= x < 2^(m+1) (m may be ...
user avatar
  • 4,409
4 votes

Can we have a Time clocked transaction in Tezos?

You have access to a "time" with sp.now so you can compute conditions, etc. There is nothing like "send in 30 minutes". You need external input to trigger operations Tezos. You can ...
user avatar
  • 3,185
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,185
4 votes
Accepted

Best Language to Use with Tezos

First of all, Fi is no longer updated and Liquidity no longer supports Tezos, which leaves Ligo, SmartPy, Michelson and Morley. To this list, I would also add Archetype. All of these languages can be ...
user avatar
  • 2,348
4 votes
Accepted

How to store and load custom FA2 NFT metadata?

Your code above has some issues that I will describe below. Also, you are confusing off-chain metadata with on-chain metadata, tzip16 and tzip21 allow those structures because they were designed to be ...
user avatar
4 votes
Accepted

Using sp.create_contract to generate pseudorandom numbers on-chain

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....
user avatar
4 votes
Accepted

Limiting the time (time/date based) that a contract method can be called

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()....
user avatar
3 votes
Accepted

Type error, (sp.TRecord(addr = sp.TAddress)) is not (sp.TUnit) in smartPy

Contratry to my initial answer, as FFF pointed out, the problem is that an entrypoint in SmartPy cannot return a value to the calling contract, nor in the underlying Michelson language. The typical ...
user avatar
  • 2,348
3 votes

How do I get a list of a Tezos smart contract KT1 address entrypoints and its parameters?

The SmartPy contract explorer allows you to see all the entry point of a given contract in any of the networks (main and test) along with autogenerated forms to interact with all those entrypoints. ...
user avatar
  • 6,006
3 votes

How do I get a list of a Tezos smart contract KT1 address entrypoints and its parameters?

To find all the entrypoints and their types using tezos-client you can use the following command: tezos-client get contract entrypoints for <src> To check a specific entrypoint you can also ...
user avatar
3 votes
Accepted

How to deploy a smart contract influenced by UI inputs using ConseilJS and SmartPy generated Michelson?

I cannot answer all your questions but at least, I can say that, in SmartPy.io, the storage sent to ConseilJS is the content of the tab "Storage" (in either Michelson or Micheline formats) and the ...
user avatar
  • 3,185
3 votes

set a ui to allow to nodes interact via smartpy contract

Give ConseilJS a try. Here’s a set of tutorials: https://medium.com/the-cryptonomic-aperiodical/blockchain-development-with-tezos-698aa930e50f If you just want straight code samples, check this out:...
user avatar
3 votes
Accepted

How to delegate the balance of a smart contract?

1) How does an originated KT address delegate to a baker? During the origination of a smart contract, an initial delegate can be set. After origination, only the smart contract itself can change its ...
user avatar
3 votes
Accepted

How to get a contract storage data from another contract in smartPy?

There are several example templates, such as FA2 (real world token contracts) and Collatz (small demo and test template). https://www.smartpy.io/dev/?template=FA2.py https://www.smartpy.io/dev/?...
user avatar
  • 3,185
3 votes

Calling view of Fa1.2 contract

I am unsure how to interpret params.target, so i modified getBalance by adding an entrypoint and address @sp.entry_point def getBalance(self, params): sp.transfer(sp.as_nat(self.data....
user avatar
  • 495
3 votes

Is it possible to use natural logarithmic in your smartpy code?

I have a contract for binary log that uses few multiplications and can be adjusted for any fixed point precision: https://github.com/Sophia-Gold/michelson/blob/master/log2fix.tz. I don't think it can ...
user avatar
3 votes

What guarantees do we have when verifying the sender's identity (in SmartPy)?

You are guaranteed (if the crypto behind Tezos is not broken) that the person who signed the transaction knew the corresponding private key (in case of an implicit account) so, for all reasonable ...
user avatar
  • 3,185
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,185
3 votes
Accepted

How do you set the time of a transfer when testing contracts with SmartPy?

Use now = sp.timestamp(10). We used to allow now = 10 but this is not well typed. (also, obviously, the exception message should be better)
user avatar
  • 3,185
3 votes
Accepted

How to compare timestamps in tezos smartpy?

To compare timestamps, you can use < or <=. The problem in your code is that sp.timestamp(params.req.deadline) is wrongly built. sp.timestamp(...) is for constants. Simply replace that by sp.now&...
user avatar
  • 3,185

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