Giter Club home page Giter Club logo

infinite-wallet's Introduction

Hedera Hashgraph Extension Wallet

This wallet was created for the Hedera Hashgraph hackathon. It supports all hashgraph actions such as transfer, token create, etc.

Installation

  • Grab the latest release from this repository
  • Open up chrome and navigate to chrome://extensions/
  • Enable 'Developer mode'
  • Click 'Load unpacked'
  • Select /dist directory
  • Open the wallet from the top right extension icon, and import your accounts.

Application integration

  • $ npm i -S @hashgraph/sdk@^2
const { Client, TransferTransaction } = require("@hashgraph/sdk");

let wallet;

document.addEventListener('hederaWalletLoaded', async () => {
    // Grab the injected wallet from the window object
    wallet = window.wallet;

    // Testnet, Mainnet, or Previewnet
    const account = await wallet.login('Testnet');

    // Instantiate a client
    const client = Client.forTestnet();

    // Set the operator for signing to the signer from the wallet
    client.setOperatorWith(
        account.id,
        account.publicKey,
        wallet.getTransactionSigner()
    );

    // You can now use any Hashgraph SDK transaction builders,
    // and execute using this client.
    const executed = await new TransferTransaction()
        .addHbarTransfer(wallet.account.id, Hbar.fromTinybars(-1))
        .addHbarTransfer('some.other.id', Hbar.fromTinybars(1))
        .signWithOperator(client)
        .execute(client);

    console.log(await executed.getReceipt(client));
})

Injected APIs

Account Object

{
    id:string           // Example: 0.0.123456
    publicKey:string,   // Example: 302a30050....
    network:string,     // Example: Testnet
}

APIs

  • wallet.login(network:string) - Requests a login from the user
  • wallet.logout() - Logs out of the user's wallet
  • wallet.account - Will be populated with an account instance after calling login()
  • wallet.addAccount(network:string, id:string, privateKey:string) - Requests that the user add a specific account to their wallet. This is a utility for account creation processes.
  • wallet.getTransactionSigner() - Returns a transaction signer that can be used with the SDK's client.setOperatorWith

Note: Logins persist past page reload. When the page first loads you can check wallet.account to see if there is already a login permission in place.

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.