starknet-edu / deploy-cairo1-demo

47 stars 23 forks source link

failed to declare contract which is compiled by "Scarb" #11

Open Ljiacheng opened 1 year ago

Ljiacheng commented 1 year ago

I build a contract which is compiled by Scarb. And I get a file named "hello_HelloStarknet.sierra.json" with command scarb --release build for example. When I use command starknet declare --contract target/release/hello_HelloStarknet.sierra.json, I get this error:

scarb version:

scarb 0.2.0-alpha.2 (f9c07ce68 2023-05-05)
cairo: 1.0.0-rc0 (https://crates.io/crates/cairo-lang-compiler/1.0.0-rc0)

starknet version:

starknet 0.11.0.2
Sending the transaction with max_fee: 0.000001 ETH (1378300000000 WEI).
Got BadRequest while trying to access https://alpha4.starknet.io/gateway/add_transaction. Status code: 500; text: {"code": "StarknetErrorCode.COMPILATION_FAILED", "message": "Compilation failed. Error: Invalid Sierra program.\n"}.
Traceback (most recent call last):
  File "/home/ljc/cairo_venv_v11/lib/python3.9/site-packages/services/external_api/client.py", line 187, in _send_request
    return await self._parse_response(
  File "/home/ljc/cairo_venv_v11/lib/python3.9/site-packages/services/external_api/client.py", line 231, in _parse_response
    raise BadRequest(status_code=response.status, text=text)
services.external_api.client.BadRequest: HTTP error ocurred. Status: 500. Text: {"code": "StarknetErrorCode.COMPILATION_FAILED", "message": "Compilation failed. Error: Invalid Sierra program.\n"}
Error: BadRequest: HTTP error ocurred. Status: 500. Text: {"code": "StarknetErrorCode.COMPILATION_FAILED", "message": "Compilation failed. Error: Invalid Sierra program.\n"}
Ljiacheng commented 1 year ago

By the way, with a file tree:

.
├── Scarb.toml
├── cairo_project.toml
└── src
    ├── hello_starknet.cairo
    ├── interface.cairo
    └── lib.cairo

I don't known how to build a [contract].json file with "starknet-compile"

asoong commented 1 year ago

You can follow these steps to pull a more recent version of the cairo package which includes the compiler but use 1003d5d14c09191bbfb64ee318d1975584b3c819 instead of the documented commit sha.

Don't forget to apply the troubleshooting section as needed.