Skip to main content

Integration

Installation

First, install the required packages for initializing the Paymaster.

npm install @abstraxn/relayer

Usage

Before using the Relayer, initialize it with the required configuration:

import { Relayer } from "@abstraxn/relayer";
import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider("<RPC_URL>");
const signer = new ethers.Wallet("<PRIVATE_KEY>", provider);

const relayer = new Relayer({
relayerUrl: "YOUR_RELAYER_URL",
chainId: 1,
signer,
provider,
});

Building a Relayer Transaction

To build a transaction before sending it to the relayer:

const txParams = {
abi: contractAbi,
contractAddress: "0xContractAddress",
method: "transfer",
args: ["0xRecipientAddress", ethers.parseUnits("1", 18)],
};

const txData = await relayer.buildRelayerTx(txParams);
console.log("Transaction Data:", txData);

Sending a Relayer Transaction

Once the transaction is built, send it using:

const response = await relayer.sendRelayerTx(txData);

console.log("Transaction ID:", response.transactionId);

Checking Transaction Status

Monitor the transaction status using:

const status = await relayer.getRelayerTxStatus(response.transactionId);
console.log("Transaction Status:", status);

Conclusion

This guide provided an overview of setting up and using the Relayer SDK to interact with smart contracts. For more details, refer to the official documentation.