How Do You Troubleshoot the Cargo/Rust Error “use of undeclared type or module”?

Problem Scenario
You run a "cargo run" command. You get an error like one or more of the following:

use of undeclared type or module api

use of undeclared type or module serde_json

use of undeclared type or module async-std

What should you do?

Update the Cargo.toml file. The dependencies section should have an entry like one of the following (but the version number may or may not differ):

name = "in3-tutorial"
version = "0.0.1"
authors = [""]
edition = "2018"

in3 = "0.1.7"
async-std = "1.5.0"
futures-executor = "0.3.5"
serde_json = "1.0"
ethabi = "13.0.0"
ethereum_abi = "0.2.0"
ethbloom = "0.10.0"

name = "in3"
path = "/home/jdoe/rust/"

If you are not sure what version is valid, go here:

Leave a comment

Your email address will not be published. Required fields are marked *