Git Product home page Git Product logo

tbapi's Introduction

TezBoX API

This is the API for the TezBox Browser Extension, which allows app developers to integrate their websites directly with their users.

Installation

Simply include the tbapi.js file into your website. This will create the window.tbapi object which you can use to access the API.

Usage

tbapi.haveAccess and tbapi.requestAccess

Before you can integrate with a users TezBox via the tbAPI, you need to ensure you have access. You can use the following functions to check and request access. Both functions return a promise that will always resolve with the outcome.

tbapi.haveAccess().then(function(r){
  if (r == false) {
    console.log("We don't have access");
  } else {
    console.log("We have access");
  }
});

tbapi.requestAccess().then(function(r){
  if (r == false) {
    console.log("Access rejected or blocked");
  } else {
    console.log("Access granted!");
  }
});

Once you have access, you can use the following methods:

tbapi.getAllAccounts

Retreive a list of all the users accounts (including titles, addresses and public keys).

tbapi.getAllAccounts().then(function(r){
  if (r == false) {
    console.error(r.error);
  } else {
    console.log("Here are the accounts", r.data);
  }
});

tbapi.initiateTransaction

Initiate a transaction to be approved by the user and injected into the blockchain. This function requires 3 mandatory arguments (source, destination, amount) and 4 optional arguments (fee, parameters, gas_limit, storage_limit):

tbapi.initiateTransaction(source, destination, amount, fee, parameters, gas_limit, storage_limit).then(function(r){
  if (r == false) {
    console.error(r.error);
  } else {
    console.log("Transaction was set!", r.data);
  }
});

tbapi.signData

WIP Sign data with the users private key

Errors

Coming soon

tbapi's People

Contributors

stephenandrews avatar

Watchers

 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.