Learn how to use the Elder Helper class and React hook to interact with rollups on Shib Alpha Layer.
The Elder Helper class provides a convenient way to interact with rollups through a simple, object-oriented interface. This guide explains how to use the Elder Helper class in your applications to connect to the Elder network and send transactions to your rollup.
The Elder Helper class encapsulates the functionality needed to interact with rollups, including connecting to the Elder network, managing Elder addresses and public keys, sending transactions, and handling configuration parameters.
import { Elder } from "./path-to-elder-helper";import { Wallet } from "ethers";// Initialize your wallet with a private keyconst wallet = new Wallet("your-private-key");// Connect to Elder networkconst elder = await Elder.connect(wallet, { rollID: 1, rollChainID: 1n, // Using BigInt for chain ID eth_rpc: "https://your-eth-rpc-url", // Optional parameters chainName: "your-chain-name", // Defaults to "testnet-4" message: "Custom connection message", // Custom message to sign});// Now you can access the Elder addressconsole.log("Elder address:", elder.address);
import { Contract } from "ethers";import { parseEther } from "ethers/lib/utils";// Prepare a transaction (example with a contract)const contract = new Contract(contractAddress, contractABI, wallet);const tx = await contract.populateTransaction.transfer( recipientAddress, parseEther("0.1"));// Send the transaction using the Elder helperconst { tx_hash, result } = await elder.sendTransaction(tx, { gasLimit: 1000000, value: parseEther("0.01").toBigInt(), // Amount of ETH to send with the transaction});console.log(`Transaction sent with hash: ${tx_hash}`);console.log("Transaction result:", result);
import { useState } from "react";import { BrowserProvider } from "ethers";import { eth_getElderAccountInfoFromSignature, eth_broadcastTx, eth_getElderMsgAndFeeTxRaw } from "elderjs";export function useElder() { // ...hook implementation as in the Elder docs...}
Now that you understand how to use the Elder Helper class and the useElder React hook, you can:
Integrate them into your dApps
Create reusable transaction patterns
Build higher-level abstractions on top of these tools
The Elder Helper class and React hook make it easy to build powerful, user-friendly rollup integrations on Shib Alpha Layer. Start building today and unlock the full potential of your rollup!