首页 > 解决方案 > 调用 Rust 初始化函数时出现“无法反序列化合约状态”

问题描述

我已经能够near dev-deploy使用近壳来运行Rust 合约,然后调用一个函数“new”near call my-account new '{"param1": "foo"}'

但是,当我将相同的合同部署到使用NEAR Wallet创建的首选帐户时,这不起作用。

错误是:

Smart contract panicked: panicked at 'Cannot deserialize the contract state.: Custom { kind: InvalidInput, error: "Unexpected length of input" }',

标签: rustnearprotocol

解决方案


事实证明,在同一账户/地址更新合约时,区块链世界中存在一个常见问题。这里的解决方案是删除并重新创建帐户。我曾经near-shell删除它,然后使用 Wallet 重新创建它。

在命令行上:

near delete my-account another-account-getting-the-tokens

然后通过访问再次创建帐户: https ://wallet.nearprotocol.com/create/

这清除了状态,我能够重新部署合同并运行init“新”功能


推荐阅读