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 🙏

© 2026 – Pkg Stats / Ryan Hefner

openchain-sdk-yxl-ts

v1.2.4

Published

OpenChain SDK for browser

Readme

OpenChain SDK

OpenChain SDK for browser environments.

Installation

npm install openchain-sdk-yxl

Required Peer Dependencies

The SDK requires the following peer dependencies to be installed in your project:

npm install buffer events process

Usage

在 Vite 项目中使用

  1. 安装必要的依赖:
npm install buffer events process
  1. 配置 vite.config.js:
import { defineConfig } from 'vite';

export default defineConfig({
  resolve: {
    alias: {
      buffer: 'buffer',
      process: 'process/browser',
      events: 'events'
    }
  },
  define: {
    'process.env': {},
    global: 'globalThis'
  }
});
  1. 在入口文件中初始化环境:
import { Buffer } from 'buffer';
import process from 'process';

window.Buffer = Buffer;
window.process = process;
window.global = window;
  1. 使用SDK:
import OpenChainSDK from 'openchain-sdk-yxl';
// 或者
import { OpenChainSDK } from 'openchain-sdk-yxl';

const sdk = new OpenChainSDK({
  host: 'your-api-host',
  chainID: 0
});

在 Create React App 中使用

  1. 安装必要的依赖:
npm install buffer events process react-app-rewired
  1. 配置 config-overrides.js:
const webpack = require('webpack');

module.exports = function override(config) {
  config.resolve.fallback = {
    buffer: require.resolve('buffer/'),
    process: require.resolve('process/browser'),
    events: require.resolve('events/')
  };

  config.plugins.push(
    new webpack.ProvidePlugin({
      Buffer: ['buffer', 'Buffer'],
      process: 'process/browser'
    })
  );

  return config;
};
  1. 更新 package.json 中的 scripts:
{
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test"
  }
}
  1. 在入口文件中初始化环境:
import { Buffer } from 'buffer';
import process from 'process';

window.Buffer = Buffer;
window.process = process;
window.global = window;
  1. 使用SDK:
import OpenChainSDK from 'openchain-sdk-yxl';
// 或者
import { OpenChainSDK } from 'openchain-sdk-yxl';

const sdk = new OpenChainSDK({
  host: 'your-api-host',
  chainID: 0
});

在 Webpack 项目中使用

  1. 安装必要的依赖:
npm install buffer events process
  1. 配置 webpack.config.js:
const webpack = require('webpack');

module.exports = {
  resolve: {
    fallback: {
      buffer: require.resolve('buffer/'),
      process: require.resolve('process/browser'),
      events: require.resolve('events/')
    }
  },
  plugins: [
    new webpack.ProvidePlugin({
      Buffer: ['buffer', 'Buffer'],
      process: 'process/browser'
    })
  ]
};
  1. 在入口文件中初始化环境:
import { Buffer } from 'buffer';
import process from 'process';

window.Buffer = Buffer;
window.process = process;
window.global = window;
  1. 使用SDK:
import OpenChainSDK from 'openchain-sdk-yxl';
// 或者
import { OpenChainSDK } from 'openchain-sdk-yxl';

const sdk = new OpenChainSDK({
  host: 'your-api-host',
  chainID: 0
});

API Examples

Account Operations

// Create account
const result = await sdk.account.create();
console.log(result);

// Get account info
const info = await sdk.account.getInfo('your-account-address');
console.log(info);

Contract Operations

// Deploy contract
const contractResult = await sdk.contract.createContract({
  sourceAddress: 'your-address',
  initBalance: '10',
  type: 0,
  payload: 'contract-code'
});
console.log(contractResult);

// Call contract
const callResult = await sdk.contract.call({
  contractAddress: 'contract-address',
  input: 'method-name'
});
console.log(callResult);

WebSocket Usage

import { WebSocketClient } from 'openchain-sdk-yxl';

const ws = new WebSocketClient({
  url: 'ws://your-ws-url',
  autoReconnect: true
});

ws.on('connected', () => {
  console.log('Connected to WebSocket server');
});

ws.on('transaction', (message) => {
  console.log('New transaction:', message);
});

// Subscribe to transactions
ws.subscribeTx(['your-account-address']);

Browser Compatibility

The SDK requires the following browser environment support:

  • Buffer (通过 buffer 包提供)
  • Process (通过 process 包提供)
  • Events (通过 events 包提供)

Minimum browser versions supported:

  • Chrome >= 60
  • Firefox >= 60
  • Safari >= 12
  • Edge >= 79

TypeScript Support

The package includes TypeScript definitions. No additional @types package is required.

License

ISC