Is there any example of a substrate node made using Leptos?
Writing the front-end in Rust instead of typescript or Javascript
seems to be a good idea…
Kazu
use anyhow::anyhow;
use js_sys::Promise;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::fmt::Write;
use subxt::ext::codec::{Compact, Encode};
use subxt::{self, OnlineClient, PolkadotConfig};
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;
use yew::{AttrValue, Callback};
#[subxt::subxt(runtime_metadata_path = "../../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}
pub(crate) async fn fetch_constant_block_length() -> Result<String, subxt::Error> {
let api = OnlineClient::<PolkadotConfig>::new().await?;
let constant_query = polkadot::constants().system().block_length();
let value = api.constants().at(&constant_query)?;
Ok(format!("{value:?}"))
This file has been truncated. show original
this example is done with yew.rs but you’ll get the drill and easily adapt it to any other rs-frontend-framework.
to use rpc node instead running one locally you can set url to OnlineClient to get started.
let url = "wss://rpc.ibp.network/kusama";
let api = OnlineClient::<PolkadotConfig>::from_url(url).await?;
1 Like