smartpy_io | Unsorted

Telegram-канал smartpy_io - SmartPy

429

https://smartpy.io/ https://twitter.com/smartpy_io

Subscribe to a channel

SmartPy

Jordan I tried it.
Still getting error

1.

# Show Pending Rewards
sc.h2("Show Pending Rewards")
pending_rewards = sp.compute(
staking.get_pending_rewards(Addresses.alice, _now=sp.timestamp(2))
)
sc.show(pending_rewards)

TypeError: View.__call__() got an unexpected keyword argument '_now'


2.
# Show Pending Rewards
sc.h2("Show Pending Rewards")
pending_rewards = sp.compute(
staking.get_pending_rewards(Addresses.alice), _now=sp.timestamp(2)
)
sc.show(pending_rewards)

TypeError: compute() got an unexpected keyword argument '_now'

3.
# Show Pending Rewards
sc.h2("Show Pending Rewards")
pending_rewards = sc.compute(
staking.get_pending_rewards(Addresses.alice), _now=sp.timestamp(2)
)
sc.show(pending_rewards)

TypeError: Scenario.compute() got an unexpected keyword argument '_now'.

Читать полностью…

SmartPy

How do you handle tickets stored in a map where key is sp.address and value is the ticket for an entrypoint that receives the ticket and should store it in the map?

Especially you would need to account for the case where there could be an existing ticket from the same issuing contract, so you would want to join the existing ticket with the received ticket, but when there are no previous tickets for the issuing contract, you want to create a new entry in the map?

I am having troubles handling this case as I continuously encounter error — "...cannot be used twice because it contains a ticket."

For example this:

@sp.entrypoint
def receive_shares(self, payload):
"""
Args:
payload:
issuer (sp.address): The address of the contract that originally issued the ticket.
ticket (sp.ticket): The ticket being received.
"""
sp.cast(payload.issuer, sp.address)
sp.cast(payload.ticket, ShareTicketType)

# Store the received ticket, keyed by its original issuer.
# If some tickets already exist, join existing with newm if not, store ticket in wallet
with sp.modify_record(self.data) as data:

(option_ticket, share_balances) = sp.get_and_update(payload.issuer, None, data.held_external_shares)
data.held_external_shares = share_balances
#data.held_external_shares[payload.issuer] = payload.ticket

match option_ticket:
case Some(t):
(ticket_data, held_ticket) = sp.read_ticket(t)
data.held_external_shares[payload.issuer] = sp.join_tickets(held_ticket, ticket)
case None:
data.held_external_shares[payload.issuer] = ticket

Читать полностью…

SmartPy

This is the test I have written

# Show Pending Rewards
sc.h2("Show Pending Rewards")
pending_rewards = staking.get_pending_rewards(Addresses.alice, _now=sp.timestamp(2))
sc.show(pending_rewards)

Читать полностью…

SmartPy

Can you share your code?

Читать полностью…

SmartPy

Hi, testing my contracts.
Weird thing happened.
Once call was successful. But another just like the previous one fails.

