Overview
The @ocap/client
library is a JavaScript client for connecting applications to a Forge-powered blockchain. It simplifies interaction by sending requests over HTTP/HTTPS and can be used in both Node.js and browser environments, making it a versatile tool for building applications that read and write data to the blockchain. You can find the library on npm.
How It Works#
The client acts as an intermediary between your application and a blockchain node. It abstracts the complexities of the GraphQL API, allowing you to interact with the blockchain through a straightforward set of JavaScript methods. For real-time updates, it establishes a WebSocket connection to subscribe to on-chain events.
Core Capabilities#
A GraphQLClient
instance provides five main groups of methods to streamline your development process when interacting with the blockchain.
Method Group | Description |
---|---|
Queries | Retrieve data from the blockchain, such as information on blocks, transactions, accounts, assets, or the overall chain state. |
Mutations | Send transactions to the blockchain. The main method is |
Subscriptions | Listen for real-time changes to any data on the blockchain, allowing your application to react to events as they happen. |
Senders | A set of helper methods that simplify the process of signing and sending a transaction by taking a |
Encoders | A set of helper methods that encode a transaction for later signing. These are used internally by the |
Next Steps#
To begin building your application, proceed to the Getting Started guide for installation instructions and a basic usage example. If you are new to the underlying blockchain principles, you may find it helpful to review the Core Blockchain Concepts first.