16 votes
Accepted

Reentrancy attack vector on tezos smart contracts?

Michelson (and higher level language like Liquidity on top of it) does not allow a smart contract to call another smart contract without commmitting its state/storage first. It makes reentrancy ...
lefessan's user avatar
  • 3,308
14 votes

Storage and parameter size limitations of smart contract?

1. Maximum parameter size per transaction The maximum number of bytes per transaction for a single transaction is limited several constants, in particular an upper size of for operations ...
arvidj's user avatar
  • 2,378
11 votes
Accepted

How can I write tests for my smart contracts?

There are several test frameworks coming for Tezos. Ours (Techelson) can be used both from Michelson and from Liquidity. It should be released soon. (I will update this answer when it is released)
lefessan's user avatar
  • 3,308
11 votes

Is there a way to generate a pseudo-random number inside a contract in liquidity?

If what you mean is a non-predictable source of randomness, no, there is none. Any information that could be used for that could either be predictable by a user, or tempered by a malicious baker. You ...
lefessan's user avatar
  • 3,308
10 votes
Accepted

Spending XTZ held in an implicit account from a smart contract

No, a contract can only spend its own funds.
Arthur B's user avatar
  • 4,599
10 votes
Accepted

Michelson Logic understanding problem

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 ...
FFF's user avatar
  • 3,250
10 votes

How to upgrade a smart contract?

Disclaimer: This is just an example for educational purposes, don't use it in production. Here is a fairly primitive upgradable design for a Liquidity smart contract: Proxy Contract Holds the state ...
Matej maht0rz Šima's user avatar
9 votes

Michelson Logic understanding problem

'*' 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 ...
Arthur B's user avatar
  • 4,599
9 votes

Benefits of Michelson

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 ...
lefessan's user avatar
  • 3,308
9 votes
Accepted

In the broker2.liq example, how is storage being returned by the call function?

This is an obsolete example. Contract calls do not return values anymore (it should not be in the repo). Have a look here instead (contract calls create operations that are executed sequentially after ...
jojo's user avatar
  • 332
9 votes
Accepted

How to upgrade a smart contract?

Because values of type lambda can be kept in storage or passed as parameters (either as lambda or as bytes to be UNPACKed), it is possible to write contracts which can upgrade themselves... This won't ...
Tom's user avatar
  • 2,506
9 votes

How are the originated contract addreses (KT1) computed?

In case someone needs precise calculations. Say, you have an operation group hash onvsLP3JFZia2mzZKWaFuFkWg2L5p3BDUhzh5Kr6CiDDN3rtQ1D and an origination index 0 which is increased for every ...
Michael Zaikin's user avatar
8 votes
Accepted

How can a string be coerced into tez using Liquidity?

So apparently, this feature is no longer available in Liquidity, and the docs are incorrect in this case. You can read a reply from Liquidity Lead Dev here.
Matej maht0rz Šima's user avatar
8 votes

Formal verification of Tezos smart contracts

So this is a huge question and I think there are many people more qualified than me, but I'll offer some initial guidance. In Software Foundations, a book on Coq, they talk about an implied language ...
Rob's user avatar
  • 576
8 votes
Accepted

Basic Syntax for iterating through List Element and processing each of them

You can use Loop.left (with and accumulator) but it is easier to use List.fold and tail recursive functions (those are encoded with loops). Here is a way to do it (you can call the entry point test ...
jojo's user avatar
  • 332
7 votes
Accepted

How are Smart Contracts saved for checking in future?

Am I understanding correctly, that I can store for example my rental contract as a Smart Contract and then it is made official with baking it with bakers? Like in all open blockchain systems, you ...
Amit Panghal's user avatar
7 votes

Is there a Tezos equivalent of ERC?

Martin Pospěch drafted an Tezos "ICO token" standard at https://gitlab.com/tips2/TIPs/blob/master/TIPS/tip-7.md Stephen Andrews is working on a tztoken at http://tztoken.teztech.io/ OcamlPro has a ...
Fred Yankowski's user avatar
7 votes
Accepted

How to extract the storage of a smart contract?

In the command line ./tezos-client get contract storage for KT1BRudFZEXLYANgmZTka1xCDN5nWTMWY7SZ You could also just call the RPC curl http://localhost:8732/chains/main/blocks/head/context/...
Arthur B's user avatar
  • 4,599
7 votes

How are the originated contract addreses (KT1) computed?

KT1 addresses are computed from origination nonce. The origination nonce is made of operation hash (the operation that creates the origination) and its index (the index starts from 0 and it gets ...
Tomáš Zemanovič's user avatar
7 votes
Accepted

Michelson: Parameter vs Storage

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 ...
Claude Barde's user avatar
6 votes
Accepted

How to specify the smart contract entry point in eztz call?

Michelson doesn't support multiple entry points right now. Liquidity uses unions (or type variables) to make up for this. A union has a Left and Right side, but can also be nested. Let's analyse the ...
Stephen Andrews's user avatar
6 votes
Accepted

Formal verification of Tezos smart contracts

If we agree that the purpose of analyses is to both prove properties and help users of smart contracts to understand them, I would say: Values: studying what values each element of the storage can ...
FFF's user avatar
  • 3,250
6 votes
Accepted

Benefits of Michelson

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 ...
Arthur B's user avatar
  • 4,599
6 votes
Accepted

What does it cost to make a contract through Tezos?

Contract origination incurs standard transaction fees (see here). One thing to note is that the storage cost is 0.001 tez per byte of data being stored on-chain (which includes the size of your ...
Stephen Andrews's user avatar
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 ...
cousinit's user avatar
  • 1,999
6 votes

Testing frameworks for tezos smart-contracts

Ad 1. I am not sure whether it is what you look for, but look at: https://smartpy.io/demo/ SmartPy offers different tools: Analytics: elements of the UI in SmartPy.io to analyse smart contracts and ...
Tomasz Waszczyk's user avatar
6 votes
Accepted

Batching Transactions FA2

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 ...
Eugene Mishura's user avatar
6 votes
Accepted

Can a smart contract know its own address?

Yes, Michelson provides the following instruction SELF_ADDRESS In SmartPy you can use sp.self_address
Rodrigo Quelhas's user avatar
5 votes
Accepted

How can I deploy a Michelson smart contract?

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> ...
lefessan's user avatar
  • 3,308
5 votes

How can I call a contract with a type parameter?

If you use the next branch of Liquidity, you can use : liquidity CONTRACT.liq --call-arg main '{ name = "test"; sig = "abcd" }' to print the argument to be used by tezos-client (where main is the ...
lefessan's user avatar
  • 3,308

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