11

The BigMap container is a special map (dictionary) whose storage is only read or written per key on demand. The motivation to have such a container is the following. Suppose that you have a contract containing lots of more or less independent data and you don't want to read / write all of the data at once but only a small part of it. Think of crypto-kitties,...


10

We can simulate the program in the following way. We write the stack between [...] and then the operations. We use three different operations push <int>, * and +. push puts an integer at the top of the stack, * pops two elements from the stack and pushes their product, and + pops two elements from the stack and pushes their sum. Your program starts ...


9

The main benefits of Michelson are the guarrantees that it gives on the execution of a smart contract : static typing catches many errors, and the semantics is clearly defined, so you have no surprise at execution. Yes, Michelson is a low-level language, you should aim at a higher-level language, like Liquidity (http://www.liquidity-lang.org/), that ...


9

'*' and '+', in this context, are not the infix operators you are used to. Imagine reading left to right and stacking up the numbers as you go. When you encounter + or * you replace the top two elements of the stack with the result of the operation.


9

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) ...


7

Let's find out. We start by running a sandbox node. We'll originate two contracts, one for maps, the other for bigmap. parameter (pair address nat); storage (big_map address nat); code { UNPAIR; UNPAIR; DIP { SOME }; UPDATE; NIL operation; PAIR; }; (this is the big_map version, the map version is the same with the type "bigmap" ...


6

DIP lets you operate on the stack one level below the top element. You can think of DIP as taking the top element, putting it on an auxiliary stack, performing some operations on the remaining stack, and then placing the element from the auxiliary stack back on top.


6

Micheline is the concrete syntax of Michelson. https://tezos.gitlab.io/whitedoc/michelson.html The concrete syntax means that it is the part of language in which Michelson is actually written and doesn't deal with semantics (evaluation, etc.).


6

Michelson lets you write concise contracts using high level primitives (like maps, sets) without departing from Tezos' native VM. That means you don't have to trust your contract to the output of a compiler. What you see is what is executed on chain. In addition, it is purely functional and statically typed, attributes which generally help developers avoid ...


6

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 '...


6

The difference is very simple :) The parameter is made of data that are sent to the contract with a transaction while the storage holds the state of the contract (i.e all the data that the contract saves to be reused later). It is true that both the storage and the parameter can be seen as inputs because they are fed to the contract at the beginning of its ...


6

There are eight types of costs: 1 Reading cost 2 Deserialization cost 3 Parsing cost 4 Type comparison cost 5 Interpreter cost 6 Unparsing cost 7 Serialization cost 8 Writng cost More documentation is available in this document https://gitlab.com/morley-framework/morley/-/blob/e2d3cf9197804a2cfa92715e1a4d640fe5b87af7/docs/...


5

There is an assumption that all Tezos nodes are synchronized, otherwise the consensus with 1-minute slots would not work. Of course, some delay is ok, but more than a few seconds might prevent a baker from baking. NOW is the time at which the block, containing the transaction, should be baked. So, the baker knows the last block time, he knows his slot, so ...


5

Read the documentation of: tezos-client -A mainnet-node.tzscan.io originate contract It says: tezos-client originate contract <new> for <mgr> transferring <qty> from <src> running <prg> where <prg> is a file containing your Michelson source.


5

This feature is not totally implemented in Babylon (http://tezos.gitlab.io/protocols/006_carthage.html#comparable-pairs-in-sets-and-maps), but it will arrive with Cartage in a few days if the vote is stakeholders vote for it. You can follow the election of Carthage at this address : https://tzstats.com/election/16


5

key_hash is blake2b hash of a public key, in the base58 encoded form it can start only with tz, but address is more general, it can also hold KT accounts; There are no instructions for that, probably because it's a rare and arguable case; EDIT: as pointed out by Raphaƫl, you can convert key_hash to contract and then to address using IMPLICIT_ACCOUNT ; ...


5

Why can I convert between address and contract. But not between address and key_hash? There is the (IMPLICIT_ACCOUNT) instruction to go from key_hash to address. For the other direction, there was (a feature request) but it was closed because no use case has been presented to motivate it.


5

Other transactions will fail automatically and the contract will revert to the previous storage state automatically. By design, any invocation of the Tezos smart contract works as an atomic transaction. An entry point gets the current contract storage value and returns an updated storage value. If the operation fails for any reason, a new storage value is ...


4

ConseilJS beta 0.2.7 has experimental functionality that allows that sort of GUI deployment. Docs here, code here.


4

I have implemented the PACK and UNPACK in tezbridge-crypto project. You can checkout the source code here: codec.js#L426 Here are some test cases: index.js#L35 In short words, there are several mappings(codec.js#L166, codec.js#L288) between the Michline value and the binary representation. The conversion is just a one way walk though the data, and each ...


4

Contracts don't currently return any data. You should use callbacks for on-chain data transmission, or use an off-chain oracle. On chain, you use the TRANSFER_TOKENS; instruction to send from contract a to contract b. Contract b would then send data back via another TRANSFER_TOKEN; call. You should update the storage of contract a to acknowledge that a call ...


4

Annotations are never necessary, they only add new type constraints. Their purpose is twofold: documenting what corresponds to what in a Michelson smart contract (and I personally feel that this is really useful and should even be improved); adding constraints to ensure that these annotations are coherent with one another (it's also quite useful and these ...


4

No. The only way to do that is for the contract you call to explicitely send you a callback, continuation passing style.


4

It does need to be exactly an int. Something close to what you describe is probably how multiple entry points for contracts would be supported, though there would be an additional tag to indicate the position of the type in the disjunction. The technique is known as "sum-type polymorphism".


4

Turns out this supposed to be passed like this: '(Pair "tz1PKKC9NTsxxfwYpg1bVAY5k5AKuPYe9gpg" "KT1GE2AZhazRxGsAjRVkQccHcB2pvANXQWd7")'


4

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 ...


4

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 ... @sp.entry_point ...


4

You express the Unit in JavaScript by calling the method like this contract_instance.method([["unit"]]);


3

DIP applies the sequence of instruction that follows it between braces to the stack below the top element. Similarly, DIIP will apply the sequence to the stack without its two topmost element etc. You can also think that you have two stacks, the fictitious one being used to hold the topmost elements of the real one until the sequence is over, then those ...


3

You may want to follow this project: https://medium.com/tezos/introducing-ligo-a-new-smart-contract-language-for-tezos-233fa17f21c7 Not many answers for now, syntax apart, it looks like Liquidity or Fi.


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