https://smartpy.io/ https://twitter.com/smartpy_io
Sure! Thanks and seems like instructions-for-llms.md is sort of to the direction. Example I gave is one that I found and consider very useful especially since Svelte 5 upgrade is not reflected in the training data (cutoff dates etc) of LLMs so far, and this approach helps to overcome this gap. So my intention was to provide this as an inspiration. You could also consider making like a .cursorrules file. Although that might be too Cursor specific
Overall, great to hear you are already thinking this about this!
Hey, I'm considering to do this.
In the meantime, I can suggest you 3 things for cursor (you may adapt if you use another tool):
1) Download the templates from https://gitlab.com/smartpy.io/smartpy/-/tree/main/templates?ref_type=heads and add them to your workspace or to cursor index.
2) Add the SmartPy documentation to the @docs. The entrypoint is https://smartpy.io/manual/introduction/overview and the prefix is https://smartpy.io
3) See instructions-for-llms.md. I wrote it on the fly few days ago, that's not comprehensive nor well written (in particular, I'm not respecting the cursor rules syntax) but you can also add it to the context and the LLM will take it into account.
Thank you for this question!
Hi folks, first message here. I’m starting to study sp again after a while, and like before I realized that chatGPT, Claude etc are suggesting me the old sp syntax. Is there any AI assistant around with the new syntax/docs updated?
Читать полностью…yes, at compile time, for instance you could add a sibling directory contracts/originator
containing the files Originator.spy
and another test_harness.py
with
# Originator.spy
import smartpy as sp
import contracts.contract_B.B as B
class Originator(sp.Contract):
@sp.entrypoint
def ep(self):
_ = sp.create_contract(
B.ContractB,
None,
sp.tez(0),
sp.record(result=0, administrators={}),
)
# test_harness.py
# we are in a .py file so this is all normal python code
import smartpy as sp
@sp.add_test()
def test():
# Create the scenario
scenario = sp.test_scenario(name="Test")
# need to add_module - which is just like importing - but returns a handle we can use in the test
O = scenario.add_module("./Originator.spy")
contract = O.Originator()
scenario += contract
scenario.h2("My Test suite")
# creates a dynamic contract
contract.ep()
# our test scenario needs a handle to B module so that we can use it in the dynamic contract call
B = scenario.add_module("contracts/contract_B/B.spy")
# gets the most recently created dynamic contract
b = scenario.dynamic_contract(B.ContractB)
b.add(sp.record(x=1, y=2))
scenario.verify(b.data.result == 3)
sp.create_contract
call wrong, for instance if you got the storage initialising wrong. Which maybe answers your other question? The storage you give to the sp.create_contract
has to be compile time correct for the contract you are creating dynamically - but that has always been the case, as the CREATE_CONTRACT
michelson that is generated has to be typed correctly.
Читать полностью…
Ok, and so if i'd have contract a that has an entrypoint to deploy contract b that imports modules and uses type definitions, functions defined in those imported modules, then those all would be handled at compile time? Just to understand, can you define a storage of a contract as well depending what modules you are importing? Or it's just functions, entrypoints, types etc?
Читать полностью…I've been wondering how do you deploy/originate a contract that imports another contract like previously?
I've done and deployed a contract that is able to originate another, but in that case the code of both contracts are in the same main module.
Thank you @karoshibee for your reply
I tried that and now I’m getting the following error:
python3 test_contract_A.py
Traceback (most recent call last):
File "/workspaces/smart-contract/contracts/contract_A/test_contract_A.py", line 4, in <module>
@sp.add_test()
File "/workspaces/smart-contract/contracts/contract_A/test_contract_A.py", line 7, in test
pool_module = scenario.add_module(“./A.spy")
FileNotFoundError: contracts.contract_B.B.spy
Hello everyone, I have a question.
I have a contract, let’s call it A (stored as `contracts/contract_A/A.spy`), and I want to import another contract, B (stored as `contracts/contract_B/B.spy`), so they are not stored in the same directory.
How can I do that? I have tried using the from … import
statement in different ways, but I keep getting the error:
SyntaxError: Not a module statement
Hey Jordan, hope you are doing good, it's been a long time.
I'm facing a error while deploying the Michelson code
below is the error
failed(permanent: proto.021-PsQuebec.michelson_v1.ill_typed_data), (permanent: proto.021-PsQuebec.michelson_v1.invalid_constant), (permanent: proto.021-PsQuebec.michelson_v1.invalid_constant), (permanent: proto.021-PsQuebec.michelson_v1.invalid_constant), (permanent: proto.021-PsQuebec.michelson_v1.invalid_constant), (permanent: proto.021-PsQuebec.michelson_v1.invalid_constant), (permanent: proto.021-PsQuebec.destination_repr.invalid_b58check)
What I'm trying to do here is cloning the USDT mainnet contract to ghostnet for testing purpose
📣 We have released a new SmartPy alpha v0.21.0a1 ! 📣
This release includes
* a brand new Jupyter Notebook web app for writing and running SmartPy code,
* an updated public repository for SmartPy releases,
* improvements to SmartPy syntax including Python's match/case syntax, type hints, set notation and more,
* updating the default protocol choice to Tezos Quebec.
Please see the release notes for more info
🚀 🔥 🎉
contractCall = sp.build_lambda(makeContract,
with_operations=True,
with_exceptions=False,
with_mutez_overflow=False,
with_mutez_underflow=False)
but now it's unclear how I would call this entry point at all... https://better-call.dev/ghostnet/KT1LgAbxgJ7GpvRdctFyNaLeYtQvCF3vsuBD/interact/callContract
Читать полностью…I think the solution/understanding lies in the fuction of "params" in the example
Читать полностью…it works but I can't cast it inside the entry point since I need it to be "pre casted" or just something the contract can just ()
Читать полностью…We'll have a look at this. I can't promise a date but it's definitely something to consider. Thank you for your suggestions.
Читать полностью…I have been actually thinking the same thing. Taquito has quite nice chat on their website, although it's very basic and limited in the sense, it works and helps to get quick answers.
I've also found this example
https://svelte-llm.khromov.se/
Are you considering compiling any documentation into an AI digestible format?
For example, if contract a deployes a slightly different contract depending what kind of user it is for, could I customise a storage for that to-be-deployed contract by importing different module? Or should i just have let's say two contract templates directly within my main module?
Читать полностью…Hello, if you're talking about importing modules and then using the contracts/type definitions/functions defined within then that is a compile-time consideration, so it is all "sorted out" by the time smartpy gets to generate the final michelson contract. So you should just be able to originate that final contract as usual.
You can see this with the previous example.tar.gz
if you add an entrypoint to ContractB
in contracts/contract_B/B.spy
and then compile test_a_b.py
; you should see the entrypoint code in the outputted michelson contract file Test/step_001_cont_0_contract.tz
.
Good morning, I took a guess as to the directory setup you probably have and came up with example.tar.gz - there are inline comments and a description of the setup I tested it with - I hope that helps?
Читать полностью…Hi there, the from ... import
form of importing isnt supported, it would be import contracts.contract_A.A as a
and import contracts.contract_B.B as b
. The filepath resolution is then performed as described here: https://releases.smartpy.io/0.19.2a4/manual/syntax/modules#filepath-resolution
Hey, it reminds me this error: https://tezos.stackexchange.com/questions/5951/invalid-b58check-error-while-originating-contract/5952#5952
Can you have a look at that?
In 2025 we will be gradually deprecating the legacy SmartPy web app starting with the legacy contract explorer at legacy.smartpy.io/explorer - please use the main explorer at smartpy.io/explorer going forward.
Читать полностью…into that contract call on bcd (or more generally any front end)
Читать полностью…def set_42(params):
administrated = sp.contract(sp.int, c2.address, entrypoint="set_value")
sp.transfer(sp.int(42), sp.tez(0), administrated.unwrap_some())
maybe it's just this: expects parameter of type sp.unknown, but got sp.lambda_(sp.unknown, **sp.unknown**, with_storage="no-access"... but got sp.lambda_(sp.unknown, **sp.unit**,
Читать полностью…> sp.cast(params.contractLambda, sp.lambda_(sp.record (
card = sp.nat,
gameId = sp.nat,
hash = sp.string
), sp.unit,
with_storage="no-access",
with_operations=True,
with_exceptions=True,
with_mutez_overflow=True,
with_mutez_underflow=True))
params.contractLambda(params.contractParams)