docs ⦿ dedot 🧑‍💻
TypinkXTelegramGithub
dedot 🧑‍💻
dedot 🧑‍💻
  • Welcome to Dedot
  • Why Dedot?
  • Getting started
    • Installation
    • Connect to network
    • @polkadot/api -> dedot
    • Packages structure
  • Clients & Providers
    • Providers
    • Clients
  • Client API
    • ChainApi
    • Constants
    • Runtime APIs
    • Storage Queries
    • Transactions
    • Events
    • Errors
  • ink! Smart Contracts
    • Introduction
    • Generate Types & APIs
    • Deploy contracts
    • Queries
    • Transactions
    • Events
    • Handle errors
  • CLI
  • Keyring & Signer
  • Runtime upgrades
  • Type system
  • Utilities
    • HexString
    • Uint8Array (U8a)
    • String
    • Hash functions
    • Address
    • BigInt & number
    • Balances
    • Merkleized Metadata
  • Help & FAQ
    • Tutorials
      • Develop ink! dApp using Typink
    • Built with Dedot
    • Forum Posts
    • Telegram
    • Github
    • API Reference
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub

Type system

PreviousRuntime upgradesNextUtilities

Last updated 8 months ago

Was this helpful?

The table below is a mapping between types (Rust) and TypeScript types that we're using for Dedot:

Scale Codec (Rust)
TypeScript (dedot)

u8, u16, u32,

i8, i16, i32

number

u64, u128, u256,

i64, i128, i256

bigint (native , not bn.js)

bool

boolean (true, false)

Option<T>

T | undefined

Result<Ok, Err>

{

isOk: true;

isErr?: false;

value: Ok

} | {

isOk?: false;

isErr: true;

err: Err

}

Vec<T>

Array<T>

str

string

Tuple: (A, B), ()

[A, B], []

Struct:

struct {

field_1: u8,

field_2: str

}

{

field_1: number,

field_2: string

}

Enum:

enum {

Variant1(u8),

Variant2(bool),

Variant3

}

{

type: 'Variant1',

value: number

} | {

type: 'Variant2',

value: boolean

} | {

type: 'Variant3'

}

FlatEnum:

enum {

Variant1,

Variant2

}

'Variant1' | 'Variant2'

scale-codec
BigInt