xJonathanLEI / starkli

Starkli (/ˈstɑːrklaɪ/), a ⚡ blazing ⚡ fast ⚡ CLI tool for Starknet powered by 🦀 starknet-rs 🦀
https://book.starkli.rs
Apache License 2.0
155 stars 43 forks source link

Error: JSON-RPC error: code=-32602, message="Invalid params", data={"reason":"expected value at line 1 column 754"} #74

Closed 2klonghua closed 4 months ago

2klonghua commented 4 months ago

Calling starkli declare target/dev/contracts_Simple_storage.contract_class.json --rpc .... --account .. --keystore

Investigate it further using the --log-traffic and it looks like these params are expected when calling "starknet_estimateFee":

"entry_points_by_type": {
      "CONSTRUCTOR": [],
      "EXTERNAL": [],
      "L1_HANDLER": []
},
xJonathanLEI commented 4 months ago

Hey can you check what spec version your RPC endpoint is serving? starkli spec-version.

2klonghua commented 4 months ago

0.6.0

xJonathanLEI commented 4 months ago

Would you mind posting the content of target/dev/contracts_Simple_storage.contract_class.json so I can reproduce the issue?

2klonghua commented 4 months ago

Here is the original lib.cairo:

Code: `

[starknet::contract]

mod Simple_storage {

#[storage]
struct Storage {
    value: felt252,
}

fn set_value(ref self: ContractState, value: felt252) {
    self.value.write(value);
}

fn get_value(self: @ContractState) -> felt252 {
    self.value.read()
}

} `

I compile it using scarb build, and generate the following json: Result: {"sierra_program":["0x1","0x4","0x0","0x2","0x5","0x4","0x1","0xff","0x0","0x4","0x0"],"sierra_program_debug_info":{"type_names":[],"libfunc_names":[],"user_func_names":[]},"contract_class_version":"0.1.0","entry_points_by_type":{"EXTERNAL":[],"L1_HANDLER":[],"CONSTRUCTOR":[]},"abi":[{"type":"event","name":"contracts::Simple_storage::Event","kind":"enum","variants":[]}]}%

Sorry for the formatting

xJonathanLEI commented 4 months ago

I just tried declaring this exact class on Sepolia using Starkli and it works. Transaction hash: 0x06bf7c26f81dafa1d9ab4b36fabd75bb05806f967dad268d5d0e729dfc520020.

Are you using the latest Starkli version? If so can you post the complete --log-traffic logs?

(You might need to do some renaming on the contract to be able to declare it again, as the network doesn't allow declaring the same class twice)

2klonghua commented 4 months ago

Resolved

2klonghua commented 4 months ago

If it helps, my Scarb.toml configuration are as follows:

` [package] name = "contracts" version = "0.1.0"

[dependencies] starknet = ">=2.2.0"

[[target.starknet-contract]] sierra = true `

xJonathanLEI commented 4 months ago

From your own log:

WARNING: the JSON-RPC endpoint you're using serves specs 0.5.1, which might be incompatible with the version 0.6.0 supported by this Starkli release for the starknet_estimateFee method. You might encounter errors.

Why did you claim that your RPC is 0.6.0 then? Starkli already tells you why it fails with a warning. You need a JSON-RPC 0.6.0 endpoint. Check which RPC version to use with starkli -vv.

Closing this now.

2klonghua commented 4 months ago

I run starkli spec-version earlier which generate 0.6.0

I missed that warning message, my bad. Switched to 0.6.0 and it works now. Thank you

xJonathanLEI commented 4 months ago

I run starkli spec-version earlier which generate 0.6.0

This is quite weird tbh. Maybe this means that whichever API provider you're using load balances traffic across different RPC versions, which sounds like a terrible idea if true. In any case pinning the version is always better. You can also consider using the free RPC vendor feature.