Ethers.js is a library for interacting with Ethereum. This guide shows how to integrate Para’s secure signing with both v6 and v5 versions. Build transactions with Ethers API and sign them securely using Para.

Prerequisites

To use Para, you need an API key. This key authenticates your requests to Para services and is essential for integration. Before integrating Para with your application, ensure you have:

  • Completed Para authentication setup in your application (see one of our Setup Guides)
  • A valid Para API key
  • An RPC endpoint for your desired network

Need an API key? Visit the Developer Portal to create API keys, manage billing, teams, and more.

Installation

Choose your package manager to install the Para Ethers integration along with Ethers.js:

npm install @getpara/ethers-v6-integration@alpha ethers@^6

Basic Setup

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

// Initialize Para (ensure authentication is completed before signing)
const para = new Para(Environment.BETA, YOUR_API_KEY);

// Set up the provider with a RPC URL
const provider = new ethers.JsonRpcProvider(YOUR_RPC_URL);

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

// Now you can use the signer with any Ethers.js operations

Usage Examples

Once you’ve set up the Para Ethers Signer, you can use it just like any standard Ethers signer. Para handles the secure signing process without changing how you construct transactions. An example of sending ETH and interacting with a smart contract is provided below.

Sending ETH

// Construct a transaction using the standard Ethers API
const transaction = {
to: "0x1234567890123456789012345678901234567890",
value: ethers.parseEther("0.01"),
// Optional: specify gas parameters
// gasLimit: 21000,
};

// Sign and send the transaction
const tx = await signer.sendTransaction(transaction);
console.log("Transaction hash:", tx.hash);

// Wait for confirmation
const receipt = await tx.wait();
console.log("Transaction confirmed in block:", receipt.blockNumber);

Interacting with Smart Contracts

// Contract ABI (simplified example for ERC-20 transfer)
const abi = [
"function transfer(address to, uint256 amount) returns (bool)"
];

// Contract address for your contract
const contractAddress = "0xTokenContractAddress";

// Create a contract instance with your ParaEthersSigner passed as the signer
const contract = new ethers.Contract(contractAddress, abi, signer);

// Call the contract method
// Para will handle the signing process without modifying the transaction
const tx = await contract.transfer(
"0xRecipientAddress",
ethers.parseUnits("10", 18) // Adjust decimals based on your token
);

console.log("Transaction hash:", tx.hash);

As long as the Para client is authenticated and has wallets available, you can use the full Ethers.js API with the Para Ethers Signer without any additional changes.

ParaEthersSigner Methods

The ParaEthersSigner provides standard Ethers.js signer functionality, allowing you to use Para’s secure signing capabilities:

getAddress()
function
signMessage(message)
function
signTransaction(transaction)
function
signTypedData(...)
function

Para handles only the signing process. It does not modify your transaction in any way. All transaction construction, including gas estimations and parameter settings, is your responsibility through the Ethers.js API.

Important Considerations

When working with the ParaEthersSigner, keep in mind:

  1. Authentication requirement: The Para client must have an authenticated account before attempting any signing operations.

  2. Wallet availability: Ensure Para has wallets available for the EVM wallet type. If you encounter errors about missing wallets, check your developer portal settings for your API key is configured for EVM wallet types.

  3. Transaction construction: Para only signs the raw bytes of the transaction you provide. Any issues related to transaction parameters (gas price, gas limit, etc.) or RPC interactions are not related to Para’s signing functionality. The RPC endpoint or the transaction itself may be the source of any issues.

  4. Network configuration: Make sure your RPC endpoint matches the network configuration in your Para setup. Ensuring you set the correct RPC URL to match the transaction Chain ID is crucial for successful transaction signing and submission.

Server-Side Signing

Para’s signers can also be used on the server-side using pregen wallets or an active client side session. To learn more about using para on the server, check out these guides:

Examples

If you’d like to learn more about how to use the ParaEthersSigner for different transaction types, check out this example in our Examples Hub:

Troubleshooting

Next Steps

Now that you’ve completed signing transactions with Ethers.js, explore more advanced features like Permissions Popups. If you’re ready to kick off your project launch with Para, check out our Go Live Checklist.