Questions tagged [smartpy]

Discussion about the SmartPy language

Filter by
Sorted by
Tagged with
1
vote
1answer
2 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 ...
2
votes
2answers
183 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 ...
0
votes
1answer
18 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, ...
0
votes
2answers
58 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 ...
0
votes
1answer
31 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
2answers
137 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.
1
vote
1answer
23 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
2answers
51 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
1answer
70 views

How to create a contract which would delegate XTZs and receive rewards?

I am trying to write a contract that receives rewards from the baker using a default entry point and should only allow me to change the baker from a different entry point. I am using the smartpy tool ...
1
vote
2answers
32 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....
0
votes
1answer
83 views

Initiate a field in the storage of a contract with the source address of origination

I have the following smart contract where I pass admin address in the init function of the smart contract: (you can run it on smartPy online editor) class SC(sp.Contract): def __init__(self, ...
2
votes
1answer
24 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 ...
1
vote
1answer
106 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
1answer
29 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
2answers
44 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
0answers
25 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
1answer
27 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
1answer
20 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
2answers
35 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 ...
1
vote
2answers
100 views

Send tezos to contract address after origination using conseiljs

I am trying to send tez from my tz1-AAA account to KT1-AAA contract address means I want my contract address to hold some tez. Disclaimer - I have knowingly replaced some part of address with "....(s)...
1
vote
2answers
48 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
0answers
32 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/...
0
votes
3answers
74 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
1answer
23 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
1answer
53 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 ...
1
vote
1answer
58 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.
0
votes
0answers
18 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 ...
2
votes
1answer
24 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
0answers
27 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?
0
votes
0answers
115 views

Mint FA2 NFT when contract is called by purchaser

I'm working on a smart contract which allows a caller to "purchase" an NFT simply by calling the contract and providing payment. I'd like the contract to mint the NFT at the time the ...
1
vote
2answers
39 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 ...
1
vote
1answer
316 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 ...
1
vote
1answer
26 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 ...
2
votes
1answer
91 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 ...
1
vote
1answer
35 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
3answers
65 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
1answer
31 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
1answer
28 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
1answer
46 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
1answer
42 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?
0
votes
0answers
24 views

how to work with map of map

I have a structure that looks like this: struc = sp.TRecord( addr = sp.TAddress, value = sp.TNat ) struct2 = sp.big_map( tkey=sp.TAddress, tvalue=sp.TMap( sp.TNat, sp....
2
votes
1answer
79 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
1answer
36 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(...
1
vote
1answer
129 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 ...
0
votes
2answers
60 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.
0
votes
0answers
21 views

Can anyone refer me to a good code example that creates a Token crowdfunding STO/IDO/ICO contract in Tezos?

Can anyone refer me to a good code example that creates a Token crowdfunding STO/IDO/ICO contract in Tezos? (Comparable to ERC-20 crowdfunding contracts)
1
vote
2answers
83 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 ...
2
votes
1answer
107 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
1answer
50 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
1answer
57 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 ...