Questions tagged [smartpy]

Discussion about the SmartPy language

Filter by
Sorted by
Tagged with
1 vote
2 answers
35 views

Invalid Metadata on Smart Contract

I am in the middle of migrating my DApp from Ithacanet to Ghostnet, the majority of the migration is done, but I am unable to mint (it's a minting contract based off of hin) using the smart contract ...
user avatar
4 votes
1 answer
27 views

Unpacking return unexpected result

I'm having some issue with the contract read, i have data in format of sp.TMap(string,bytes), im using sp.pack() to get the bytes representation of a sp.TNat in a concrete example for a nat 200 y get ...
user avatar
4 votes
1 answer
43 views

How to get the owner of an FA2 token on chain

For an FA2 nft contract, how can I get the address of the owner of token_id 0 from inside another contract?
user avatar
2 votes
1 answer
26 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
3 answers
51 views

How to get fxhash token attributes with smartpy?

Want to obtain fxhash token attributes/metadata with smartpy, the problem is fxhash smart contract doesn't have entrypoint or views for it. There is "get_token_data" view but it returns ...
user avatar
  • 101
2 votes
1 answer
41 views

Chest keys generated by @smartpy/timelock are not functional

The tool I use https://www.npmjs.com/package/@smartpy/timelock, https://github.com/RomarQ/tezos-timelock/ the tool works good on other functions such as openChest and createChestKey. I used node 14.14....
user avatar
  • 101
1 vote
1 answer
17 views

When generating contract metadata with `sp.init_metadata` do you include or exclude on-chain views in the `views` array in the metadata?

When performing self.init_metadata("metadata", some_metadata) on contract metadata inside smartpy, should the list of views inside the TZIP-16 metadata only contain off-chain views, or must ...
user avatar
  • 439
1 vote
1 answer
20 views

Is it possible to use an existing contracts storage as the seed data for a new contract that has the same storage schema?

Can you deploy a new copy of a contract with SmartPy and simultaneously copy the storage of an already existing contract that has an identical model into the freshly deployed contract?
user avatar
  • 439
1 vote
1 answer
33 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,...
user avatar
  • 439
1 vote
1 answer
14 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( ...
user avatar
3 votes
1 answer
49 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 ...
user avatar
  • 439
2 votes
1 answer
27 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 ...
user avatar
  • 439
2 votes
0 answers
46 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 ...
user avatar
  • 439
1 vote
1 answer
27 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 ...
user avatar
  • 439
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
user avatar
2 votes
1 answer
27 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
user avatar
0 votes
0 answers
19 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....
user avatar
1 vote
1 answer
51 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 ...
user avatar
0 votes
2 answers
47 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 ?
user avatar
0 votes
0 answers
28 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 ...
user avatar
  • 557
2 votes
2 answers
33 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 ...
user avatar
  • 23
1 vote
1 answer
42 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 ...
user avatar
  • 557
1 vote
1 answer
89 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 ...
user avatar
0 votes
1 answer
21 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=...
user avatar
  • 557
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
2 votes
1 answer
87 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 ...
user avatar
0 votes
0 answers
21 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 ...
user avatar
  • 557
0 votes
1 answer
52 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 ...
user avatar
  • 439
2 votes
2 answers
47 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 ...
user avatar
  • 439
0 votes
0 answers
25 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....
user avatar
2 votes
2 answers
99 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 ...
user avatar
  • 439
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
40 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 ...
user avatar
  • 557
0 votes
1 answer
75 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....
user avatar
  • 557
1 vote
1 answer
128 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 ...
user avatar
  • 557
1 vote
1 answer
23 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 ...
user avatar
1 vote
3 answers
102 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?
user avatar
  • 557
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() ...
user avatar
  • 5
1 vote
1 answer
39 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 ...
user avatar
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 ...
user avatar
  • 113
0 votes
1 answer
94 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, ...
user avatar
1 vote
1 answer
96 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 ...
user avatar
1 vote
2 answers
44 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....
user avatar
  • 11
4 votes
3 answers
81 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 ...
user avatar
  • 41
2 votes
1 answer
51 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 ...
user avatar
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 ...
user avatar
0 votes
1 answer
61 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 ...
user avatar
1 vote
2 answers
79 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
user avatar
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....
user avatar
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 ...
user avatar