Questions tagged [smart-contracts]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
15 votes
3 answers
606 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 ...
  • 1,973
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 ...
  • 505
4 votes
3 answers
484 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
3 answers
332 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 ...
1 vote
1 answer
240 views

How do you create a secondary KT1 contact under your TZ address?

I want to have multiple KT1 address on one TZ address(ledger) to delegate to multiple people
1 vote
1 answer
49 views

Is there a parameter we can add to a KT1 contract so that it expires after a certain amount of blocks?

I'm asking because I would like certain KT1 addresses return the funds back to the owner after a certain amount of blocks
1 vote
1 answer
134 views

how to calculate the value of a single LQT token for Liquidity Baking?

In looking at the Granadanet contract storage, I can see the amount of tzBTC, Tez, and LQT tracked in/by the CPMM. Here are those values as of writing this: tokenPool 45805 xtzPool 111379958864916 ...
10 votes
1 answer
234 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
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 ...
5 votes
2 answers
374 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 ...
  • 505
5 votes
1 answer
69 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 ...
  • 697
4 votes
1 answer
121 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 ...
  • 680
3 votes
2 answers
348 views

Using sp.create_contract to generate pseudorandom numbers on-chain

In this answer, the answerer suggested that CREATE_CONTRACT could be used to generate a contract address which could then be used as a seed for a pseudorandom number in a contract. What would a simple ...
  • 233
3 votes
1 answer
195 views

Why aren't the offchain views appearing?

I'm extending the smartpy FA2 template # FA2 = sp.import_script_from_url("https://smartpy.io/dev/templates/FA2.py") class TezosLandNft(FA2.FA2): ... which has the following offchain views ...
  • 557
3 votes
1 answer
88 views

how can i send operation throught eztz to a contract specific entry point?

im tryng to send the operation to a deployed contract, this is my function ... eztz.contract .send( "KT18qHvhEZUwiawA8QEURwuK8RGJj184725L", keysext.pkh, keysext.sk, 5, "RIGHT LEFT UNIT", "...
2 votes
1 answer
135 views

How to transfer token to multisig contract

The contract code is [{"prim":"parameter","args":[{"prim":"pair","args":[{"prim":"pair","args":[{"prim":"nat","annots":["%counter"]},{"prim":"or","args":[{"prim":"pair","args":[{"prim":"mutez","...
2 votes
1 answer
101 views

Can't get tzBTC out of the tzBTC Granadanet contract

i'm trying to (eventually) add liquidity to the Liquidity Baking CPMM contract on Granadanet. In order to add liquidity, I need some tzBTC from the tzBTC contract here.. I cannot, for the life of me, ...
2 votes
1 answer
198 views

Parse address to string in smartPy

Can we parse a varialble of type sp.TAddress to sp.TString like this: strAddress = sp.string(sp.address("tz1-add")) or strAddress = str(sp.address("tz1-add"))? Smart Contract Example: import ...
  • 444
2 votes
2 answers
101 views

Random number on-chain

Since all the answers are a bit old, is there a better or more generic way to get a random number on-chain than using Harbinger Oracle? Would it be safe to imagine a community approved & audited ...
2 votes
1 answer
82 views

Why does `sp.pack('some string')` prepend `0x05010000002e` before the actual bytes?

If I pass in the string QmbPAr5RcCZZDRsNKnf2p1t6GK3Qu7oDH39HCK3aewUq3w to the sp.pack method in an entrypoint and perform and sp.trace in smartpy I expect to get the following bytes: ...
  • 349
1 vote
1 answer
410 views

Pseudo-random numbers for NFT attribute random generation

I'd like to generate an NFT within a contract and give it a randomly occurring attribute. As I search, it seems that the only fully-secure way to do this is to use an Oracle or build some sort of ...
  • 233
1 vote
1 answer
90 views

Calling balance_of via smart contract gives error A FAILWITH instruction was reached with 19

I am trying to call "balance_of" entrypoint of fxhash contract (in ghostnet). Deployed contract: https://better-call.dev/ghostnet/KT1FqmrtKA4Pz4cNDsikt8qrwEg8pdSCpYug/interact/check I used &...
  • 61
1 vote
1 answer
521 views

Converting a hash into an int within a range

I have a contract where I'd like to convert a hash (sha256 in this case, but I'm open to any of the other hashing algorithms available) into an Int (or Nat) between 1 and 100. I have the code that ...
  • 233
1 vote
1 answer
90 views

How to add new record fields in data storage after contract deployment? Is storing JSON in a field viable?

AFAIK, there is no way to update storage types(ex: can't add a new record field to a Map<sp.Nat, sp.record(a=1)>) of a contract after deployment. (Correct me if I'm wrong). This means, after a ...
  • 557
1 vote
1 answer
402 views

Smart contract calls another smart contract's method with SmartPy

How can I call a smart contract method from another smart contract with smartPy? Use Case: Lest's imagine that we have: Smart contract with a function increment(a) Smart contract with a function ...
  • 444
1 vote
2 answers
135 views

Read another contract's storage without making a transaction?

Is it possible for contract X to read the storage of contract Y without making a transaction? I think I understand how I can make X call a function on Y using a callback pattern. But since I only want ...
  • 1,973
1 vote
1 answer
273 views

Delegating from a Kt1 address locked my coins, how can I fix it?

Might have royally messed up here, but I added an address via command line with ./tezos-client add address stakingfacilities tz1WpeqFaBG9Jm73Dmgqamy8eF8NWLz9JCoY (for stakingfacilities baker in ...
1 vote
1 answer
74 views

How to add add a record to a map in CameLIGO

I'm using CameLIGO and want to add a record to a map. I keep getting this error: Error: ligo: : Parse error in file "tmp-1lMUlWlg5fktI.ligo", line 21, characters 45-46, after "{" and before "}": ...
1 vote
1 answer
31 views

How do we achieve a variable type of struct in smartPy

I am translating following code in solidity to smartpy. How do we achieve a variable type of struct in smartPy. Types.AssetTransferDetail[] memory _assetDetails = new Types....
0 votes
1 answer
82 views

How do you update a map in Pascal Ligo?

I'm trying to learn how to write a smart contract and using Ligo. I'm struggling with quite a few things at the same time e.g. syntax, understand the documentation, best practices etc. Baby step is, ...
0 votes
1 answer
36 views

Declaration Error: Variable name "x" already in use

When calling a method that uses a local variable twice, I'm getting this error. Example smartpy link. In this linked code I added a new method test_string_of_nat2 which triggers this behavior. How ...
  • 557
0 votes
1 answer
62 views

Vanity address generator for contracts

Is that even possible for Tezos contracts? There is a vanity address "generator" in JS for tezos. See github So looking for something like this but for Tezos contracts.
  • 37