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
# Install via Yarn
yarn add @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.
Now that we have the paymaster object, we can call all sorts of methods upon it.
import { ERC20Token } from"@txfusion/txsync-viem/src/abi/ERC20Token";consttokenAddress='0x...'; // Replace with the actual token address on L2constargs= ['0x...',parseEther(amount)]; // Recipient address and amount to send// Sending transaction:consttxHash=awaitpaymaster.sendPaymasterTransaction( tokenAddress asAddress,// Contract address ERC20Token,// ABI"transfer",// Function to call args, { gasLimit: gasLimit,// Override values },);// Estimate gasconstestimatedGas=paymaster.estimateGas( tokenL2Address asAddress, ERC20Token,"transfer", [recipientAddress,parseEther(amount)], { gasLimit: gasLimit, },);// Getting restrictions:constrestrictions=awaitpaymaster.getExtensions()
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.