failed to resolve: use of undeclared crate or module `imp`

I have one more question: when I run cargo build-sbf, it reports a get random error; could you tell me how to fix it?

$ cargo build-sbf
    Compiling getrandom v0.2.7
error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> src/lib.rs:240:9
    |
240 | / compile_error!("target is not supported, for more information see: \
    | |                https://docs.rs/getrandom/#unsupported-targets");
    | |_______________________________________________________________^

error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> src/lib.rs:262:5
    |
262 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared crate or module `imp`

For more information about this error, try `rustc --explain 0433`.
error: could not compile getrandom due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed

The second error here is a little misleading - the real error is the first one:

Solana doesn't have support for random sources. Non-determinism would be catastrophic in the context of a blockchain. You will need to rewrite your thing to not depend on randomness.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.