npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

squarelink

v1.1.4

Published

Squarelink's Web3 library

Downloads

934

Readme

Squarelink Web3 SDK

license

This is the Squarelink Web3 SDK which enables Squarelink enhancements to standard Web3 JSON RPC requests.

Check out the Squarelink Documentation for more information, quick-start guides, etc.

Installation

Node

$ npm install squarelink

CDN

<script src="https://squarelink.com/js/squarelink.min.js"></script>

Usage

First, register your application at dev.squarelink.com to obtain your CLIENT ID

import Web3 from 'web3'
import Squarelink from 'squarelink'

const sqlk = new Squarelink('<CLIENT ID>')

// Use callback or Promise
sqlk.getProvider(provider => {
  const web3 = new Web3(provider)

  // Use the web3 library as you would normally!
  web3.currentProvider.enable()
})

Configuration

const sqlk = new Squarelink(clientId [, network][, opts])

Squarelink-Object - Initializes a Squarelink Web3 Provider for you

  • clientId-String - The Client ID provided to you when you register your DApp in the Squarelink Developer Console

  • network-String|Object - Configures the RPC node you're connecting to. See a list of our available networks. Defaults to 'mainnet'.

  • opts - Object - Pass additional options to the Squarelink SDK.

Examples

// connect to the Ropsten network
new Squarelink('<CLIENT ID>', 'ropsten')
// connect to a custom private network
new Squarelink('<CLIENT ID>', {
  url: 'https://localhost:8545',
  chainId: 420
})

Options (opts)

  • scope - Array - Request additional scopes to use custom Squarelink functions.
  • useSync - Boolean - See getProviderSync below for usage (default = false).

Available Scopes:

  • user - Equivalent to all scopes below
  • user:name - Access to read user's name
  • user:email - Access to user's email address
  • user:security - Access to read user's security settings

Detecting Squarelink

web3.currentProvider.isSquarelink

Additional Functions

  • Squarelink.getName() - requires the user or user:name scope

  • Squarelink.getEmail() - requires the user or user:email scope

  • Squarelink.getSecuritySettings() - requires the user or user:security scope

Initializing Squarelink Synchronously

The getProvider function fetches a list of our supported networks and their RPC endpoints from our API. This allows us to remotely switch RPC providers to ensure 100% uptime and remove faulty/compromised endpoints.

If you are unable to support callbacks/promises, you can use getProviderSync which uses hard-coded RPC endpoints. NOTE: we cannot guarantee 100% uptime with this method.

const sqlk = new Squarelink('<CLIENT ID>', 'mainnet', { useSync: true })
const web3 = new Web(sqlk.getProviderSync())

Documentation

https://docs.squarelink.com

License

MIT