Questions tagged [smartpy]
Discussion about the SmartPy language
151
questions
1
vote
1
answer
31
views
Why does unpacking a record that has a key containing bounded data fail with `to_value sp.TBounded` in smartpy?
Tests are throwing a to_value error in the scenario when trying to unpack a record that contains a key with a bounded type TNat inside the entrypoint being called.
There's a minimal reproduction below,...
0
votes
1
answer
11
views
Getting error in cryptobot smart contract. [What fix is required ?? ]
import smartpy as sp
# TODO: Code needs to be fixed.
class Cryptobot(sp.Contract):
def __init__(self, manager_address, life_state, initial_mutez, market_address):
self.init(
...
3
votes
1
answer
40
views
Why can I not subtract 2 local variables of type nat from each other and assign that result to another local variable in a view in smartpy?
I am trying to do some maths operations inside an on-chain view and am getting an unexpected result.
The reproduction contract tries to perform the following steps:
Define an internal contract ...
2
votes
1
answer
17
views
Why does calling sp.address() with a dynamic value inside an entrypoint fail?
Is there some way to call sp.address inside an entrypoint and pass in a dynamic String?
I have created an example contract showing the failing state:
import smartpy as sp
class ...
2
votes
0
answers
44
views
How to use internal hacks to convert from String to Address (or from Address to String) in SmartPy
There is a similar question but it does not fully answer this question.
In the answer for that question posted here there is mention that while it is officially not possible it is actually technically ...
1
vote
1
answer
25
views
Receiving a "doesn't have a comparable type" error when returning a list from an on-chain view
When I return a list from an on-chain view am receiving a type error but am unsure where to set the type in order to fix it.
Returning a string or integer from the view works fine. Is there a set ...
1
vote
0
answers
8
views
Suggestion more then question about tezos course on plural sight
There is a good course about BlockChain fundamentals on Plural sight but addressing ethereum. It could be great if someone can create similar curse there with targeting tezos with
2
votes
1
answer
25
views
grpc call consumption in smartpy
we have done a grpc call consumption in python. now for our smart contract wanted to consume one grpc call. is it possible in smartpy.
Unable to found any example till date
0
votes
0
answers
17
views
Initiating a contract with map
I want to originate a contract in SmartPy with an initial map() payload. However the originated contract always has an empty contracts storage. Here's what I have:
def __init__(self):
self....
1
vote
1
answer
46
views
Can I create an on-chain view that calls another contract's on-chain view and return it?
I have two contracts contract_one and contract_two. On contract_two I have an on-chain-view defined like this:
@sp.onchain_view()
def get(self, id):
sp.result(self.data.map[id])
This view works ...
0
votes
1
answer
37
views
How to raise or emit an event?
In Solidity there's emit keyword for raising an event. How to do it in Tezos in a smart contract?
Namely, a) define b) emit an event
?
0
votes
0
answers
27
views
Is there a smartpy util to stringify JSON?
I see there's a good utils repo for strings here:
https://github.com/RomarQ/tezos-sc-utils
I'm just wondering whether there's one for stringifying JSON. Or an example that does this.
Input: map or ...
2
votes
2
answers
31
views
Smartpy restrict entrypoint for originated addresses (KT1)
I would like to know if the entrypoint of my smart contract is called from an implicit(tz1) or an originated address(KT1). How can i do the check in smartpy?
Looking at the Smartpy documentation, it's ...
1
vote
1
answer
40
views
Using the token_metadata @offchain_view to load tzip-21 compliant metadata
Are there any downsides to how I'm declaring the token_metadata in the @offchain_view below? Loading the data from storage appears to work as expected when testing it on tzcomet and BCD, though I just ...
1
vote
1
answer
73
views
NFT collection prices API?
I am building on Tezos (I am new here). I was wondering if there is an API for getting floor prices of NFT collections? For example getting the floor price of Tezzardz on OBJKT.com. If not how can I ...
0
votes
1
answer
18
views
Missing private variable when using private lambda on offchain view
I'm getting the error Missing private variable string_of_nat Is it not possible to use private lambdas within off_chain_views? What could I do if I want to use them here?
https://smartpy.io/ide?cid=...
0
votes
1
answer
27
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 ...
2
votes
1
answer
72
views
How do I call an entrypoint of an existing contract using SmartPy?
How does one call an entrypoint of an existing contract using SmartPy?
For example, I'd like to be able to write a contract that calls the getBalance method of the existing ETHtz FA1.2 contract and ...
0
votes
0
answers
20
views
How do you compile 2 smartpy contracts with one's deployment address depended by the other?
Say we have contract A and contract B. We want to use contract A's address as the admin for contract B.
Do I need to first deploy contract A and then input that address into contract B's admin_address ...
0
votes
1
answer
44
views
Originating a contract fails with 'unexpected_lazy_storage' ONLY when exception optimisation level is set to 'full-debug'
I have a contract that originates correctly when exception_optimization_level is set to debug-message and default-line. The contract tests, compiles, and works as expected except for a bug that is ...
2
votes
2
answers
43
views
Receiving an "OpenVariant" error when evaluating view result in another contract. How do you use the view response inside a smartpy contract?
I have a scenario that works in local smartpy tests, but once deployed to testnet the same call responds with an obscure "OpenVariant" error.
There is a check that happens inside an ...
0
votes
0
answers
23
views
How minimize storage fee when doing airdrop using smartpy and fa2 template
Hello I try to do a airdrop for my community using FA2 template and smartpy,
you can see my smart contract below :
import smartpy as sp
FA2 = sp.io.import_template("FA2.py")
class Token(FA2....
2
votes
2
answers
91
views
How do you convert a string sent to an entrypoint into its byte representation?
I want to turn a string into the 0x byte format inside an entrypoint.
If I try to use sp.pack() the actual value I want gets prepended with pack instructions as detailed here
I'm looking for a runtime ...
2
votes
1
answer
61
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:
...
1
vote
1
answer
38
views
What guarantees do on-chain views provide?
A couple of months back, I asked this about off-chain views (here).
Now, on the Hangzhou testnet, synchronous on-chain views are supported. (smartpy documentation). Do these views provide ...
0
votes
1
answer
67
views
Is it possible to dynamically generate FA2 token metadata?
For example, I know the code below isn't valid syntax, but would doing something like it be possible to dynamically set metadata content based on the token id? If so, how would that work?
@sp....
1
vote
1
answer
115
views
Is there a "standard" way to load off-chain metadata for all tokens from a single off-chain data source in an FA2 contract?
Let's say I want to create a fixed cap of 10,000 NFTs. I pre-generate the token_metadata and store it on IPFS. The token_ids are only recorded on the FA2 contract when they're bought.
If I don't want ...
1
vote
1
answer
17
views
How can I debug "Error in generated Michelson contract" SmartPy CLI compilation error
I'm trying to compile a script locally, it doesn't throw any errors in the online SmartPy terminal, but when I try to compile locally with add_compilation_target and SmartPy CLI I get:
"Error in ...
1
vote
3
answers
95
views
Is it possible to optimize FA2 NFT storage to create 10,000+ without expensive storage fees?
I used this Smartpy code to mint 200 NFTs (max allowed per transaction) which cost cost 14 Tez - bettercalldev link.
How much could this be optimized?
0
votes
1
answer
12
views
Online SmartPy IDE run error:
The error says:
exports[f] is not a function.
Not sure why when I try to run....
import smartpy as sp
@sp.add_test(name = "First test")
def test():
scenario = sp.test_scenario()
...
1
vote
1
answer
36
views
How to compare TKeyHash with TAddress? [SmartPy]
I am writing a smart contract which allows the delegate to be changed. I also want incoming payments to be permissioned. Ideally, I want to update the incoming payment whitelist with the baker's ...
1
vote
1
answer
137
views
Is it possible to break out / access storage from a michelson lambda?
I am new to Michelson and Smartpy so forgive if I have any mistakes, I will try to correct them.
I have not been able to find an answer to the question if a function like the below, prevents the ...
0
votes
1
answer
88
views
Getting CORS errors on mainnet.smartpy.io with Taquito
const Tezos = new TezosToolkit('https://mainnet.smartpy.io');
const network = {
type: 'mainnet',
rpcUrl: 'https://mainnet.smartpy.io'
};
This is what I've been using to hook up Taquito, ...
1
vote
1
answer
88
views
Calling Harbinger using Smartpy to get randomness
I want to get a random value in my smart contract to provide a fair distribution of different tokens.
I read that using Harbinger to get values and use it for entropy could be the good way to do. But ...
1
vote
2
answers
43
views
SmartPy cast sp.TAddress to contract
I have one contract which creates and stores another contract, so in the creator contract I have something like:
children=sp.map
(
tkey=sp.TNat,
tvalue=sp....
4
votes
3
answers
73
views
unhandledRejection {} when using smartpy cli compile/test
I did the installation of https://smartpy.io/docs/cli/ (including python,node and the cli version 0.8.3-1) both in ubuntu (windows subsystem) and in Windows 10 and every time I try to run compile or ...
2
votes
1
answer
48
views
Is it possible to test for type exceptions in SmartPy?
How do you catch parameter type exceptions in SmartPy tests?
There's an example of exception testing in: https://smartpy.io/docs/scenarios/testing
An example from docs
# Assert exception result
...
2
votes
1
answer
152
views
How do I use sp.if_ and sp.for_ control statements in pure Python?
I'm following this: https://tezos.b9lab.com/smartpy/language guide, but it's written for the SmartPy online IDE, I'm trying to do this all in my local dev environment.
PyCharm IDE gives me an "An ...
0
votes
1
answer
53
views
Packing args in taquito to match sp.pack / PACK
How can i pack on taquito side params so that they match what i would get in smartpy with sp.pack?
Say i have params two ints and a string: 1, 3, "something"
What do i need to do in taquito ...
1
vote
2
answers
71
views
Is it possible to read external smart contract data with smartpy
I would like to make a smart contract (A) where I call an entrypoint on contract B
Is it possible to either check the return value of the entrypoint interaction or read a big_map of B's
0
votes
0
answers
31
views
missing token metadata
I believe with this operation ooDavbDYs9SkBR4JoaUxTBysvEnd7y1gP1ZDGddQgfQZaURpdjx I have created a token.
This is the entry point I called
@sp.entry_point
def mintDiezDAO(self, params):
sp....
1
vote
1
answer
37
views
Best way to duplicate/sync private database with FA2 contract transactions & balances
If you wanted a private DB to have all of the transactions,balances etc. of a particular FA2 contract deployed on mainnet, what would be the best way of achieving this?
Is it possible to have a ...
0
votes
1
answer
24
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
45
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
55
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
85
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
29
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
108
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 ...
0
votes
0
answers
33
views
Is there any default FA2 / FA1.2 config to mint non-transferable tokens?
I am working on a requirement that needs a non-transferable token (similar to ERC 1238 requirement). ie the token can be transferred only from token contract/ admin to the user and the user cannot ...