πŸš€ Quick start

Starting guide on how to quickly integrate the @txfusion/txsync-viemπŸš€

πŸ“₯ 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-viem package

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

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

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 } from "@txfusion/txsync-viem";
import { createWalletClient, custom } from 'viem';
import { zkSync } from 'viem/chains';
import { eip712WalletActions } from 'viem/zksync';

// Get the account
const [account] = await window.ethereum!.request({ method: "eth_requestAccounts" });

// Create walletClient object
const walletClient = createWalletClient({
  account,
  chain: zkSync,
  transport: custom(window.ethereum),
}).extend(eip712WalletActions());

// Create publicClient object
const publicClient = createPublicClient({
  chain: zkSync,
  transport: http(),
});

// Get paymaster object
const paymaster = await getPaymaster(
  paymasterAddress,
  walletClient,
  publicClient
);

console.log(`PaymasterType: ${paymaster.paymasterType}`);
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.

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