11
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 ...
7
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' ...
6
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 ...
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 ...
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-...
5
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....
5
votes
Accepted
Error in Inter contract call from a contract to quipuswap dex2 contracts swap entrypoint
The contract giving you this error is KT1F8Ei743RE8wH4BEdpq2uuqoHgb6jkfuJe, which is a FA1.2. The error code is 75.
Running Factori's analyze command,
factori analyze kt1 --network ghostnet ...
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
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://...
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....
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. ...
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 ...
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 ...
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(...
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 ...
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 ...
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()....
4
votes
Accepted
Using dummy address for randomization
The address of these dummy contracts depends directly on the hash of the transaction, so it can be easily manipulated by the one creating it. So if the transactions are created by users, they can ...
3
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 ...
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 ...
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.
...
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 ...
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 ...
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:...
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 ...
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/?...
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....
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
smartpy × 233smart-contracts × 131
michelson × 19
nft × 18
fa2 × 13
error × 12
taquito × 11
ligo × 10
types × 10
storage × 9
testing × 9
contract × 7
string × 6
node × 5
origination × 5
python × 5
rpc × 4
liquidity × 4
transfer × 4
javascript × 4
blockchain × 4
bigmap × 4
dapps × 4
encoding × 4
tzip16 × 4