https://smartpy.io/ https://twitter.com/smartpy_io
Hello, I am using the online SmartPy IDE, but I am encountering some errors. Specifically, I am getting the error "AttributeError: module 'smartpy' has no attribute 'Contract'," and I am unable to use it. I have also encountered changes in the way contracts should be defined. I would like to know if there has been a recent update that might be incompatible with older code, or if there is an alternative way to define contracts.
I would appreciate it if you could look into my issue and provide a solution.
Thank you.
also I would make sure to use an up to date octez-client
as the smartpy RPCs recently upgraded to v21
> Access to fetch at 'https://ghostnet.smartpy.io/keys/tz2NBt7dzqEzJjVg9KfGV8A7KDcQiqtEsbMR' from origin 'http://192.168.1.104:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Читать полностью…if it still doesnt work when published on heroku I'd have a look at whether there are extra steps you need to do for CORS support on that platform
Читать полностью…Trying to minimize noise here but it's def a cors issue even after deploying to heroku, no idea how the fuck this is happening
Читать полностью…> tz2NBt7dzqEzJjVg9KfGV8A7KDcQiqtEsbMR https://ghostnet.smartpy.io/
localhost/:1 Access to fetch at 'https://ghostnet.smartpy.io/keys/tz2NBt7dzqEzJjVg9KfGV8A7KDcQiqtEsbMR' from origin 'http://localhost:3002' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Using print(contract.data.value)
gives weird data and not the actual value.sp.show
prints in log.txt
I want in Compiler.
What can be the issue here?
Code
@sp.private(with_storage="read-write")
def _claim(self, address):
# Return 0 if user has no stakes
if not self.data.stakes.contains(address):
return sp.nat(0)
TypeError_: (SmartPy)Читать полностью…
File "staking.py", line 154, in <module>
return sp.nat(0)
'return' in non-terminal position.
Also, is there any way to see HTML view of tests as we had in legacy or on online ide?
Its difficult to debug using the log.txt file.
Thank you, I see the problem, the set syntax is still old in the test scenario. You'll have to use sp.set([x1, x2, ...])
. That will be fixed in the next version.
Thanks, in the end I just had bad smartpy contract and prefer the smartpy/ide as it's one less wheel I have to reinvent
Читать полностью…do you still get the 403 with setting the rpc to another e.g. https://rpc.tzkt.io/ghostnet ?
Читать полностью…> Error3: {
"value": {
"mutezPerMove": 100,
"player": "tz2NBt7dzqEzJjVg9KfGV8A7KDcQiqtEsbMR"
},
"token": {
"val": {
"prim": "nat",
"annots": [
"%mutezPerMove"
]
},
"idx": 0
},
"name": "NatValidationError",
"message": "[mutezPerMove] Value is not a number: {\"mutezPerMove\":100,\"player\":\"tz2NBt7dzqEzJjVg9KfGV8A7KDcQiqtEsbMR\"}"
}
hmm yeah, it's def CORS, I can get to the contract(Methods).entryPointName(params).send() and when I don't get a Michelson TypeError with either methods or contractMethods I go straight to the CORS error when running both locally and after publishing to Heroku
Читать полностью…Yep, maybe worth checking you can configure the service to allow CORS and then check can run it locally first, then move to heroku and check it still works?
Читать полностью…I think that you need to allow cross-origin requests at your end? I don't believe it's a smartpy RPC issue.
Читать полностью…I don't have a smartpy.io question but does anyone know whot to get around teh smartypy.io CORS policy when trying to interact with contract via a dApp?
Читать полностью…We can't use sp.trace
in tests??
How can we display output in console from tests?
In Michelson and therefore in SmartPy you cannot return in a if
branch without returning in the else
.
See https://smartpy.io/manual/introduction/differences#functions.