npm i zyfi-agw-plugin
pnpm i zyfi-agw-plugin
yarn add zyfi-agw-plugin
Sign up at our Dashboard and create API key.
import { createAbstractClient } from '@abstract-foundation/agw-client';
import { createZyfiPaymaster } from 'zyfi-agw-plugin';
const abstractClient = await createAbstractClient({
signer,
chain,
transport: http(),
customPaymasterHandler: createZyfiPaymaster({
apiKey: 'YOUR-API-KEY',
sponsorshipRatio: 100,
}),
});
import { createZyfiPaymaster } from "zyfi-agw-plugin";
// ...
// initialize session key
// ...
// Create a session client
const sessionClient = createSessionClient({
account: account.address!,
chain: abstractTestnet,
signer: sessionSigner,
session: session,
paymasterHandler: createZyfiPaymaster({
apiKey: 'YOUR API KEY',
generalFlow: true,
});,
});
// send sponsored transaction
await sessionClient.sendTransaction({
account: account.address!, // OR maybe sessionClient.account
to: "0xC4822AbB9F05646A9Ce44EFa6dDcda0Bf45595AA",
data: encodeFunctionData({
abi: MINT_ABI,
functionName: "mint",
args: [session.signer, BigInt(1)],
}),
chain: abstractTestnet,
});
Parameter | Description | Required |
---|---|---|
apiKey |
Your API key. Get it from Dashboard | Yes |
feeTokenAddress |
The address of the token to be used for fee payment | No |
checkNFT |
Whether to check for NFT ownership for fee payment | No |
isTestnet |
Whether the transaction is on a testnet | No |
sponsorshipRatio |
The ratio of fees to be sponsored by the paymaster (0-100) | No |
replayLimit |
Determines the user nonces interval for which the response will be valid (current nonce + replayLimit) | No |
generalFlow |
Turn it on when using session keys | No |