dApps

Intro

dApps and Wallets are today the tip of the iceberg for the new WEB3.0.

dApp is an app that connects some interface (web/mobile/app) to a decentralized environment and is free from control and interference by any single authority.

The most common way to be connected to a dApp, is through the use of a wallet.

CIP-0030 Standard

The standard describes a webpage-based communication bridge allowing webpages (i.e. dApps) to interface with Cardano wallets.

How does it work?

An extension wallet injects the API into the browser page, this creates a bridge that connects the page to the wallet features & the blockchain.

Connect

  • Call cardano.{walletName}.isEnabled(): Promise <bool>

    • Returns

    • If false will ask the user to connect the dApp with the wallet

  • Call cardano.{walletName}.enable(): Promise <API>

    • This returns the api 🛸

  • Use the api

Full Api

Here is a description of more used functions of the api.

cardano.{walletName}

  • icon

  • name

  • isEnabled(): returns true if the dApp is already connected to the user's wallet

  • enable(): returns the api instance

api

  • getNetworkId(): 1 is Mainnet

  • getUtxos(): returns list of UTxOs

  • getCollateral(): returns list of Collateral UTxOs

  • getBalance(): returns the summing of getUtxos()

  • getUsedAddresses(): returns the list of all used addresses (included in some on-chain transaction)

    • Some wallets (Nami) have a Single Address Model (SAM) by default

    • If wallet is working as SAM, it returns only 1 Address

  • getRewardAddresses(): returns the list of reward (stake) addresses.

    • Is possible to have more than 1 (CIP-0018)

    • In practice 99%+ it returns only 1

  • signTx(): ask for a sign of the `transaction` in the extension, and returns the witness

    • If partialSign para is true, the wallet only tries to sign what it can (This is how multisig transactions works)

  • signData(): ask for a sign of the `payload` in the extension.

  • submitTx(): returns the transaction id for the dApp to track

Last updated