I want to get the bool value from the flipper contract. I use Rust and subxt. But I cannot convert it to a primitive type.

    let value: bool = api
        .map_err(|err| ErrorInternalServerError(err))?
        .map_err(|err| ErrorInternalServerError(err))?;

I have tried the conv and into methods. Also the decode but no luck. The error I'm seeing is:

error[E0277]: the trait bound `bool: std::convert::From<&frame_metadata::v14::StorageEntryMetadata<PortableForm>>` is not satisfied
  --> src/controllers/polkadot.rs:55:10
55 |         .into();
   |          ^^^^ the trait `std::convert::From<&frame_metadata::v14::StorageEntryMetadata<PortableForm>>` is not implemented for `bool`
   = help: the following implementations were found:
             <bool as std::convert::From<core_foundation::boolean::CFBoolean>>
             <bool as std::convert::From<parity_wasm::elements::primitives::VarUint1>>
             <bool as std::convert::From<subtle::Choice>>
   = note: required because of the requirements on the impl of `Into<bool>` for `&frame_metadata::v14::StorageEntryMetadata<PortableForm>`

Also without into:

   = note: `?` operator cannot convert from `&frame_metadata::v14::StorageEntryMetadata<PortableForm>` to `bool`
   = note:   expected type `bool`
           found reference `&frame_metadata::v14::StorageEntryMetadata<PortableForm>`
  • 1
    What is the error you see?
    – Shawn Tabrizi
    Commented Apr 23, 2022 at 7:29
  • @ShawnTabrizi The error I'm seeing is now updated. Commented Apr 23, 2022 at 8:57
  • 1
    why are you calling metadata() if you are trying to access storage?
    – Shawn Tabrizi
    Commented Apr 23, 2022 at 16:39
  • @ShawnTabrizi Because I need a StorageEntry for for the fetch function: docs.rs/subxt/latest/subxt/storage/… Commented Apr 24, 2022 at 5:36
  • 1
    @ShawnTabrizi is right, what you are doing here is reading from the metadata() definition itself. See my answer for how to do what you want Commented Apr 25, 2022 at 8:27

1 Answer 1


I want to get the bool value from the flipper contract

In order to read the return value of a contract message, you need to invoke it via RPC, a so called "dry-run", since calling it via a transaction will not return a value.

You would need to construct a request and then call the "contracts_call" rpc method. At the current time there is no library available to do this, you would have to copy code from cargo-contract

If on the other hand you did want to invoke a state changing contract transaction with subxt (e.g. flip in your case) you will need to invoke call on the contracts pallet e.g.:


data will need to be populated with the selector of the contract message, together with the encoded args. The code above is copied from cargo-contract.

If you are just experimenting and don't want to integrate the above calls into your codebase, I recommend using cargo-contract to interact with the contract during development.

Your Answer

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

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