调用 Rust init 函数时出现“无法反序列化合约状态”

Mik*_*vis 7 rust nearprotocol

我已经能够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" }',
Run Code Online (Sandbox Code Playgroud)

Mik*_*vis 6

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

在命令行上:

near delete my-account another-account-getting-the-tokens
Run Code Online (Sandbox Code Playgroud)

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

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

  • 惊人的!另一种解决方案是创建当前为主帐户的子帐户,然后更改 config.js 中的 CONTRACT_NAME (2认同)