Questions tagged [smartpy]

Discussion about the SmartPy language

Filter by
Sorted by
Tagged with
6
votes
4answers
260 views

Ethereum/Solidity dev here, looking to migrate some Solidity contracts onto Tezos. Was hoping to have some light shed on a few questions

Was hoping to have some light shed on a few questions. Narrowing in on using Ligo, Archetype, or Liquidity. Is Liquidity kind of a dead-end right now? I noticed it's not listed on developeres.tezos....
5
votes
2answers
126 views

How do I get a list of a Tezos smart contract KT1 address entrypoints and its parameters?

I wish to retrieve info from a KT1 address so I know which entrypoints are available for consuming and which are their parameters and types. How can I achieve this? Thanks in advance.
5
votes
1answer
47 views

bigmap.get(key, "") with default param in case of no entry for key in the map with Taquito

Can we do something similar to myMap.get(key, defaultValue = None) of smartPy with Taquito? An instruction like: const myContract = await Tezos.contract.at(contractAddress); const contractStorage = ...
4
votes
1answer
113 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 ...
3
votes
4answers
116 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?
3
votes
3answers
126 views

How to delegate the balance of a smart contract?

I am looking to create a smart contact that will delegate the funds it is storing. 1) How does an originated KT address delegate to a baker? 2) If a KT address delegates, can it do anything else? I ...
3
votes
1answer
95 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 ...
2
votes
2answers
352 views

How to retrieve data from smart-contract using javascript?

I have stored data that I would like to retrieve from a deployed smart-contract. The storage structure was defined using SmartPy: def __init__(self): self.init(bmap=sp.big_map(tkey=sp....
2
votes
1answer
100 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, ...
2
votes
1answer
168 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 ...
2
votes
1answer
262 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 ...
2
votes
4answers
128 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
56 views

How to create a mapping in smartpy ? Do we need to define the datatypes of the key & value like in solidity?

Want to implement mappings like this in smartpy : // Mapping from token ID to owner mapping (uint256 => address) private _tokenOwner; // Mapping from token ID to approved address mapping (...
2
votes
1answer
88 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 ...
2
votes
2answers
50 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. ...
2
votes
1answer
129 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): ...
2
votes
1answer
196 views

How to deploy a smart contract influenced by UI inputs using ConseilJS and SmartPy generated Michelson?

I wish to be able to create a smart contract taking input from a UI to supply parameters pubKey,prvKey,pubHash for the deployment and minAmount and maxTime to influence the Michelson. I have the ...
2
votes
1answer
50 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
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 ...
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?
2
votes
3answers
62 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
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(...
2
votes
1answer
68 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
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 ...
2
votes
1answer
46 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 ...
2
votes
1answer
78 views

Is it possible to convert types in SmartPy?

For example, converting a TMutez into a TString?
2
votes
1answer
59 views

Cyclic inter contract calling in smartpy

What I am trying to achieve is that, once I receive data from another contract my contract should return data after computation to same contract who has sent the data. Computational Contract import ...
2
votes
1answer
106 views

How do we use getBalance() function in FA1.2 token contract in SmartPy?

https://smartpy.io/demo/index.html?template=FA1.2.py&source=post_page--------------------------- This is the token contract link. It is deployed on the https://babylonnet.SmartPy.io node with the ...
2
votes
2answers
126 views

Tezos Blockchain Time in SmartPy

I am new to Tezos Block chain and I am writing a smart-contract for crowdfunding using smartPy. For this I need current date time of Tezos Block chain. So, can anyone help me out, how to find out this?...
2
votes
1answer
23 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
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
23 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 ...
2
votes
1answer
55 views

How can I delay executing a smart contract until 30 minutes after its last invocation using Tezos SmartPy?

I have a function f1 in tezos contract that can be invoked by a node but after 30 min of the invocation if no other function f' has been invoked the f1 has to continue its process normally otherwise ...
2
votes
0answers
67 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
2
votes
0answers
55 views

how can i call specific smartpy tezos contract entrypoint using ConseilJs?

I am trying to set UI that allow users to interact with tezos smart contract by pressing some buttons that have to call the corresponding function in the smart contract with relative arguments
1
vote
2answers
136 views

Where are the API docs for SmartPy?

I'm working on a contract now and specifically I'd like to call a SmartPy API like sp.transfer(address, amount)? Is there a function like this? I can't find API docs for SmartPy and digging into the ...
1
vote
2answers
154 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 ...
1
vote
1answer
36 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
2answers
127 views

Taquito default entrypoint not found

I have deployed a smart contract on carthagenet. The contract only has a single entry point. Taquito is not able to find that single entry point. I tried both default and root methods and it doesn'...
1
vote
1answer
309 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
2answers
82 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
155 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
57 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
2answers
99 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
32 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 ...
1
vote
2answers
121 views

How to get a contract storage data or call a "get" entrypoint from another contract in smartPy?

I want to interact with the FA12.py smart contract (https://smartpy.io/demo/index.html?template=FA1.2.py) and get the balance of a user, from another smart contract. the FA12 function that I tried to ...
1
vote
1answer
29 views

set a ui to allow to nodes interact via smartpy contract

Hii have wrote a smart contract using smartpy where i have two nodes that should interact with each other, now i want to set the user interface to simulate the nodes interact what should i use and ...
1
vote
1answer
84 views

Type error, (sp.TRecord(addr = sp.TAddress)) is not (sp.TUnit) in smartPy

When I implement a getBalance in the FA1.2 function like this: @sp.entryPoint def getBalance(self, params): return self.data.balances[params.addr] As test: scenario += c1.getBalance(addr = ...
1
vote
2answers
86 views

How to total smartpy.TMutez type stored as values in smartpy.bigmap?

I have the following smartpy.bigmap in smart contract storage: import smartpy as sp self.data.init(bgmp=sp.bigmap(tkey=sp.TAddress,tvalue=sp.TMutez)) I would like to total all the stored tvalue so ...
1
vote
1answer
101 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 ...