"operation_result": {
"status": "failed",
"errors": [
{
"kind": "temporary",
"id": "proto.021-PsQuebec.michelson_v1.runtime_error",
"contract_handle": "KT1HyojJMK6CqfYtsjERiXXFC5XGrq1JELqX",
"contract_code": "Deprecated"
},
{
"kind": "temporary",
"id": "proto.021-PsQuebec.michelson_v1.script_rejected",
"location": 487,
"with": {
"int": "349"
}
}
]

Читать полностью…

SmartPy

dear group ll this thing with new syntax it's been very demanding - but thanks for the tip using cursor - even though . I still tappiing in the darkness _ I would like to have a tier based pricing defined . and entrypoint to view the actual price from frontend - But i get an error for the calculate price function .- do you have a hint ? : https://smartpy.io/ide?cid=QmbFgsHFt5vbzatZ3ngiVzoVNNWex33crgvPvthuegaxs2&k=04fbc5be74e39d196753 - thanks

Читать полностью…

SmartPy

Hi, welcome here.
The import is expected inside the module.

@sp.module
def main():
import smartpy.contract_utils as contract_utils


I just remarked that this contract_utils has a bug. I'll fix it in the next release.

Читать полностью…

SmartPy

thank's...Jordan 😁

Читать полностью…

SmartPy

There is no smartpy command (there was one is an older version).
You can write your contract like explained in the tutorial or download one with wget https://smartpy.io/templates/welcome.py.
Then to execute it you call python welcome.py (replace welcome by your contract name).
You should see the generated files like explained in the installation documentation.

Читать полностью…

SmartPy

i created a virtual environment inside which, i install smartpy using the same command, the installation done well, but the command ''smartpy —version'' don't work.

Читать полностью…

SmartPy

Please, consider retweet or like https://x.com/smartpy_io/status/1902651838303769069

Читать полностью…

SmartPy

and llms it'S not really helpful because the new syntax -

Читать полностью…

SmartPy

I appreciate your suggestion - But I just don't have so much time to do such a contract maybe - I though it woudl be more accesible -> but thanks for advice. Since the contract it's for an artistic work, it is also flexible - and I thniking about to reduce to just to a price to mint for everybody but admin - the thing with the whitelist is complicated - because the list would have to be dynamic - and when I see the ! boilerplate --- ,,,, ///

Читать полностью…

SmartPy

you mean like this ? _https://smartpy.io/ide?cid=QmWNwew5ik6orFvWvJGHsQB1JCCVzjbvtxa9js6mnC2JLm&k=9acb99ca9e91ecbbb54c

Читать полностью…

SmartPy

and I agree with @kspr9 .. a website AI assistant like taquito did would be very cool 👀

Читать полностью…

SmartPy

Jordan
Would appreciate some feedback when it's convenient for you, thanks

Читать полностью…

SmartPy

You can wrap pending_rewards = sc.compute(staking.get_pending_rewards(...), _now=...)

Читать полностью…

SmartPy

Jordan

While testing onchain views,
How can we pass current time?
I tried using _now in view call, but getting error

TypeError: View.__call__() got an unexpected keyword argument '_now'

Читать полностью…

SmartPy

Any help would be appreciated

Читать полностью…

SmartPy

I made some changes: https://smartpy.io/ide?cid=QmPwWX2FyAYuBnh7pejWiC9eFJcFkBgwYFcpbcrxpyJayh&k=9afefd13788196a7c4aa

- Within a module you can call a function by providing its name directly, not by referencing the module name.
- For now, module functions can only be called by naming arguments and wrapping it with sp.record
- You cannot return in a method if there is code after it so I added a else in your method

I let you investigate the error.

Читать полностью…

SmartPy

📣 We have released a new SmartPy alpha v0.22.0a1! 🎉

https://releases.smartpy.io/0.22.0a1

This alpha release includes
* The proposed Rio protocol as a choice for protocols, Oxford protocol is removed & we've updated to octez-client 22.0-rc3.
* Auto-import modules when instantiating a scenario.
* Can return origination_result and call_result values to Python.
* Updated documentation to include the tutorials from docs.tezos.com plus more documentation for type hints & for catching exceptions in SmartPy.

Please see the release notes (https://releases.smartpy.io/0.22.0a1/releases) for more details. 🚀

Читать полностью…

SmartPy

Hi
I am new to this group. Trying to write some smartpy smart contract. Appreciate the help.

If i try to execute the following from the sample jupyter notebook
import smartpy.contract_utils as cu
or
import smartpy.contract_utils as cu

both of which end up with error : NO module namd smartpy.contract_utils

Читать полностью…

SmartPy

By the way, welcome to Tezos @Neudjieu

Читать полностью…

SmartPy

any help will be very nice...

Читать полностью…

SmartPy

Hi everyone, it's my firts with tezos. After installation of smartpy library on Ubuntu 24.04, when i perfom "smartpy --version", i get "smartpy : commande introuvable".
i used this commande "pipx install https://smartpy.io/static/tezos_smartpy-0.21.1-py3-none-any.whl" because with pip the are conflicts.

Читать полностью…

SmartPy

📣 We have released a new SmartPy version v0.21.0!

This release includes

- a Jupyter Notebook web app
- an updated public repository
- improvements to SmartPy syntax
- default protocol to Tezos Quebec
- a new documentation website.

Please see the release notes.

Читать полностью…

SmartPy

I am sorry - but don't understand the doc - https://smartpy.io/manual/data-types/lists-sets-and-maps -

Читать полностью…

SmartPy

You should start with a small example. I suggest you to empty the editor and write "!" and then click on boilerplate.

In the constructor you want to to save a list of addresses.
To do that you can use a big map (see the documentation for more info). I explained in a previous message how to initialize it.

Then you can create an entrypoint to add people to that whitelist.
The entrypoint can be self.data.whitelist[sp.sender] = ().

Then you can create an entrypoint that only accepts call with 5 tez or 0 tez for people who are in the whitelist.
if not self.data.whitelist.contains(sp.sender): and then assert sp.amount = sp.tez(5).

Читать полностью…

SmartPy

sorry @jordan still though I try hard to understand - I still dont get your advice

Читать полностью…

SmartPy

Awesome, thank you so much for the step by step and instructions. That for sure will be a gamechanger to speed up things here!

Читать полностью…
Subscribe to a channel