Ethers.js is a powerful library for interacting with the Ethereum blockchain. This guide will show you how to integrate Para’s signing capabilities with both Ethers v6 and v5, allowing you to securely manage and sign transactions using Para’s secure infrastructure.

Prerequisites

Before integrating Para with Ethers.js, ensure you have:

  • Set up authentication with Para. See our Getting Started guides for detailed instructions.
  • Configured the Para client in your application
  • Access to an Ethereum node or RPC provider URL

If you haven’t set up Para authentication yet, complete one of our authentication tutorials first and return to this guide when you’re ready to implement signing.

Ethers v6

Installation

Choose your preferred package manager to install the required dependencies:

Usage

First, set up the Para Ethers signer:

import { ParaEthersSigner } from "@getpara/ethers-v6-integration";
import { ethers } from "ethers";
import Para from "@getpara/web-sdk";

// Initialize Para
const para = new Para(Environment.BETA, YOUR_API_KEY);

// Set up the provider
const provider = new ethers.JsonRpcProvider(YOUR_RPC_URL);

// Create the Para Ethers Signer
const ethersSigner = new ParaEthersSigner(para, provider);

To sign transactions:

import { TransactionRequest } from "ethers";

// Construct the transaction
const transaction: TransactionRequest = {
  from: "0x...", // Your address
  to: "0x...", // Recipient address
  value: ethers.parseUnits("0.1", "ether"),
  // Configure other transaction parameters as needed
};

// Call the signTransaction method to sign the transaction
const signedTx = await ethersSigner.signTransaction(transaction);

The v6 signer supports all standard signing operations including signMessage() and signTypedData() for EIP-712 formatted data.

Ethers v5

Installation

Install the v5-specific integration package:

Usage

Set up the v5 signer:

import { ParaEthersSigner } from "@getpara/ethers-v5-integration";
import { ethers } from "ethers";
import Para from "@getpara/web-sdk";

// Initialize Para
const para = new Para(Environment.BETA, YOUR_API_KEY);

// Set up the provider
const provider = new ethers.providers.JsonRpcProvider(YOUR_RPC_URL);

// Create the Para Ethers Signer
const ethersSigner = new ParaEthersSigner(para, provider);

// Basic operations
const address = await ethersSigner.getAddress();
const balance = await provider.getBalance(address);
console.log("Balance:", ethers.utils.formatEther(balance));

Server-Side Usage

Para can also be used for server-side signing alongside Ethers.js. See our

Server-Side Signing Guide for more details on setting up server-side signing with Para.

Additional Resources