Skip to main content

Documentation Index

Fetch the complete documentation index at: https://yieldxyz.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Overview

EVM transactions returned by the Yield.xyz API can be signed using any Ethereum-compatible library. Below you’ll find examples for the three most popular options.

ethers.js

ethers.js is one of the most widely adopted Ethereum libraries, offering a clean API for wallets, providers, and contract interaction.

Installation

npm install ethers

Signing a Transaction

import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);

async function signAndSend(unsignedTx) {
  const tx = await wallet.sendTransaction({
    to: unsignedTx.to,
    data: unsignedTx.data,
    value: unsignedTx.value ?? 0,
    gasLimit: unsignedTx.gasLimit,
  });

  const receipt = await tx.wait();
  console.log("Transaction hash:", receipt.hash);
  return receipt;
}
ethers.Wallet handles nonce management and gas estimation automatically when connected to a provider.