Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@ocap/client

Package Overview
Dependencies
Maintainers
3
Versions
530
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ocap/client

graphql client to read/write data on arcblock blockchain

Source
npmnpm
Version
1.25.6
Version published
Maintainers
3
Created
Source

![graphql-client](https://www.arcblock.io/.netlify/functions/badge/?text=graphql-client)

[! [! [![gitter](https://badges.gitter.im/arcblock/community.svg)](https://gitter.im/arcblock/arcblock/community?utm_source = badge = badge \&utmm_medium = badge \ utm_campaign = badeaign = badeaign = badage) 客户库可以在Node.js和浏览器环境中使用http/https通过http/https发送所有请求,将您的应用程序连接到Forge Power的区块链节点。

“ GraphQlClient”实例主要支持5组方法,这些方法可节省您的时间,从/到区块链读取数据时。

_queries:QUERY BLOCK/TRASSACTION/ACCENT/ACCENT/ASSET/CHAIN/NODE数据表格区块链 _突变“:将事务发送到区块链``sendtx',所有交易应在发送到区块链之前签署所有交易 *``订阅':收听区块链上任何数据的更改 *``senders':采用``钱包''和tx对象的快捷方式,然后进行签名,然后发送 *coders:采用``钱包''和tx`对象的快捷方式,编码事务以进行后期签名,内部由发件人内部使用

## 目录

_[安装](#安装) _[用法](#使用) _[示例](#示例) _[调试](#调试)*[文档](#文档)

## 安装

npm i @ocap/client -S
# 或者
PNPM install @ocap/client

## 用法

``JS const mcrypto = require('@ocap/mcrypto'); const graphQlclient = require('@ocap/client'); const {fromrandom,wallettype} = require('@ocap/wallet'); const {hextobytes} = require('@ocap/util');

const client = new GraphQlClient('http://localhost:8210/api'); console.log({ 查询:client.getqueries(), 订阅:client.getSubscriptions(), 突变:client.getmutations(), 发件人:client.gettxsendmethods(), 编码器:client.getTxEncodePhods(), });

(async()=> { //查询链状态数据 const Chaininfo =等待客户端。GetChainInfo(); const forgestate =等待客户端。 const block =等待client.getBlock({height:2}); console.log('getchaininfo',chaininfo); console.log('getforgentate',宽恕); console.log('getBlock',block);

//发送交易 const钱包= fromrandom( wallettype({ 角色:mcrypto.types.roletype.role_account, PK:mcrypto.types.keytype.secp256k1, 哈希:mcrypto.types.hashtype.sha3, })) ); const hash =等待client.declare({ 绰号:“用户名”, 钱包, }); console.log(hash); })();



##示例

*[在区块链上声明标识](./示例/scellare.js)
*[为新创建的帐户获取免费令牌](./示例/get_free_token.js)
*[2个帐户之间的转移资产](./示例/Transfer_asset.js)
*[2个帐户之间的转移令牌](./示例/trassing_token.js)
*[2个新创建的帐户之间的Exchange Asset和令牌](./示例/Exchange.js)
*[在区块链上创建/更新资产](./示例/Asset.js)
*[消费新创建资产](./示例/clummume_asset.js)
*[连接节点的股份](./示例/stake_for_node.js)


##调试
*如果您在node.js中:`debug =@ocap/client node script.js`
*如果您在浏览器中:`localstorage.setitem('debug','@ocap/client')


##文档

*查询参数和响应结构可以在此处找到:[queries.md](./docs/queries.md)
*完整的方法列表可以在此处找到:[readme.md](./docs/readme.md)

Keywords

graphql

FAQs

Package last updated on 01 Oct 2025

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