7

While doing the tutorial of "Build the Substrate Kitties Chain" there comes a section https://docs.substrate.io/tutorials/v3/kitties/pt1/#uniqueness-custom-types-and-storage-maps

In this there it says 'Along with this code, we'll need to import serde. Add this to your pallet's Cargo.toml file, using the matching version as Substrate upstream.'

So How to add serde in cargo.toml?

3 Answers 3

4

To add serde in cargo.toml you should go in pallets\kitties\src\cargo.toml and in the [dependencies] section add a line like:

serde = {version="1.0.136", feature= ["derive"]}

Just keep in mind that the version keeps on updating. So You may have to update the version. Currently, on the date of writing this answer version is 1.0.136

1
  • dont you have to disable the std / default features?
    – 0xsegfault
    Mar 17, 2022 at 20:00
3

Run cargo update -p sp-io to fix any problems with version mismatch with Substrate.

1
[dependencies]
serde = "1.0"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.