Squarelink Web3 SDK
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
Usage
First, register your application at dev.squarelink.com to obtain your CLIENT ID
const sqlk = '<CLIENT ID>' // Use callback or Promisesqlk
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'<CLIENT ID>' 'ropsten'
// connect to a custom private network'<CLIENT ID>' url: 'https://localhost:8545' chainId: 420
opts
)
Options (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 belowuser:name
- Access to read user's nameuser:email
- Access to user's email addressuser:security
- Access to read user's security settings
Detecting Squarelink
web3.currentProvider.isSquarelink
Additional Functions
-
Squarelink.getName() - requires the
user
oruser:name
scope -
Squarelink.getEmail() - requires the
user
oruser:email
scope -
Squarelink.getSecuritySettings() - requires the
user
oruser: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 = '<CLIENT ID>' 'mainnet' useSync: true const web3 = sqlk
Documentation
License
MIT