Questions tagged [smartpy]

Discussion about the SmartPy language

Filter by
Sorted by
Tagged with
0
votes
2answers
17 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
10 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
52 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
1answer
43 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
1answer
39 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
26 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
1answer
52 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
1answer
74 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
60 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
1answer
38 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
1answer
17 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
1answer
25 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 ...
0
votes
1answer
17 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 ...
2
votes
1answer
46 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
1answer
24 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 ...
1
vote
1answer
89 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
2answers
68 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
1answer
27 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
1answer
27 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
1answer
17 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
1answer
48 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
0
votes
1answer
26 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
1answer
52 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
1answer
33 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
1answer
25 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....
1
vote
1answer
31 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 ...
1
vote
1answer
17 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
48 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
2answers
87 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
27 views

What's the best way to convert from TMutez to TBytes?

Previously when I asked about converting types, I got this useful suggestion: For mutez, you could start to convert to int (by dividing by 1 mutez) and then use the same techniques. I'm wondering if ...
1
vote
2answers
66 views

How to Integrating SmartPy compiler within the browser?

I have been trying to integrate the SmartPy compiler toolchain within Cryptoverse wars Learning interface and have been going through this video (OCaml Under The Hood: SmartPy) and have encountered ...
1
vote
1answer
32 views

In a SmartPy smart contract, is there 'continue' or 'break' for loop?

In a SmartPy smart contract, is there 'continue' or 'break' for loop? When I use 'continue' for loop, an error occurred. 'Error: invalid syntax'
1
vote
1answer
46 views

How do you set the time of a transfer when testing contracts with SmartPy?

Previously, to set the (virtual) time a transaction happened in SmartPy I used the flag now when running a command like run. Now it seems to cause an error (seems like something changed in an update). ...
1
vote
1answer
51 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
1answer
21 views

How can I manually create an on chain contract call?

Using tezos sandbox mode, I am trying to test an on chain contract call in isolation of the main contract which calls it. If my contract was the Collatz template, it would like be trying to run the ...
1
vote
1answer
38 views

Is it possible to convert types in SmartPy?

For example, converting a TMutez into a TString?
1
vote
1answer
27 views

How should sp.if be used?

I find I run into some unexpected behavior when using sp.if. e.g. a = False sp.if 1 > 2: a = True seems to result in a == True. The example below is doing so in the ...
1
vote
1answer
16 views

SmartPy: How to test an invalid transaction sent from a contract call

I am testing a contract in SmartPy that uses a contract call (similar to the Collatz example). Contract 'A' sends a transaction to contract 'B' with some data. Contract 'B' does some computation and ...
1
vote
2answers
63 views

How can I write On Chain Contract Calls in Tezos Sandbox?

I am trying to write a test case in Tezos Sandbox that uses an On Chain Contract Call. To start with, I am trying to implement the example from SmartPy "On Chain Contract Calls - Collatz" ...
1
vote
1answer
22 views

in smartpy, local variable param, what's difference?

in smartpy def aa(self) { value_in_func = "1234" msg = "abc" + value_in_func hex_string = msg.encode("utf-8") thingToSign = sp.bytes("0x" + ...
2
votes
0answers
55 views

how to hook function in smartpy FA2

when calling transfer method, how to call hook method on received smart contract. I'm using fa2 in smartpy
1
vote
1answer
20 views

How does sp.record arrange data into pairs?

For example if I have the following code: sp.record(one = one, two = two, three = three, four = four, five = five) Would the format of the result be pair(one pair(two pair(three pair(four five)))) or ...
1
vote
1answer
33 views

Can we have a Time clocked transaction in Tezos?

I want to make an escrow contract where the transaction can be done after an interval. Is it possible / any hack that can make it happen? The balance should get deducted from the sender beforehand and ...
1
vote
1answer
40 views

How do you do sp.record(sp.pack()) outside of SmartPy?

I have a smart contract which verifies a signature from Bob in order to do something. The contract was made using SmartPy and for testing the scenario I used the following code to produce a signature: ...
1
vote
1answer
25 views

What guarantees do we have when verifying the sender's identity (in SmartPy)?

When we check the address that called the current entry point e.g. in SmartPy: sp.verify(self.data.authorizedAddr == sp.sender) What guarantees do we have? For example, is it possible for someone ...
2
votes
1answer
85 views

Why does smartpy use sp.for/sp.while instead of the default loops provided by python?

So I just started out with smartpy and I am kinda confused about the point of having separate expression for loops. My understanding is that it is may be because it's a part of on-chain computations, ...
3
votes
4answers
96 views

Is it possible to use natural logarithmic in your smartpy code?

If not,is there any alternative way to implement a natural log component into your smart contract code?
4
votes
1answer
97 views

Calling view of Fa1.2 contract

From my understanding, getBalance, getAllowance, getTotalSupply & getAdministrator entrypoint requires another contract to read the values. How will the entry point of the second contract look ...
2
votes
4answers
85 views

Is there a formula to build parameter messages to be passed to smart contract entrypoints?

When calling a smart contract entrypoint, it is required to pass the needed entrypoint parameters. This is done through a message that must be sent in JSON/Pairs format. My doubt is: Is there a ...
2
votes
1answer
77 views

How to get a contract storage data from another contract in smartPy?

I'm trying to access a storage data of a contract from another one using the continuous passing style in smartPy. import smartpy as sp class XXIFA12(sp.Contract): def __init__(self, admin): ...