https://smartpy.io/ https://twitter.com/smartpy_io
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'
# 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'
# 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'.Читать полностью…
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
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)
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"
}
}
]
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
Читать полностью…Hi, welcome here.
The import is expected inside the module.
@sp.module
def main():
import smartpy.contract_utils as contract_utils
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.
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.
Читать полностью…Please, consider retweet or like https://x.com/smartpy_io/status/1902651838303769069
Читать полностью…and llms it'S not really helpful because the new syntax -
Читать полностью…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 --- ,,,, ///
Читать полностью…you mean like this ? _https://smartpy.io/ide?cid=QmWNwew5ik6orFvWvJGHsQB1JCCVzjbvtxa9js6mnC2JLm&k=9acb99ca9e91ecbbb54c
Читать полностью…and I agree with @kspr9 .. a website AI assistant like taquito did would be very cool 👀
Читать полностью…Jordan
Would appreciate some feedback when it's convenient for you, thanks
You can wrap pending_rewards = sc.compute(staking.get_pending_rewards(...), _now=...)
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'Читать полностью…
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.
📣 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. 🚀
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
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.
📣 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.
I am sorry - but don't understand the doc - https://smartpy.io/manual/data-types/lists-sets-and-maps -
Читать полностью…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)
.
sorry @jordan still though I try hard to understand - I still dont get your advice
Читать полностью…Awesome, thank you so much for the step by step and instructions. That for sure will be a gamechanger to speed up things here!
Читать полностью…