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-request

v1.0.0

Published

openchain sd YxL request

Downloads

0

Readme

OpenChain Node.js SDK 使用手册

目录

简介

OpenChain Node.js SDK 是一个用于与OpenChain区块链网络交互的JavaScript开发工具包。它提供了丰富的API接口,使开发者能够方便地进行账户管理、智能合约部署与调用、资产管理等区块链相关操作。

安装与配置

安装

npm install openchain-sdk-yxl-request --save

基本配置

const SDK = require('openchain-sdk-yxl-request');

// 初始化SDK配置
const sdk = new SDK({
    host: 'http://your-openchain-node:36002',  // OpenChain节点地址
});

核心功能

账户管理

账户管理模块提供了创建账户、查询账户信息、设置权限等功能。

// 创建账户
const account = sdk.account.create();

// 查询账户信息
const accountInfo = await sdk.account.getInfo(address);

// 设置账户权限
const result = await sdk.account.setPrivilege({
    sourceAddress: address,
    masterWeight: 1,
    signers: [],
    threshold: 1
});

合约操作

支持智能合约的创建、调用和查询等操作。

// 创建合约
const contract = await sdk.contract.create({
    sourceAddress: address,
    code: contractCode,
    initBalance: '0',
    metadata: 'contract metadata'
});

// 调用合约
const invokeResult = await sdk.contract.invokeByOP({
    sourceAddress: address,
    contractAddress: contractAddress,
    opAmount: 0,
    input: 'input params'
});

资产管理

提供资产的发行、转移等功能。

// 发行资产
const issueResult = await sdk.token.asset.issue({
    sourceAddress: address,
    code: 'CNY',
    amount: '10000'
});

// 转移资产
const sendResult = await sdk.token.asset.send({
    sourceAddress: address,
    destAddress: toAddress,
    code: 'CNY',
    amount: '100'
});

CTP10代币

支持符合CTP10标准的代币操作。

// 发行CTP10代币
const tokenResult = await sdk.token.ctp10Token.issue({
    sourceAddress: address,
    name: 'MyToken',
    symbol: 'MT',
    decimals: 8,
    totalSupply: '1000000'
});

// 转移代币
const transferResult = await sdk.token.ctp10Token.transfer({
    sourceAddress: address,
    destAddress: toAddress,
    tokenOwner: tokenOwner,
    amount: '100'
});

错误处理

SDK使用标准的错误处理机制,建议使用try-catch进行错误捕获。

try {
    const result = await sdk.account.getInfo(address);
} catch (error) {
    console.error('错误类型:', error.name);
    console.error('错误信息:', error.message);
}

示例代码

完整的示例代码可以参考SDK的测试用例:

  • 账户操作: test/account.test.js
  • 合约操作: test/contract.test.js
  • 资产管理: test/asset.test.js
  • CTP10代币: test/Ctp10Token.test.js

API参考

主要模块

  • account: 账户管理模块
  • contract: 智能合约模块
  • token: 资产和代币管理模块
  • blockchain: 区块链信息查询模块

工具类

  • util: 提供常用的工具函数
  • crypto: 加密相关功能

错误类型

  • customErrors: 自定义错误类型
  • errors: 标准错误定义

注意事项

  1. 在生产环境中使用时,请确保节点地址使用HTTPS协议
  2. 私钥信息需要安全保管,避免泄露
  3. 建议在进行重要操作时启用多重签名机制
  4. 代币转移等操作前要仔细核对地址信息

许可证

ISC License