Giter Club home page Giter Club logo

webxcp's Introduction

WebXCP

Javascript code for Counterparty webXCP api.

Rational

Counterparty wallets that conform to the webXCP standard as outlined below and off the ability for web applications to request wallet specific functions. For example a web app may want the users wallet to sign a transaction or request the users address. Such a set up allows secure wallets to be built that store the users private keys nativley (in an iOS app / Android app / chrome extension etc) whilst also allowing applications to be built for the web browser. Once such example is a simple game developed in HTML5 that can be loaded inside of the IndieSquare wallet though the app browser tab and request the users address inorder to utilize the users token balance as game items.

Example

For developers creating web applications that which to use the web3 standard they can call the following 3 functions to request any listening wallet to perform the requested task.

Get Users Address

parameters:

  • basePath : base path of requested address or null to get wallets default account

  • callback : callback function with error and address

webXCP.getAccounts(null,(err, address) => {
    if(err != null){
      //handle error
    }else 
     console.log(address);
    }
});

webXCP.getAccounts("m/0'/0/2",(err, address) => {
    if(err != null){
      //handle error
    }else 
     console.log(address);
    }
});

Request Sign Message

parameters:

  • basePath : base path of key pair to sign with or null to use the wallets default key pair

  • message : message to sign

  • callback : callback function with error and signature

webXCP.signMessage(msg,null,(err, signature) => {
    if(err != null){
      //handle error
    }else 
     console.log(signature);
    }
});

Request Sign Transaction

parameters:

  • basePath : base path of key pair to sign with or null to use the wallets default key pair

  • rawtx : raw transaction to sign

  • callback : callback function with error and the signed transaction

webXCP.signTransaction(rawtx,null,(err, result) => {
    if(err != null){
      //handle error
    }else 
     console.log(result.raw);
    }
});

webxcp's People

Contributors

mandelmonkey avatar

Stargazers

TeaTwo avatar

Watchers

James Cloos avatar  avatar Benton C Bainbridge avatar Yuta Hoshino 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.