txSync SDK
HomeBlogProjectsCreate ZK Chains
  • 👋Introduction
  • 🚀Getting Started
    • Installation Guide
    • Quick Start Guide
  • 🛠️SDKs
    • 📦@txfusion/txsync-sdk
      • 🚀 Quick start
      • 📝 API
        • Paymaster
        • Restrictions
      • 🧑‍🍳 Examples
      • 🤝 Contributing
    • 📦@txfusion/txsync-viem
      • 🚀 Quick start
      • 📝 API
        • Paymaster
        • Extensions
      • 🧑‍🍳 Examples
      • 🤝 Contributing
  • 🔌Product Integration
    • Portal
    • Bridge
    • Tsuko
    • Visor
    • ZK Chains
    • Playground
Powered by GitBook
On this page
  • 📥 Installation & setup
  • Install the @txfusion/txsync-sdk package
  • Get your paymaster object
  • Using paymaster methods
  1. SDKs
  2. @txfusion/txsync-sdk

🚀 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
# Install via Yarn
yarn add @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.

Previous@txfusion/txsync-sdkNext📝 API

Last updated 6 months ago

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

🛠️
📦
API
Examples