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

Restrictions

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

PreviousPaymasterNext🧑‍🍳 Examples

Last updated 11 months ago

createRestriction

async function createRestriction(
  name: string,
  type: RestrictionMethod,
  runner: Signer | Wallet,
  items?: RestrictionItems,
  restrictionFactoryContractAddress?: string
): Promise<Address>

Deploys a new restriction contract based on the provided parameters.

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

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

  • runner: Signer | Wallet: A Signer or Wallet instance used for signing transactions and interacting with the Restriction Factory contract.

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

  • 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 restriction.

types

PaymasterParams

export type PaymasterParams = [Address, InterfaceAbi, any[]?, PaymasterOverrides?];

PaymasterType

export enum PaymasterType {
  ERC20,
  SPONSORED,
}

RestrictionMethod

export enum RestrictionMethod {
  CONTRACT,
  USER,
  FUNCTION,
}

PaymasterOptions

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

PaymasterOverrides

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

BaseRestrictionItem

export type BaseRestrictionItem = {
  address: string;
};

AddressOrBaseRestrictionItem

export type AddressOrBaseRestrictionItem = string | 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;

typechain

export type { ContractRestriction };
export type { ERC20Paymaster };
export type { ERC20Token };
export type { Factory };
export type { FunctionRestriction };
export type { IRestriction };
export type { RestrictionFactory };
export type { SponsoredPaymaster };
export type { UserRestriction };
export { ContractRestriction__factory };
export { ERC20Paymaster__factory };
export { ERC20Token__factory };
export { Factory__factory };
export { FunctionRestriction__factory };
export { IRestriction__factory };
export { RestrictionFactory__factory };
export { SponsoredPaymaster__factory };
export { UserRestriction__factory };

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

🛠️
📦
RestrictionMethod
RestrictionItems
populatePaymasterTransaction
sendPaymasterTransaction
checkTransactionEligibility
getMinimalAllowance