Socket
Book a DemoInstallSign in
Socket

@blockmason/link-sdk

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blockmason/link-sdk

Convenience library for accessing an API hosted on Blockmason Link.

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
2
Created
Source

CircleCI

Installing

To add this library to your app, do one of the following:

Using Yarn:

yarn add @blockmason/link-sdk

Using NPM:

npm install @blockmason/link-sdk

Usage

Importing the module

First, your app should import the link module from this library.

Using ES6:

import { link } from '@blockmason/link-sdk';

Using CommonJS modules (Node.js):

const { link } = require('@blockmason/link-sdk');

Configuring

Once you have the link() function imported, create a client for your Link project like this:

const project = link({
  clientId: '<your-client-id>',
  clientSecret: '<your-client-secret>'
});

Use the Client ID and Client Secret provided by your Link project to fill in the respective values above.

Using from a Node.js environment

The Link SDK uses fetch() to make HTTP requests. Most modern browsers provide this function as a global, but it is absent from Node.js.

When calling the link() function from a Node.js environment, you can pass in a fetch() implementation along as a second parameter, like this:

const fetch = require('node-fetch');
const { link } = require('@blockmason/link-sdk');

const project = link({
  clientId: '<your-client-id>',
  clientSecret: '<your-client-secret>'
}, {
  fetch
});

The above snippet uses the node-fetch compatibility package.

Then, you can use the project object to make requests against your Link project.

For example, assuming your project has a GET /echo endpoint that expects a message input and responds with a message output:

const { message } = await project.get('/echo', {
  message: 'Hello, world!'
});
console.log(message);
// "Hello, world!"

Another example, assuming your project has a POST /mint endpoint that expects to and amount inputs:

await project.post('/mint', {
  amount: 1000,
  to: '0x1111222233334444555566667777888899990000'
});

FAQs

Package last updated on 27 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.