Giter Club home page Giter Club logo

cardano-wallet-interface's Introduction

cardano-wallet-interface

brought to you by Harmonic Pool

Thank you

This softweare exists thanks to Harmonic delegators an supporters

How can I support?

  • delegate ADA to Harmonic Pool
  • donate ADA to : addr1qxm09exmyl04yhh67rvvmp2zauq32p8g7v60wtv03ved7t8h2y992ly7znq5q8ckurcpum0dc8kaunpkysnlnzzhw0pqd875p8
  • contribute building this repository
  • contribute building a greather Cardano with any repository of Harmonic Pool

Contents

Installation

run the following in your project directory

npm install https://github.com/HarmonicPool/cardano-wallet-interface

supported wallets

here's a list of supported wallet, if you notice a Cardano wallet that support dApp connector is missing, feel free to send a mail here

Usage

basic usage

access a generic wallet

let Typhon = undefined;
const ITyphon = Wallet.getInterface( Wallet.Names.Typhon );

if( 
    ITyphon.isInjected() // equivalent to ```Wallet.has( Wallet.Names.Typhon )```
)
{
    if(
        ITyphon.isAviable() // if enabled before returns true, no need to perform async calls
    )
    {
        Typhon = Wallet.Typhon; // Wallet.get( Wallet.Names.Typhon ) will do the same
    }
}
else // async code needed
{
    if(
        await ITyphon.isEnabled() // @returns {Promise<boolean>} as per CIP0030 definition
    )
    {
        Typhon = Wallet.Typhon; // same as before
    }
    else
    {
        await Wallet.enable( Wallet.Names.Typhon ); // makes the object aviable
        Typhon = Wallet.Typhon; // same as before
    }
}
simple delegation

NOTE: every other wallet will work the same way, just change the name (eg. Nami -> CCVault )

/*... other imports ...*/
import Wallet from "@harmonicpool/cardano-wallet-interface";

/*...*/

if( Wallet.has( Wallet.Names.Nami ) )
{
    if( !await Wallet.isEnabled( Wallet.Names.Nami ) )
    {
        Wallet.enable( Wallet.Names.Nami )
        .then(
            () => {
                Wallet.Nami.delegateTo(
                    "<your pool id>",
                    "<your blockforst api key>"
                );
            }
        );
    }
    else
    {
        Wallet.Nami.delegateTo(
            "<your pool id>",
            "<your blockforst api key>"
        );
    }
}

/*...*/

have a look at documentation/examples/Wallets iteration.md to understand how to generalize the process for more wallets

other examples

check the documentation/examples folder for more

Documentation

a more in depth documentation can be found in the documentation folder

cardano-wallet-interface's People

Contributors

michele-nuzzi avatar harmonicpool avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.