JavaScript Client Library
The JavaScript Client Library for Signchain, available as @grexie/signchain
on npm, allows Node.js developers to interact directly with Signchain's vaults and APIs. This library is tailored for secure server-side use, offering powerful tools for transaction signing, wallet management, and API integration, all designed to work seamlessly within a JavaScript environment.
Key Benefits
The JavaScript Client Library is built to simplify blockchain interactions and enhance security in web and backend applications. Here’s what you can expect:
- Seamless Blockchain Integration: Access blockchain transactions, wallet management, and signing capabilities directly in your JavaScript applications.
- Gas Fee Offloading: Signchain’s model allows you to offload gas fees to users, enabling a more scalable and cost-effective solution for your operations.
- Enhanced Security: The library ensures private keys and sensitive data remain secure by handling interactions within your backend environment.
- Efficient Development Workflow: Skip the complexities of direct blockchain handling; the client library abstracts many of the low-level details, so you can focus on building features.
Installation
To install the Signchain JavaScript Client Library, use npm or yarn:
npm install @grexie/signchain
or
yarn add @grexie/signchain
The package is compatible with Node.js environments, ensuring optimal security for server-side blockchain operations.
Core Features
The library provides a comprehensive set of methods to interact with Signchain’s vaults and API, making it easy to manage wallets, sign transactions, and retrieve vault status. Here’s a quick look at the key features:
1. Wallet Management
Create, retrieve, list, and manage wallets within your Signchain Vault. Wallets are securely managed on your server, keeping private keys secure and allowing for robust control over wallet data.
2. Secure Transaction Signing
Use Signchain’s secure API to sign transactions within your application, leveraging the private key encryption and security built into the Signchain Vault infrastructure.
3. Vault Status Monitoring
Retrieve real-time information about the status of your vault, including active vault keys, wallet counts, and version details.
4. Access Control and Security
The JavaScript Client Library integrates with Signchain’s authentication model, using API keys to protect your endpoints and data. For additional security, pair it with the VAULT_AUTH_SECRET_KEY
in self-hosted setups.
High-Level Workflow
Here's a quick overview of how to start using the JavaScript Client Library:
-
Initialize the Client
Start by creating an instance ofSignchainClient
, passing in the API key and vault ID. This setup enables secure communication with Signchain's API.const { SignchainClient } = require('@grexie/signchain'); const client = new SignchainClient({ apiKey: 'your-api-key', vaultId: 'your-vault-id' });
-
Perform Wallet Operations
You can easily create, retrieve, or list wallets using the client. Here’s an example of creating a new wallet:const wallet = await client.createWallet({ name: 'My Wallet' }); console.log(wallet);
-
Sign Transactions
The library allows for secure transaction signing. Here’s a simple example:const options = { chain: 'ethereum', contract: '0xYourContractAddress', sender: '0xYourSenderAddress', abi: contractABI, functionName: 'myFunction', args: ['param1', 'param2'] }; const { submissionHash, args } = await client.sign(options); console.log('Signed Transaction:', submissionHash, args);
-
Check Vault Status
Keep track of your vault’s health and activity by checking its status:const status = await client.vaultStatus(); console.log('Vault Status:', status);
Additional Resources
- Getting Started: Follow our setup guide to quickly get started with Signchain’s JavaScript Client Library.
- Usage Examples: See detailed examples for common use cases, including wallet management, transaction signing, and API handling.
- API Reference: For a comprehensive list of available endpoints and parameters, consult the API Reference.
Security Recommendations
- Run on Server-Side Only: This library is designed exclusively for server-side use to keep your API key and private data secure.
- Enable
VAULT_AUTH_SECRET_KEY
: For self-hosted vaults, ensure that theVAULT_AUTH_SECRET_KEY
is properly configured to prevent unauthorized access. - Regularly Update API Keys: Rotate your API keys periodically to maintain security and prevent unauthorized access.
By integrating the Signchain JavaScript Client Library, you’ll be able to securely manage wallets and transactions, offload gas fees, and implement secure blockchain features without the hassle of direct blockchain interactions. Explore our Getting Started guide to dive deeper!