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

@openblockhq/dappsdk

v5.0.15

Published

A simple, powerful SDK to interact with the OpenBlock

Downloads

13,800

Readme

OpenBlock DApp SDK

OpenBlock SDK is an open-source SDK that allows you to connect your DApps to our users, their assets and NFTs. We currently support major EVM chains, Aptos, Starcoin and more. Login to openblock.com for more details.

Introduction

  • OpenBlock is a next-gen on-chain wallet committed to MPC protocol, keyless, seedless, and pushing security limits through distributed credentials and wallet recovery mechanisms.

Install

yarn add @openblockhq/dappsdk

Using SDK

Ethereum

import '@openblockhq/dappsdk';

window.addEventListener('DOMContentLoaded', () => {
  const provider = window.openblock;

  // Config
  provider.autoRefreshOnNetworkChange = false;

  // On Chain Changed
  provider.on('chainChanged', (chain) => {
    // handler
  });

  // On Accounts Changed
  provider.on('accountsChanged', (accounts) => {
    // handler
  });

  // Request Accounts
  const accounts = await provider.request({
    method: 'eth_requestAccounts',
  });

  // Chain ID
  const chainId = await provider.request({
    method: 'eth_chainId',
  });

  // Net Version
  const networkId = await provider.request({
    method: 'net_version',
  });

  // Get Block By Number
  const block = await provider.request({
    method: 'eth_getBlockByNumber'
  });

  // Switch Ethereum Chain
  await provider.request({
    method: 'wallet_switchEthereumChain',
    params: [
      {
        chainId,
      }
    ]
  });

  // Send Transaction
  await provider.request({
    method: 'eth_sendTransaction',
    params: [
      {
        from,
        to,
        value,
        gasLimit,
        gasPrice,
        type,
        data,
      }
    ]
  });

  // Add Ethereum Chain
  await provider.request({
    method: 'wallet_addEthereumChain',
    params: [
      {
        chainId,
        rpcUrls: [
          'https://http-mainner-node.huobichain.com',
          'https://http-mainner.hecochain.com',
        ],
        chainName: 'Huobi ECO Chain',
        nativeCurrency: { name: 'HECO', decimals: '18', symbol: 'HT' },
        blockExplorerUrls: ['https://hecoinfo.com'],
      }
    ]
  });

  // Sign
  await provider.request({
    method: 'eth_sign',
    params: ['accounts', 'msg'],
  });

  // Personal Sign
  await provider.request({
    method: 'personal_sign',
    params: ['msg', 'from'],
  });

  //  eth_signTypedData_v4
  await provider.request({
    method: 'eth_signTypedData_v4',
    params: ['accounts','typedata msg'],
  });

  // Personal Sign Verify
  await provider.request({
    method: 'personal_ecRecover',
    params: ['msg', 'sign'],
  });
});

Aptos

import '@openblockhq/dappsdk';

window.addEventListener('DOMContentLoaded', () => {
  const provider = window.openblock.aptos;

  // connect 
  const account = await provider.connect();

  // Sign And Submit Transaction
  await provider.signAndSubmitTransaction({
    type: 'entry_function_payload',
    function: '0x1::managed_coin::register',
    arguments: [],
    type_arguments: [
      'address::move_coin::MoveCoin',
    ],
  });

  // Sign Message
  const signed = await provider.signMessage({
    address: true,
    application: true,
    chainId: true,
    message: 'hello world!',
    nonce: 888,
  });

  // Get Account
  const account = await provider.account();

  // Get Network
  const network = await provider.network();

  // Disconnect
  await provider.disconnect();

  // Check isConnected
  await provider.isConnected();

  // On Account Change
  await provider.onAccountChange((account) => {
    // handler
  });

  // On Network Change
  await provider.onNetworkChange((network) => {
    // handler
  });
});

Starcoin

import '@openblockhq/dappsdk';
import { providers } from '@starcoin/starcoin';

window.addEventListener('DOMContentLoaded', () => {
  const provider = new providers.Web3Provider(window.obstarcoin, 'any');

  // Config
  window.obstarcoin.autoRefreshOnNetworkChange = false;

  // On Chain Changed
  window.obstarcoin.on('chainChanged', () => {
    // handler
  });

  // On Network Changed
  window.obstarcoin.on('networkChanged', () => {
    // handler
  });

  // On Accounts Changed
  window.obstarcoin.on('accountsChanged', () => {
    // handler
  });

  // Connect
  window.obstarcoin.request({
    method: 'stc_requestAccounts',
  });

  // Get Accounts
  const accounts = await window.obstarcoin.request({
    method: 'stc_accounts',
  });

  // Get Chain
  const chainInfo = await window.obstarcoin.request({
    method: 'chin.id',
  });

  // Request Permissions
  const permissions = await window.obstarcoin.request({
    method: 'wallet_requestPermission',
    params: [{ stc_accounts: {} }]
  });

  // Get Permissions
  const permissions = await window.obstarcoin.request({
    method: 'wallet_getPermissions',
  });

  // Resolve Functions
  const funcInfo = await window.obstarcoin.request({
    method: 'contract.resolve_function',
    params: [functionId]
  });

  // Resolve Module
  const moduleInfo = await window.obstarcoin.request({
    method: 'contract.resolve_module',
    params: [moduleId],
  });

  // Personal Sign
  const sign = await window.obstarcoin.request({
    method: 'personal_sign',
    params: [msg, from , extraParams]
  });

  // Get Encryption Key
  const key = await window.obstarcoin.request({
    method: 'stc_getEncryptionPublicKey',
    params: [accounts[0]]
  });

  // Auto Accept Token
  const result = await window.obstarcoin.request({
    method: 'state.get_resource',
    params: [accounts[0], '0x1::Account::AutoAcceptToken'],
  });

  // Send Transaction
  const hash = await provider
    .getSigner()
    .sendUncheckedTransaction({
      to,
      value,
      gasPrice,
    });

  // Get Transaction
  const transaction = await provider.getTransactionInfo(transactionHash);

  // Get Token Address
  const result = await provider.call({
    function_id: `${accounts[0]}::ABC::token_address`,
    type_args: [];
    args: [],
  });

  // Call Function
  const result = await provider.send('contract.call_v2', [
    {
      function_id,
      type_args,
      args,
    },
  ]);
});

Sui

import '@openblockhq/dappsdk';

window.addEventListener('DOMContentLoaded', () => {
  const provider = window.openblock.sui;

  // Connect
  provider.features['standard:connect'].connect();

  // Listen
  provider.features['standard:events'].on('event', () => {});

  // Execute Transaction
  provider.features['sui:signAndExecuteTransactionBlock'].signAndExecuteTransactionBlock({
    transactionBlock, // class TransactionBlock
    options,
  });

  // Sign Message
  provider.features['sui.signMessage'].signMessage({
    message // UInt8Array
  });
});

Solana

import '@openblockhq/dappsdk';

window.addEventListener('DOMContentLoaded', () => {
  const provider = window.openblock.solana;

  // Connect
  provider.connect();

  /**
   * Sign And Send Transaction
   * @param transaction {Transaction | VersionedTransaction}
  */
  provider.signAndSendTransaction(transaction);

  /**
   * Sign Transaction
   * @param transaction {Transaction | VersionedTransaction}
  */
  provider.signTransaction(transaction);

  /**
   * Sign All Transactions
   * @param transactions {Array<Transaction | VersionedTransaction>}
  */
  provider.signAllTransactions([transaction1, transaction2]);

  /**
   * Sign Message
   * @param message {Uint8Array}
  */
  provider.signMessage(message);
});