Questions tagged [smart-contracts]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
15 votes
3 answers
532 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 ...
user avatar
  • 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 ...
user avatar
  • 495
1 vote
1 answer
128 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 ...
user avatar
4 votes
3 answers
454 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 ...
user avatar
4 votes
3 answers
254 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 ...
user avatar
1 vote
1 answer
233 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
user avatar
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
user avatar
10 votes
1 answer
212 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 ...
user avatar
9 votes
1 answer
143 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 ...
user avatar
4 votes
1 answer
99 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 ...
user avatar
  • 670
3 votes
1 answer
183 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 ...
user avatar
  • 557
3 votes
1 answer
83 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", "...
user avatar
2 votes
1 answer
67 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: ...
user avatar
  • 439
1 vote
1 answer
325 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 ...
user avatar
  • 233
1 vote
1 answer
343 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 ...
user avatar
  • 444
5 votes
2 answers
338 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 ...
user avatar
  • 495
5 votes
1 answer
67 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 ...
user avatar
  • 697
3 votes
2 answers
276 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 ...
user avatar
  • 233
2 votes
1 answer
96 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, ...
user avatar
2 votes
1 answer
154 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 ...
user avatar
  • 444
2 votes
1 answer
25 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 &...
user avatar
  • 101
2 votes
1 answer
125 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","...
user avatar
1 vote
1 answer
443 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 ...
user avatar
  • 233
1 vote
1 answer
78 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 ...
user avatar
  • 557
1 vote
1 answer
244 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 ...
user avatar
1 vote
2 answers
114 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 ...
user avatar
  • 1,973
1 vote
1 answer
55 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 "}": ...
user avatar
0 votes
1 answer
79 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, ...
user avatar
0 votes
1 answer
28 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 ...
user avatar
  • 557