near / near-cli

General purpose command line tools for interacting with NEAR Protocol
https://docs.near.org
MIT License
193 stars 93 forks source link

Having called my smart contract code several times from a React front-end, I'm getting this error severally #993

Closed morarafrank closed 2 years ago

morarafrank commented 2 years ago

"Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error("missing field first_candidate", line: 1, column: 2)', src/lib.rs:114:1"}}

willemneal commented 2 years ago

This error is saying that the JSON sent to the contract was missing a required key here first_candidate. Can you share your full command?

morarafrank commented 2 years ago

near call abc.testnet get_first_candidate abc.testnet

willemneal commented 2 years ago

You need to serialize the call in JSON:


near call abc.testnet get_first_candidate '{"first_candidate": "abc.testnet" }'

Currently you are pass abc.testnet as the whole argument.

morarafrank commented 2 years ago

Thanks @willemneal . It worked. Seems I was not passing the whole argument.