@polkadot/api -> dedot
Last updated
Was this helpful?
Last updated
Was this helpful?
dedot
is inspired by @polkadot/api
, so both are sharing some common patterns and api styling (eg: api syntax api.<type>.<module>.<section>
). Although we have experimented some other different api stylings but to our findings and development experience, we find that the api style of @polkadot/api
is very intuiative and easy to use. We decide the use a similar api styling with @polkadot/api
, this also helps the migration from @polkadot/api
to dedot
easier & faster.
While the api style are similar, but there're also some differences you might need to be aware of when switching to use dedot
.
@polkadot/api
dedot
Below is a few examples showing the differences between dedot
& @polkadot/api
when accessing the on-chain data/information.
Example 1:
Example 2:
Example 3:
Unlike @polkadot/api
where data are wrapped inside a , so we always need to unwrap the data before using it (e.g: via .unwrap()
, .toNumber()
, .toString()
, .toJSON()
...). dedot
leverages the native TypeScript type system to represent scale-codec types, so you can use the data directly without extra handling/unwrapping.
More information on how Dedot lerverage Typescript type system to represent (Rust) data types can be found .