genlayer-js v0.9.0
GenLayerJS
👀 About
GenLayerJS SDK is a TypeScript library designed for developers building decentralized applications (Dapps) on the GenLayer protocol. This SDK provides a comprehensive set of tools to interact with the GenLayer network, including client creation, transaction handling, event subscriptions, and more, all while leveraging the power of Viem as the underlying blockchain client.
Prerequisites
Before installing GenLayerJS SDK, ensure you have the following prerequisites installed:
- Node.js (>= 16.x)
- npm (>= 7.x)
🛠️ Installation and Usage
To install the GenLayerJS SDK, use the following command:
$ npm install genlayer-js
Here’s how to initialize the client and connect to the GenLayer Simulator:
Reading a Transaction
import { localnet } from 'genlayer-js/chains';
import { createClient } from "genlayer-js";
const client = createClient({
chain: localnet,
});
const transactionHash = "0x...";
const transaction = await client.getTransaction({ hash: transactionHash })
Reading a contract
import { localnet } from 'genlayer-js/chains';
import { createClient } from "genlayer-js";
const client = createClient({
chain: localnet,
});
const result = await client.readContract({
// account: account, Account is optional when reading from contracts
address: contractAddress,
functionName: 'get_complete_storage',
args: []
stateStatus: "accepted",
})
Writing a transaction
import { localnet } from 'genlayer-js/chains';
import { createClient, createAccount } from "genlayer-js";
const client = createClient({
network: localnet,
});
const account = createAccount();
const transactionHash = await client.writeContract({
account: account, // using this account for this transaction
address: contractAddress,
functionName: 'account',
args: ['new_storage'],
value: 0, // value is optional, if you want to send some native token to the contract
});
const receipt = await client.waitForTransactionReceipt({ hash: txHash, status: TransactionStatus.FINALIZED}) //or ACCEPTED
🚀 Key Features
- Client Creation: Easily create and configure a client to connect to GenLayer’s network.
- Transaction Handling: Send and manage transactions on the GenLayer network.
- Wallet Integration*: Seamless integration with MetaMask for managing user accounts.
- Gas Estimation*: Estimate gas fees for executing transactions on GenLayer.
* under development
📖 Documentation
For detailed information on how to use GenLayerJS SDK, please refer to our documentation.
Contributing
We welcome contributions to GenLayerJS SDK! Whether it's new features, improved infrastructure, or better documentation, your input is valuable. Please read our CONTRIBUTING guide for guidelines on how to submit your contributions.
License
This project is licensed under the MIT License - see the LICENSE file for details.
3 months ago
3 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
7 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago