Giter Club home page Giter Club logo

scatter-js's Introduction

Scatter JS

npm version scatterjs-core

npm version scatterjs-plugin-eosjs

npm version scatterjs-plugin-eosjs2

npm version scatterjs-plugin-web3

npm version scatterjs-plugin-tron

CDN

<script src="https://cdn.scattercdn.com/file/scatter-cdn/js/latest/scatterjs-core.min.js"></script>
<script src="https://cdn.scattercdn.com/file/scatter-cdn/js/latest/scatterjs-plugin-eosjs.min.js"></script>
<script src="https://cdn.scattercdn.com/file/scatter-cdn/js/latest/scatterjs-plugin-eosjs2.min.js"></script>
<script src="https://cdn.scattercdn.com/file/scatter-cdn/js/latest/scatterjs-plugin-web3.min.js"></script>
<script src="https://cdn.scattercdn.com/file/scatter-cdn/js/latest/scatterjs-plugin-tron.min.js"></script>

Installation

To use ScatterJS you must have at least the core. You can also use Scatter without any blockchain support by simply importing only the core without any blockchain specific plugins.

This is great for sites that want to authenticate with users in a decentralized way, but don't need any blockchain functionality.

npm i -S scatterjs-core

Plugins

To keep this library small and focused only on the blockchains you want to use you can import each blockchain separately. The blockchains you don't import can't be used.

EOSIO

npm i -S scatterjs-plugin-eosjs
// OR
npm i -S scatterjs-plugin-eosjs2

Ethereum

npm i -S scatterjs-plugin-web3

Tron

npm i -S scatterjs-plugin-tron

NodeJS and babel/webpack.

If you're having trouble packaging or compiling your project you probably need to add a babel transpiler.

  • npm i -D @babel/runtime <-- run this command and it should compile.

Importing ScatterJS into your project.

Now that you have scatterjs-core and a plugin of your choosing you can go ahead and import it into your project.

You should be doing this early in your application, somewhere like your main.js or app.js, and not inside sub-pages.

Let's take eosjs as an example.

import ScatterJS from 'scatterjs-core';
import ScatterEOS from 'scatterjs-plugin-eosjs'

ScatterJS.plugins( new ScatterEOS() );

ScatterJS Usage

This library catches Scatter Desktop, Scatter Mobile and Scatter Classic ( extension ). You only need to write code once, and you will instantly support any Scatter the user has.

Making a connection

// Optional!
const connectionOptions = {initTimeout:10000}

ScatterJS.scatter.connect("Put_Your_App_Name_Here", connectionOptions).then(connected => {
    if(!connected) {
        // User does not have Scatter installed/unlocked.
        return false;
    }
    
    // Use `scatter` normally now.
    ScatterJS.scatter.getIdentity(...);
});

Using a signature provider ( plugin )

You can instantiate most plugins in two ways.

// Using a proxy wrapper
const eos = ScatterJS.scatter.eos(network, Eos, eosjsOptions);

// Or using a hook provider.
const eos = Eos({httpEndpoint:'', signatureProvider:ScatterJS.scatter.eosHook(network)});

What now?

Head over to the Scatter Developer Documentation to learn about all the amazing things you can do with Scatter.

There's also a lot more information about proper setup in the Setting up for Web Applications section which will help you get the most out of ScatterJS, and make sure you aren't exposing your users to malicious non-Scatter plugins.


Looking for the old scatter-js package?

scatter-js's People

Contributors

nsjames avatar soleone avatar

Watchers

James Cloos 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.