Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NEAR smart contract rust Error: "Cannot deserialize value with Borsh"

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!

like image 447
Dorian Crutcher Avatar asked Oct 27 '25 12:10

Dorian Crutcher


1 Answers

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:

  • Wipe and start from scratch (use a new account or delete/create the existing one)
  • Implement the state migration: In NearProtocol, how to migrate contract state
like image 178
Vlad Frolov Avatar answered Oct 30 '25 06:10

Vlad Frolov