🚀 Quick start

Starting guide on how to quickly integrate the @txfusion/txsync-sdk 🚀

📥 Installation & setup

Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.

You can generate an API key from your Dashboard at any time.

Install the @txfusion/txsync-sdk package

The first step to interact with our API is to install the official library:

# Install via NPM
npm install @txfusion/txsync-sdk

Get your paymaster object

To be able to work with the paymaster and call the methods of the Paymaster object, you first need to get it by passing the address of the paymaster contract.

import { getPaymaster, createRestriction, types, typechain } from "@txfusion/txsync-sdk";
import { BrowserProvider } from "zksync-ethers";

// Create signer
const signer = await new BrowserProvider(window.ethereum!).getSigner();

// Get paymaster
const paymaster = await getPaymaster(paymasterAddress, signer);

console.log(`PaymasterType: ${paymaster.paymasterType === types.PaymasterType.ERC20 ? "ERC20" : "Sponsored"}`)
console.log(`Token Address: ${paymaster.token}`);

Using paymaster methods

Now that we have the paymaster object, we can call all sorts of methods upon it.

// Sending transaction:
const txResponse = await paymaster.sendPaymasterTransaction(greeterAddress, functionToCallSignature, args);

// Populating a transaction:
const populatedTx = await paymaster.populatePaymasterTransaction(...PaymasterParams);

// Estimating gas:
const gasLimit = await paymaster.estimateGas(populatedTx);

// Getting restrictions:
const restrictions = await paymaster.getRestrictions()

Above are just quick examples.

You can find how these and many other methods work, which arguments they accept, and how they interact deeply explained in the API section and the Examples section.

Last updated