@creatachain/cat3 v1.0.0
cat3 — The Ultimate Catena SDK
cat3 is the fastest, most reliable, and developer-friendly library for building on the Catena blockchain.
Simple, powerful, lightweight, and battle-tested — everything you need to create next-generation decentralized apps (dApps), wallets, and backend services.
Why cat3?
- Security First: Your private keys never leave your client. Full control, total privacy.
- Ultra Light: Tiny bundle size optimized for performance.
- Type-Safe: 100% TypeScript with strict types for safety, reliability, and DX (Developer Experience).
- Powerful Tools: Instantly interact with smart contracts, manage wallets, connect to Catena nodes, and more.
What You Can Do with cat3
- Securely generate, import, and export Catena wallets and accounts.
- Manage and recover HD wallets and mnemonic phrases across multiple languages.
- Interact with any Catena smart contract using dynamic ABI interfaces.
- Connect easily to your preferred Catena node providers over JSON-RPC.
- Build dApps, wallets, payment processors, DeFi applications, and more.
Get Started
1. Setting Up the Environment
Before you can use cat3, you need to set up your environment:
Step 1.1: Install cat3
To install cat3, you can use npm or yarn. In your terminal, run:
npm install @creatachain/cat3or
yarn add @creatachain/cat3Step 1.2: Set up a Catena Node or Connect to a Provider
To interact with the Catena blockchain, you need to connect to a Catena node. To connect to a Catena node, you will need the node URL (JSON-RPC endpoint).
Example for connecting to the Catena node:
import { catena } from '@creatachain/cat3';
// Connect to Catena node
const provider = new catena.JsonRpcProvider("https://your-catena-node-url.com");2. Generate a New Wallet
You can create a new wallet using cat3 by generating a random wallet:
import { catena } from '@creatachain/cat3';
// Create a new random wallet
const wallet = catena.Wallet.createRandom();
console.log("Wallet Address:", wallet.address);
console.log("Private Key:", wallet.privateKey);This will generate a new wallet and print the address and private key. Note: Make sure to save your private key securely.
3. Get Balance of CTA (Catena Coin)
You can fetch the CTA (Catena Coin) balance of an address using the getBalance method from the Provider class.
import { catena } from '@creatachain/cat3';
// Connect to Catena node
const provider = new catena.JsonRpcProvider("https://your-catena-node-url.com");
const balance = await provider.getBalance("YourAddressHere"); // Get CTA balance
console.log("Balance of CTA:", balance.toString()); // Output balance in wei4. Send a Simple Transfer Transaction
Once you have a wallet and a balance, you can send CTA coins to another address. Here’s an example of how to send a transaction:
import { catena } from '@creatachain/cat3';
// Connect to Catena node
const provider = new catena.JsonRpcProvider("https://your-catena-node-url.com");
async function sendTransaction() {
// Create signer
const senderWallet = new catena.Wallet("0xPRIVATE_KEY", provider);
const receiverAddress = "0xReceiverAddressHere"; // Receiver's address
const amount = "2"; // Amount to send in CTA
// Create transaction
const tx = {
to: receiverAddress ,
value: catena.parseCTA(amount),
gasLimit: 21000n, // Note the 'n' for BigInt literals
gasPrice: 50
};
//Sending transaction
const response = await senderWallet.sendTransaction(tx);
console.log("Transaction sent! Tx Hash:", response.hash);
}
// --- RUN IT --- //
sendTransaction();Explanation:
- Replace "0xPRIVATE_KEY" with your wallet's private key.
- Replace "0xReceiverAddressHere" with the recipient's address.
- The gasLimit and gasPrice values should be adjusted based on the network conditions.
5. Deploy a Smart Contract
You can deploy a smart contract to the Catena blockchain by creating a contract instance and using the deploy() method.
import { catena} from '@creatachain/cat3';
// Connect to Catena node
const provider = new catena.JsonRpcProvider("https://your-catena-node-url.com");
async function deployContract() {
// Create signer for deployment
const wallet = new catena.Wallet("0xPRIVATE_KEY", provider);
// Replace with your contract's ABI and bytecode
const contractABI = [ /* Your contract ABI here */ ];
const contractBytecode = "0xYourContractBytecodeHere";
const factory = new catena.ContractFactory(contractABI, contractBytecode, wallet);
console.log("Deploying contract...");
const contract = await factory.deploy();
await contract.waitForDeployment();
console.log("Contract deployed at:", await contract.getAddress());
}
// --- RUN IT --- //
deployContract();Explanation:
- Replace the contractABI and contractBytecode with your actual smart contract details.
Learn More
- Full Documentation ➔ (Coming Soon)
- API Reference ➔ (Coming Soon)
- Examples & Tutorials ➔ (Coming Soon)
8 months ago