Questions tagged [smartpy]
Discussion about the SmartPy language
157
questions
0
votes
1
answer
28
views
sp.contract from hash key
In the test, I am trying to replace the admin with a fixed account.
But I cannot find what t should be.
admin = sp.contract( t,"tz1dQXqXZ3Y5sgYwU9Aq9xRJPxEZNUwyE6ht", entry_point = "&...
0
votes
2
answers
46
views
Calling Harbinger price contract get method in taquito
I am trying to call the get method of the coinbase normalizer harbinger price contract (KT1AdbYiPYb5hDuEuVrfxmFehtnBCXv4Np7r).
Is this the correct way to call the get method, as it doesn't seem to be ...
0
votes
0
answers
72
views
is there an implementation of the FA1.2 template in ligo with metadata ( TZIP-016)?
I have find 2 implementations of the FA1.2 template, one in PascaLigo (https://gitlab.com/camlcase-dev/fa1.2/-/blob/master/ligo/fa1.2.ligo) and one in CameLigo https://gitlab.com/ligolang/ligo/-/blob/...
1
vote
2
answers
87
views
what is the equivalent of ligo "compile-parameter" for smartpy?
The Smartpy compiler allow to compile a contract (compiling the code and the initial storage) but I don't see any "compile-parameter" option, that would allow to convert a smartpy command to ...
0
votes
3
answers
98
views
More than a few hundred NFTs?
Is is possible to use Tezos to make more than 100ish NFTS? Using this template it seems that if over ~100 NFTs are minted, the contracts storage runs out. This is also concerning because it seems if ...
2
votes
1
answer
31
views
How to assign a variable based on the output of a function
I cannot figure out how to assign a variable based on the output of a function. I basically want to do this in my __init__ method
def square(x):
y = x * x
return y
toSquare = 10
result = ...
2
votes
1
answer
124
views
How do I delete an item in a smartpy list
I am trying to figure out how to delete an item from my list that I created with possible_values = sp.range(0, 100, step = 1) I have tried possible_values.pop(index), that doesnt work. I have tried ...
2
votes
1
answer
60
views
How to get the current time/timestamp in smartpy contract?
I deployed a smartpy contract in florencenet via smartpy.io. The command sp.timestamp_from_utc_now() used inside the program seems to be not giving the current time. Instead it is giving the same time ...
1
vote
0
answers
29
views
How can we accept USDTZ in smartpy smart contracts, is it even posible?
I was working on a token sale, so is there any way we can accept USDTZ as a mode of payment for the tokens?
1
vote
1
answer
48
views
Getting error at time of testnet deployment
I was familiarising with smartpy IDE by executing the code as mentioned in the below link
https://tezos.b9lab.com/smartpy/exercise-2
However, when I proceeded to deploy the contract, I am getting the ...
1
vote
1
answer
445
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 ...
3
votes
1
answer
118
views
Limiting the time (time/date based) that a contract method can be called
I'd like to publish a contract that allows calls up until a certain time and date.
For example, say I want to allow anyone to call it for 1 year after publishing the contract to the blockchain, then ...
3
votes
2
answers
279
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 ...
1
vote
1
answer
43
views
Tweaking FA1.2 to add level based balance snapshots to assist token voting in a DAO
DAOs functioning on a token voting mechanism (using either FA1.2 or FA2) mostly require the locking up of tokens for the entirety of the voting period essentially to prevent double-voting or any form ...
2
votes
1
answer
69
views
Smartpy Michelson errors only on deployment (inconsistent_annotations, inconsistent_types)
Getting this error ONLY when deploying the smartpy contract. There are otherwise no errors when testing/compiling the code. Is there a way to get a better error message? Is there a way to trigger ...
0
votes
1
answer
50
views
error Type sp.TInt / sp.TNat mismatch
Error: Type sp.TInt / sp.TNat mismatch
sp.is_nat expects a sp.TInt
Got: sp.TNat
line 119
Line: 119
self.data.shop_items[item_to_purchase.key].amount -= sp.as_nat(item_to_purchase.value)
I'm ...
0
votes
1
answer
58
views
Error: list indices must be integer, not Expr
I am trying to get the first N prime numbers in the following way:
@sp.entry_point
def n_primes(self, num):
primes = [2]
p = sp.local("p", 1)
i = sp.local("i&...
2
votes
1
answer
100
views
Smart contract break for loop in smartpy
I need to break a for loop in smartpy, but break does not work.
Is there any other solution I could use?
1
vote
2
answers
60
views
Keeping original sender in inter-contract call
I have a token contract (let's say it TC) and creating a contract Wallet. Now, is it possible for a user to call Wallet's entrypoint deposit which will do an inter-contract call to TC's transfer ...
3
votes
3
answers
162
views
Big map of map vs Big map of pairs
In the FA2 example (https://smartpy.io/ide?template=FA2.py) with multiple assets, we are using a big map of pairs (of user and token). Another option might be storing big map mapping users to another ...
2
votes
1
answer
148
views
Variable callback entrypoint in smartpy
Is it possible to use a variable as the entry_point for a callback in smartpy?
This works:
@sp.entry_point
def getProofs(self, address, callback_address):
c = sp.contract(...
0
votes
1
answer
76
views
sp.if not working as it should
I am using sp.if in an internal function, then I call it in an entry point, but whatever I enter in sp.if, it always is read as "True". Why? And how to fix it?
My code :
def is_something(...
0
votes
2
answers
74
views
What's the best IDE and language to create a FA2 Token?
Does SmartPy provide the best interface to do it?
https://smartpy.io/ide?template=FA2.py
Does this example provide everything you need to create your own token?
Any help would be appreciated.
1
vote
2
answers
117
views
Why is this big map update using up so many bytes?
In this question I asked why so much Tezos was burned when updating 380 cells in a grid.
It's surprising to see how many bytes it actually took though. If you look at the transaction, there were 380 ...
1
vote
1
answer
211
views
Best way to create FA1.2 token with TZIP016
What is the best way to implement a FA1.2 token with TZIP-016 metadata (symbol, name, decimals...)?
I am using SmartPy.
So far, I noted two methods:
the first one is to implement a FA1.2 token with a ...
1
vote
1
answer
55
views
How can I encode a 2D matrix of booleans in the least amount of bytes?
I'm looking at this ethereum smart contract that iterates over an area in a 2D bool matrix to reserve pixels. When looking at a call to that ethereum smart contract for a 20x11 area, it used 0.0315 ...
1
vote
1
answer
79
views
What would be the simplest way to connect a smartpy contract to an oracle tracking the XTZ/USD pair?
I see there's a smartpy chainlink oracle example and a github repo for Harbinger. I briefly looked at the code and it appears they are for setting up Oracles + clients. Are there any existing XTZ/USD ...
2
votes
1
answer
121
views
How should a contract check whether an address owns a FA2 token created in another contract?
I've broken up my code into 2 contracts. FA2 contract and other one managing its data and providing additional functionality on top. This is to not overload a single contract, however, it does ...
2
votes
1
answer
136
views
Is there a list of public repos using smartpy?
I'd like to see more complex examples of smartpy being used in main net contracts.
So far, I've found tzcolor's auction house contract SUPER helpful. Are there any other really good examples (that are ...
1
vote
1
answer
324
views
How do offchain views work and what guarantees do they provide?
What are the technical differences between offchain views vs onchain entry points? I know one of the differences is that onchain entry points mutate while offchain views don't. Are there any other ...
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 ...
1
vote
1
answer
27
views
Does smartpy propagate exceptions?
I'm doing something like this, but the invalid scenario assertion fails.
Is there a way to propagate the exception from the other contract? Or do I just have to test that contract separately?
class ...
1
vote
1
answer
140
views
What are good examples of upgradable smartpy contracts using Proxy delegates or stored lambdas?
I'm trying to ensure my contract is upgradable and I learn best by looking at existing examples. Does anyone have any good examples to look at?
Here are some links to previous stackoverflow Q&A's ...
1
vote
1
answer
77
views
Incompatible parameter error when calling another smart contract
I'm getting this weird error when trying to call the mint entrypoint from another contract... I had additional parameters in the BuyLandRequest and was overriding the TezosHomepageAdNft.mint ...
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 ...
0
votes
2
answers
133
views
How can I do string interpolation on smartpy?
I'm trying to provide better error messages. I've tried several things already that don't work such as regular python fstrings, regular string concatenation. I'm tried to using the sp.string function ...
2
votes
1
answer
446
views
How to store and load custom FA2 NFT metadata?
First time I'm writing a smart contract. If anything doesn't make sense at all, feel free to call out what specifically doesn't make sense and suggest a better approach. Thanks!
At a high level I just ...
1
vote
2
answers
271
views
Best Language to Use with Tezos
There are a lot of options when it comes to coding Smart Contracts on Tezos. My question is simple, which of the supported languages is the best in terms of support, east of use, documentation, and ...
0
votes
1
answer
49
views
import_script_from_url syntax
i'd like to ask if it's possible to load another smart contract from an IPFS Hash or from a SmartPy url. What would be the best way to handle them with urls?
Contract A: https://smartpy.io/ide?cid=...
0
votes
1
answer
166
views
Smartpy transfer contract balance to an address
I'm trying to figure out how to withdraw money from the contract within a smartpy entrypoint, and test the result in my scenario.
When I test the entrypoint:
@sp.entry_point
def withdraw(self, ...
0
votes
1
answer
22
views
Is SmartPy package inside All Michaelson Supported Languages?
I've discovered that Liquidity, LigoLang and Ocamel Support Tezos development, but I've only found 1 resource that states that SmartPy supports only LigoLang. I wanted to use the right language to ...
-1
votes
1
answer
67
views
Tezos SmartPy Developer Course video 1.2
How do I get find the Tezos test net as opposed to the web browser smart py interface?
Regards
WF
1
vote
1
answer
58
views
How to compare a mutez value with int in smartpy
When trying to check the transferred value is positive I get an error that TMutez is not TIntOrNat.:
sp.verify(sp.amount > 0, "Amount should be positive")
1
vote
1
answer
221
views
SmartPy Contract: Receive a balance?
I'm learning SmartPy and I'm trying to make a simple escrow contract. I read that contract.balance can be used to access the balance of a contract. In that case, how would I go about receiving XTZ to ...
1
vote
1
answer
53
views
How to resolve sp.TKey is not sp.TAddress error in SmartPy?
I have a function like this
@sp.entry_point
def _verifySigPersonalSign(self,req,sig):
sp.verify((req.deadline != sp.timestamp(0)) | (sp.now<=req.deadline), "request ...
1
vote
1
answer
65
views
How to compare timestamps in tezos smartpy?
req passed to _verifySigPersonalSign will be of type ERC
import smartpy as sp
ERC = sp.TRecord(sender=sp.TAddress,to=sp.TAddress,deadline=sp.TTimestamp)
class StoreValue(sp.Contract):
@sp....
2
votes
1
answer
61
views
What is the correct usage of sp.unpack()?
*Note that the answer to this question may be very similar to this one.
I tried out the code below within a part of a larger lambda function and got the following error. The purpose is just to convert ...
3
votes
1
answer
63
views
How can I avoid sp.TOption type when using sp.unpack()?
Within my smartpy contract, I want to convert from one type into another using sp.pack() and sp.unpack.
Below is an example of the method I am trying to use, converting a string to bytes.
...
1
vote
1
answer
75
views
Can a Dapp buy or sell (usdtz or tzbtc) from dexter?
Looking for a way for a dapp to buy tzBTC automatically after receiving tez from a baker.
1
vote
2
answers
164
views
Implementing Contract Metadata (tzip-16) on an already originated FA1.2 Smart Contract
Referring to the documents and examples of tzip-16, how would one implement the contract metadata on a Fa1.2 contract on SmartPy? In order to provide balance updates and offchain events.