diff --git a/Cargo.lock b/Cargo.lock
index c44e2c435ea5..f5a651705ab2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -13743,6 +13743,7 @@ dependencies = [
"polkadot-runtime-parachains",
"primitive-types",
"scale-info",
+ "sp-api",
"sp-arithmetic",
"sp-io",
"sp-runtime",
diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml
index 337c6e961e05..370f26b79d85 100644
--- a/xcm/xcm-builder/Cargo.toml
+++ b/xcm/xcm-builder/Cargo.toml
@@ -12,6 +12,7 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive"
xcm = { path = "..", default-features = false }
xcm-executor = { path = "../xcm-executor", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
+sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -43,6 +44,7 @@ std = [
"xcm/std",
"xcm-executor/std",
"sp-std/std",
+ "sp-api/std",
"sp-arithmetic/std",
"sp-io/std",
"sp-runtime/std",
diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs
index eaf6d636795e..ba2d9ce763db 100644
--- a/xcm/xcm-builder/src/lib.rs
+++ b/xcm/xcm-builder/src/lib.rs
@@ -83,3 +83,6 @@ pub use universal_exports::{
HaulBlobError, HaulBlobExporter, NetworkExportTable, SovereignPaidRemoteExporter,
UnpaidLocalExporter, UnpaidRemoteExporter,
};
+
+mod runtime_api;
+pub use runtime_api::*;
diff --git a/xcm/xcm-builder/src/runtime_api.rs b/xcm/xcm-builder/src/runtime_api.rs
new file mode 100644
index 000000000000..421a924798e3
--- /dev/null
+++ b/xcm/xcm-builder/src/runtime_api.rs
@@ -0,0 +1,44 @@
+// Copyright Parity Technologies (UK) Ltd.
+// This file is part of Polkadot.
+
+// Polkadot is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Polkadot is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Polkadot. If not, see .
+
+//! Runtime API definition for fungibles.
+//!
+//! (Initial version: https://github.com/paritytech/cumulus/pull/2180#issuecomment-1442952274)
+
+use frame_support::RuntimeDebug;
+use parity_scale_codec::{Codec, Decode, Encode};
+use sp_std::vec::Vec;
+use xcm::latest::MultiAsset;
+
+/// The possible errors that can happen querying the storage of assets.
+#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)]
+pub enum FungiblesAccessError {
+ /// `MultiLocation` to `AssetId`/`ClassId` conversion failed.
+ AssetIdConversionFailed,
+ /// `u128` amount to currency `Balance` conversion failed.
+ AmountToBalanceConversionFailed,
+}
+
+sp_api::decl_runtime_apis! {
+ /// The API for querying account's balances from runtime.
+ pub trait FungiblesApi
+ where
+ AccountId: Codec,
+ {
+ /// Returns the list of all [`MultiAsset`] that an `AccountId` has.
+ fn query_account_balances(account: AccountId) -> Result, FungiblesAccessError>;
+ }
+}