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
  • createExtension
  • types
  • PaymasterParams
  • PaymasterType
  • ExtensionMethod
  • PaymasterOptions
  • PaymasterOverrides
  • BaseRestrictionItem
  • AddressOrBaseRestrictionItem
  • ContractItems
  • UserItems
  • FunctionItems
  • RestrictionItems
  1. SDKs
  2. @txfusion/txsync-viem
  3. 📝 API

Extensions

Extensions are external smart contracts that can be added to the Paymaster contract. These extensions are used to enforce specific conditions or rules that must be met for a transaction to be eligible

PreviousPaymasterNext🧑‍🍳 Examples

Last updated 9 months ago

createExtension

async function createExtension(
  name: string,
  type: ExtensionMethod,
  wallet: WalletClient,
  client: unknown,
  items?: ExtensionItems,
  restrictionFactoryABI?: Abi,
  restrictionFactoryContractAddress?: Address
): Promise<Address>

Deploys a new extension contract based on the provided parameters.

  • name: string - The name of the extension contract to be created.

  • type: - The type of extension contract to be created. It can be one of the following: CONTRACT, USER, or FUNCTION

  • wallet: WalletClient: A WalletClient instance used for signing transactions and interacting with the Restriction Factory contract.

  • client: PublicClient: A PublicClient instance used for writing public transactions.

  • items: (optional) - An object containing the items (e.g., contract addresses, user addresses, function signatures with contract addresses) related to the extension being created.

  • restrictionFactoryABI: Abi (optional) - The ABI of the Restriction Factory contract. If not provided, it will be retrieved based on the chain ID.

  • restrictionFactoryContractAddress: Address (optional) - The address of the Restriction Factory contract. If not provided, it will be retrieved based on the chain ID.

  • Returns: Address: address of the deployed extension.

types

PaymasterParams

export type PaymasterParams = {
  /** The address of the paymaster. */
  paymaster: Address;
  /** The bytestream input for the paymaster. */
  paymasterInput: BytesLike;
};

PaymasterType

export enum PaymasterType {
  ERC20,
  SPONSORED,
}

ExtensionMethod

export enum ExtensionMethod {
  CONTRACT,
  USER,
  FUNCTION,
}

PaymasterOptions

export interface PaymasterOptions {
  innerInput?: BytesLike;
  minimalAllowance?: bigint;
}

PaymasterOverrides

export interface PaymasterOverrides
  extends Omit<TransactionRequest, 'from' | 'type' | 'gasPrice'> {
  paymasterOptions?: PaymasterOptions;
  gasLimit?: bigint;
  gasPrice?: bigint;
  customData?: PaymasterParams;
}

BaseRestrictionItem

export type BaseRestrictionItem = {
  address: Address;
};

AddressOrBaseRestrictionItem

export type AddressOrBaseRestrictionItem = Address | BaseRestrictionItem;

ContractItems

export type ContractItems = AddressOrBaseRestrictionItem[];

UserItems

export type UserItems = AddressOrBaseRestrictionItem[];

FunctionItems

export type FunctionItems = (BaseRestrictionItem & {
  functionSignature: string;
})[];

RestrictionItems

export type RestrictionItems = ContractItems | UserItems | FunctionItems;

A tuple type representing the parameters for several methods of Paymaster instance, like . Added for easier usage.

🛠️
📦
ExtensionMethod
ExtensionItems
sendPaymasterTransaction