Questions tagged [smart-contracts]
The smart-contracts tag has no usage guidance.
407
questions
15
votes
3
answers
647
views
How to upgrade a smart contract?
I'm building a smart contract that is sort of an index of signed documents (pointing to ipfs for the actual docs).
What if I want to add some functionality to my app down the road and need to upgrade ...
14
votes
2
answers
400
views
Formal verification of Tezos smart contracts
What are the analyses of Tezos smart contracts that could benefit dapps writers the most?
Just to be clear, by “analysis” here I mean “static program analysis”. See for instance here.
Basically the ...
13
votes
3
answers
203
views
How can I write tests for my smart contracts?
I like doing TDD and would like to build up a test suite around my contract code. I have been looking at both ReasonML and Liquidity but neither seems to have a great testing story yet. Does it make ...
11
votes
2
answers
245
views
Reentrancy attack vector on tezos smart contracts?
I heard that Michelson helps with avoiding re-entrancy bug. Why is that? Is there some feature in the language that prevent it?
10
votes
1
answer
238
views
Is there a way to generate a pseudo-random number inside a contract in liquidity?
If I require a pseudo-random number (PRN) in the internal working of a function in liquidity, is there a way to do it? Is there one in Michelson?
I already know about the way to send a PRN through RPC ...
9
votes
1
answer
1k
views
Storage and parameter size limitations of smart contract?
Got a few questions regarding storage limitations of smart contract.
What is the maximum number of bytes of data that I can send for a single transaction?
Is there a size limit to the storage of a ...
9
votes
3
answers
212
views
Is there a Tezos equivalent of ERC?
I’d like to read / contribute to existing contract standards on Tezos, is there an open source movement like ERC?
9
votes
1
answer
144
views
How can a string be coerced into tez using Liquidity?
Documentation states the following:
tez : an unbounded positive float of Tezzies, written either with a tz suffix (1.00tz, etc.) or as a string with type coercion ("1.00" : tez).
Yet the following ...
8
votes
3
answers
461
views
How can I deploy a Michelson smart contract?
I'm wondering how to deploy a Michelson smart contract on Tezos.
Maybe I'm just bad at googling, but all the examples I can find are using liquidity-cli. I'm not using liquidity for this contract, ...
8
votes
1
answer
49
views
Spending XTZ held in an implicit account from a smart contract
Is it possible for code in a KT1 smart contract to spend from a tz1 adress ?
8
votes
1
answer
234
views
How to specify the smart contract entry point in eztz call?
I want to call a smart contract with eztz:
eztz.contract.send(contract,from, keys, amoun, params, gasLimit,storageLimit)
How to specify the entry point, my smart contract has multiple entry points :
...
8
votes
1
answer
140
views
What exactly are smart contracts?
I'm new to Tezos, and in fact to Bitcoin in general. I have been reading up on it a good bit, though, and I ran across an article on cryptobriefing which states that Tezos, like Ethereum, uses smart ...
8
votes
1
answer
129
views
Why does a transaction contain a storage dump?
I have looked at a few transactions with some smart contracts and I have found that they store a dump of contract's storage.
For instance:
https://mainnet.tezrpc.me/chains/main/blocks/246869/...
7
votes
1
answer
86
views
Basic Syntax for iterating through List Element and processing each of them
I am creating two lists in liquidity and trying to process on them as follow:
type two_element = {
name: string;
value : nat;
}
type list1 = two_element list;
type list2 = two_element list;
...
6
votes
2
answers
108
views
Michelson Logic understanding problem
If i got it right, Michelson is a stack based language.
I've read the following example about stack based languages:
3 4 5 * + = 23
how does Michelson know, that it has to mutiplicate 4 * 5 ...
6
votes
1
answer
281
views
What does it cost to make a contract through Tezos?
I have seen clear structure and numbers on how baking, delegating and double endorsing etc. affect to the users amount of Tezos, but is there any cost on making a contract (in other words creating ...
6
votes
1
answer
153
views
Is there a way to call a function inside a contract from a function in another contract?
I want to have two different contracts that have functions that should interact with each other. Is there a way to pass/return values through function call between contracts?
6
votes
2
answers
59
views
How to remain auditable while using a database or index for a smart contract application?
As I am setting out to build my first proper smart contract backed application, I need to set up a database & index for the website for fast query times etc. How can I set this up in a way so that ...
6
votes
1
answer
62
views
Regarding annotations in michelson
Michelson has different type of annotations. I am curious about what is the main purpose of annotations and where should one use annotations vs where on shouldn't?
Is there a michelson pattern where ...
5
votes
3
answers
1k
views
Testing frameworks for tezos smart-contracts
I did few smart contracts with Ligo, but now looking for more productionize setup.
Is there a test framework one can use for Tezos? I'm looking for something like waffle + mocha in Ethereum, or ...
5
votes
2
answers
271
views
How to call a smart contract method with params with eztz?
Does Eztz have some method for calling smart contract methods with parameters?
For example if my contract has a method
let%entry createFile ((fileHash : string),(manager:key_hash)) storage
How can ...
5
votes
1
answer
70
views
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?
If I got the first part right, the contract ...
5
votes
2
answers
394
views
Operation cost for invoking smart contract
I would like to find out if the smart contract's code size/storage or an operation's parameters helps to derive to the cost.
Is there a formula to calculate the cost of the operation to be invoking a ...
5
votes
2
answers
181
views
How do I get a list of a Tezos smart contract KT1 address entrypoints and its parameters?
I wish to retrieve info from a KT1 address so I know which entrypoints are available for consuming and which are their parameters and types. How can I achieve this? Thanks in advance.
5
votes
1
answer
144
views
Can I withdraw funds from an empty smart contract?
I've stuffed up bad and managed to send some Tez to an empty KT1 smart contract.
Is there any way of getting it back?
The contract is:
parameter string;
storage string;
code { CAR ; NIL operation ;...
5
votes
1
answer
88
views
method for calling to entry point of contract instance (?) created by contract.create
Contract A is not able to find the address of the contract created by contract.create. Tried adding the signature of B as well as it's complete definition in contract A but still, it doesn't solve the ...
5
votes
1
answer
292
views
Gas consumption in a chain of internal transfers
I am trying to perform a chain of contract calls with internal transfers.
I think my current contracts are very simple, but I run out of gas after only 4 internal transfers:
A script or one of its ...
5
votes
1
answer
97
views
Contract.create bytes array return value
I'm using liquidity lang, and define a storage:
type storage = {
usersDocuments : (address,address set) big_map;
documents: string set;
}
and I add in to usersDocuments https://pastebin.com/...
5
votes
1
answer
111
views
Operations created by a smart contract call chain go in the same block?
Imagine there is a smart contract which calls other smart contracts using TRANSFER_TOKENS and in the end lots of operations are created.
Are these operations baked in a block atomically? I mean, is ...
5
votes
1
answer
341
views
How to provide liquidity to the upcoming liquidity baking tez/tzBTC?
I've tried to understand how to interact on the interface on Better Call dev but can't seem to figure it out. When I execute them under simulation I get failed transaction.
Where do I insert the ...
5
votes
1
answer
52
views
bigmap.get(key, "") with default param in case of no entry for key in the map with Taquito
Can we do something similar to myMap.get(key, defaultValue = None) of smartPy with Taquito?
An instruction like:
const myContract = await Tezos.contract.at(contractAddress);
const contractStorage = ...
5
votes
1
answer
56
views
Are there any wallets that can call contracts?
I'm building a dapp on Tezos and would like users to call some of the related contracts directly from the webapp. E.g. I present a QR code with a prefilled contract call. Are there any wallets that ...
5
votes
1
answer
35
views
Tuples index access via contract's input params
I'm trying to get tuple value by index using contract's input param. Getting weird assertion error.
let%entry main = (idx: int, storage) => {
let tmp = ("test - 1","test - 2", 3)
failwith(tmp[...
5
votes
2
answers
133
views
Smart contract for bakers
Is it possible to write a Smart contract that would define the relationships between baker and delegator, and if so how would it be done?
It should include the following:
- delegation duration
- ...
5
votes
0
answers
81
views
"Unhandled error: Failure backtracked" while trying to creating a contract
I'm trying to work with the example code from the liquidity documentation for Contract.create(). The code compiles and tests on the online-editor properly. It also deploys using the editor. But when I ...
4
votes
3
answers
360
views
How are the originated contract addreses (KT1) computed?
How are smart contract addresses (those that start with KT1) computed?
I would like to know whether CHAIN_ID is somehow used in its computation, or it is possible to have two KT1 contracts with ...
4
votes
2
answers
204
views
Benefits of Michelson
I'm trying to understand the design decisions behind Michelson and I'm in the process of evaluating if I should be writing my dapp in the Tezos blockchain.
What type of benefits does Michelson have ...
4
votes
4
answers
969
views
Any way to get the public key of an address?
I am developing a dapp where I need the public key of an address of the user, is it possible to get the public key in the contract (using SmartPy)? Or even on the client side using taquito or any ...
4
votes
2
answers
759
views
How to extract the storage of a smart contract?
How do I extract the storage data of a deployed smart contract? I am trying to read the storage data from the "free Ledger Nano S" contract KT1BRudFZEXLYANgmZTka1xCDN5nWTMWY7SZ from the Tezos ...
4
votes
1
answer
42
views
In the broker2.liq example, how is storage being returned by the call function?
The code here returns value from Contract.call() as:
let _result, storage = Contract.call storage.x transfer storage () in
What are the values stored in _result and storage?
Note: I couldn't ...
4
votes
2
answers
152
views
How to store a really long string on the Tezos blockchain
Let's say I wanted to store an entire article or a manifest on the Tezos blockchain. Something that is bigger than 100kB. How would I go about doing that?
4
votes
1
answer
513
views
How do I get the storage value of a bigmap using pair datatype as key with taquito library?
I am using the taquito library to interact with a smart contract that I have uploaded to carthagenet.
However, I am facing an issue in retrieving the value of a bigmap property in my smart contract ...
4
votes
3
answers
523
views
How to get smart-contract storage data?
I try to get smart-contract storage data:
eztz.node.setProvider('https://alphanet-node.tzscan.io')
eztz.contract.watch(addr, 2, function(s){
console.log("New storage", s);
});
But got an ...
4
votes
1
answer
101
views
Documentation for Serializing Contract Call Data/Parameters
Is there any documentation available for how to serialize contract call parameters?
I found good documentation for serialization of general operations and took a look at the tzips but neither seems ...
4
votes
1
answer
65
views
Can someone provide a link to a tutorial on how to do a basic smart contract on the Tezos protocol?
I'm looking for a video tutorial on how to become a programmer/how to become more knowledgeable regarding smart contracts and such. Is there a good you-tuber who blogs about Tezos programming?
4
votes
1
answer
148
views
Calling view of Fa1.2 contract
From my understanding, getBalance, getAllowance, getTotalSupply & getAdministrator entrypoint requires another contract to read the values. How will the entry point of the second contract look ...
4
votes
3
answers
177
views
What's wrong with my calculation of fees and burn here?
I am trying to calculate the cost of a transaction, post-hoc, from the response to calling the entrypoint. This is for the purposes of a testing tool I am building that I need accurate costs for.
As ...
4
votes
1
answer
60
views
When contract simulation may fail to predict the contract's behavior?
When we try to run a smart contract using tezos-client, it estimates the gas cost and predicts the final output of the contract.
It simulates the contract execution under the current block-chain, ...
4
votes
1
answer
50
views
Time based Delegations possible?
Would it be possible, to make a "time-based-delegation"?
I.E.; I want to delegate for 5 Cycles to Bakery A and after that for 10 Cycles to Bakery B and so on.
Could something like this be realized ...
4
votes
1
answer
130
views
Upgradeable Contracts: Proxy Delegate vs Stored Lambdas
There are a number of design patterns for contracts that already exist on Ethereum. For upgradeable contracts, one of them is the use of a Proxy Delegate contract.
My understanding is that the Proxy ...