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 "library" contracts directly.
As far as I understand, Archetype includes no user-extendable
mechanisms for code reuse. Actions (akin to methods) ...
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' extension on a role adds to the contract the necessary actions (ie entry points) to transfer the role to another address.
For example, invoking the '...
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://SmartPy.io/dev).
It's accessible here: https://smartpy.io/dev/index.html?template=inlineMichelson.py.
import smartpy_michelson as mi
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 reporting, the Ligo devs usually quickly answer these kinds of issues.
Archetype however is purposely not Turing complete and in particular you cannot do ...
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.map(...). To access element k, write m[k].
For an example, refer to the FA1.2 template in the SmartPy online IDE.
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 need to provide not the readable key you stored, but a hash of that key as that is how it is represented internally. This answer describes how to call the RPC
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. So your call should be:
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 negative)
let m' = m + (1 if |x/2^(m+1)-1| < |x/2^m-1| else 0) (the closests of m or m+1)
let x' = x / 2^m', note that |x'-1| < 1/3 and log(x) = log(2^m' x'...
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-programming and is extremely important for bigger templates.
Control operators such as if, for, while cannot be overloaded in Python. So we have our own pure-python ones ...
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 compute with timestamps and forbid some actions for a period.
Deducting the balance to the sender means sending the amount to the contract.
Recipient will not ...
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 solution is based on continuation-passing style. The idea is that the calling contract also provides a call back, in the form of an contract. The parameter type ...
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.
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 use:
tezos-client get contract entrypoint type of <entrypoint> for <src>
You can find more about available commands in the official documentation.
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 code is similarly the content of one of the corresponding tabs.
Depending on the form you're using, you need to set Michelson or Micheline (the latter is quite ...
Give ConseilJS a try.
Here’s a set of tutorials:
If you just want straight code samples, check this out:
There are several example templates, such as FA2 (real world token contracts) and Collatz (small demo and test template).
For your example, the error message is clearly unhelping but you should define an entry point to receive the value in a contract.
You cannot use ...
I am unsure how to interpret params.target, so i modified getBalance by adding an entrypoint and address
def getBalance(self, params):
sp.transfer(sp.as_nat(self.data.balances[params.arg.owner].balance), sp.tez(0), sp.contract(sp.TNat, params.contractAddress , entry_point = "viewBalance").open_some())
Here is my view ...
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 be written in SmartPy because last I checked it lacks shifts. Depending on your needs you could use this with change of base or Arthur's method.
There is no way of iterating over all values in a big_map in the language to which SmartPy compiles (Michelson). So it doesn't surprise me that this doesn't work in SmartPy either. Indeed, according the SmartPy documentation:
e.values(): Returns the list of values of a map, sorted by keys.
Here, I presume that map refers exclusively to normal, "simple" ...
The first and main issue you have is that setup is a method of class sp.Contract that is broken when you redefine it in your contract.
This should not be the case and must be fixed on the SmartPy side.
So rename setup anything else and it will work.
A second issue, entry points take two parameters self and params, not just one.
A third issue, contract=...
We maintain an index of all historic bigmap data at TzStats. To fetch all current keys and values in a bigmap call
If your bigmap is very large you can page through the result with limit and offset parameters (default is 100 entries, max is 500). See our bigmap docu for more details and examples.
If you ...
The SmartPy manual (https://smartpy.io/demo/reference.html#_cryptography) says that:
sp.check_signature(k, s, b): Determine whether the signature s (a sp.TSignature value) has been produced by signing b (a sp.TBytes value) with the private key corresponding to k (a sp.TKey public key value).
It simply computes a boolean after checking that the data in 'b' ...
Looking at https://smartpy.io/dev/reference.html#_chain_id, you can see that you can basically currently do three things in SmartPy:
Define chain_id constants with things like sp.chain_id_cst("0x9caecab9").
Get the current chain_id for your chain sp.chain_id.
Verify that they match with sp.verify_equal.
There are no helper lists of chain_id constants that ...
When you send an operation, it first goes to the mempool, and only then bakers include it into the block. So there is some delay...
I highly recommend you use tzkt.io explorer, because it also checks operations in the mempool so you will see them right after sending or if it's stuck in the mempool.