0.15.0 • Published 5 years ago
@arcblock/forge-graphql-client v0.15.0
forge-graphql-client
Graphql Client for Forge, provided gRPC similar features to interact with a forge-powered app.
Table of Contents
Install
npm i @arcblock/forge-graphql-client -S
# OR
yarn add @arcblock/forge-graphql-client
Usage
const Mcrypto = require('@arcblock/mcrypto');
const GraphqlClient = require('@arcblock/forge-graphql-client');
const { fromRandom, WalletType } = require('@arcblock/forge-wallet');
const { hexToBytes } = require('@arcblock/forge-util');
const client = new GraphqlClient('http://localhost:8210/api');
console.log({
queries: client.getQueries(),
subscriptions: client.getSubscriptions(),
mutations: client.getMutations(),
transactions: client.getTxMethods(),
});
(async () => {
// Query Data
const chainInfo = await client.getChainInfo();
const forgeState = await client.getForgeState();
const block = await client.getBlock({ height: 2 });
console.log('getChainInfo', chainInfo);
console.log('getForgeState', forgeState);
console.log('getBlock', block);
// Send Transaction
const wallet = fromRandom(
WalletType({
role: Mcrypto.types.RoleType.ROLE_ACCOUNT,
pk: Mcrypto.types.KeyType.SECP256K1,
hash: Mcrypto.types.HashType.SHA3,
})
);
const res = await client.sendDeclareTx({
data: {
moniker: `wangshijun_${Math.round(Math.random() * 1000)}`,
pk: Buffer.from(hexToBytes(wallet.publicKey)),
type,
},
wallet,
});
console.log(res);
})();
Documentation
Checkout: API.md.
0.15.0
5 years ago
0.14.3
5 years ago
0.14.0
5 years ago
0.13.2
5 years ago
0.13.0
5 years ago
0.12.3
5 years ago
0.12.2
5 years ago
0.12.0
5 years ago
0.11.1
5 years ago
0.11.0
5 years ago
0.10.0
5 years ago
0.9.0
5 years ago
0.8.8
5 years ago
0.8.7
5 years ago
0.8.6
5 years ago
0.8.5
5 years ago
0.8.4
5 years ago
0.8.3
5 years ago
0.8.1
5 years ago
0.8.0
5 years ago
0.7.10
5 years ago
0.7.9
5 years ago
0.7.2
5 years ago