4

I'm trying to call a view method to retrieve a Vec of u128 values and I'm getting this error as a result I'm not sure what to make of it can someone help me?

{
  "block_hash": "76auef76bmvvKT6kVZabiCrrHeTzoBP2vxGZGqaBjDc1",
  "block_height": 54564995,
  "error": "wasm execution failed with error: FunctionCallError(HostError(GuestPanic { panic_msg: \"Cannot deserialize value with Borsh\" }))",
  "logs": []
}
    at JsonRpcProvider.query (json-rpc-provider.js:116)
    at async ConnectedWalletAccount.viewFunction (account.js:356)
    at async <anonymous>:1:1
TypedError @ errors.js:18
query @ json-rpc-provider.js:116

Thank you for your help!

Elias Holzmann
  • 3,216
  • 2
  • 17
  • 33
Dorian Crutcher
  • 381
  • 2
  • 7

2 Answers2

4

My wild guess is that you re-deployed a contract where you changed the structure of the state struct (the one that is marked with #[near_bindgen]). Thus, when you call any method, it fails to deserialize the existing state to the new structure. If that is the case, you have a few options:

Vlad Frolov
  • 7,445
  • 5
  • 33
  • 52
  • even after redeploying I get this error. – Suisse Nov 10 '22 at 20:51
  • @Suisse the whole point is that it was triggered by redeployment of a non-compatible contract. Please, read the recommendations in the answer – Vlad Frolov Nov 12 '22 at 09:47
  • What does it mean: non-compatible contract? It was compatible before.. I didn't change anything on the contract, only changed the deployer computer – Suisse Nov 15 '22 at 18:20
0

Emphasizing on Vlad Frolov's answer, if you are in dev mode, deleting everything (neardev directory, target directory, etc...) then rebuilding&redeploying is a viable option; works for me. NEAR redeploys the same contract multiple times and one easily mixes up the state. Can be as easy as changing some function parameter names and you get serialization/deserialization errors, if not done carefully.

Hadi Saleh
  • 21
  • 1