Claim Calldata (claim and permitClaim)

The claimCalldata and permitClaimCalldata methods generate the calldata required to claim a Note Position ERC-721 token.

Claim (claimCalldata)

Usage

import { SupportedChainIds, claimCalldata } from "@parabolfi/core";
 
async function generateClaimCalldata() {
  const tokenId = 6n;
 
  const calldata = claimCalldata({
    walletAddress,
    tokenId,
  });
 
  console.log("Claim calldata:", calldata);
}

Parameters

  • walletAddress: Address - The wallet address of the claimer.
  • tokenId: bigint - The ID of the token to claim.

Returns

  • string - The generated calldata for the claiming operation.
0xaad3ec96...

Important Notes

  • The wallet address must be a valid Ethereum address.
  • This method is used for claiming a Note Position ERC-721 token.
  • The method validates the input parameters and throws a ParabolSDKError if they are invalid.
ℹ️

To call the claim function, the position’s maturity must have been reached.

Permit Claim (permitClaimCalldata)

Before using this method, you need to get a permit signature.

⚠️ Important Notes

To use Permit Claim, a signature must be obtained from the user. The required domain, types, and data for this signature can be retrieved using the preparePermitClaimSignature helper function. However, the NonFungibleNotePositionName, and NonFungibleNotePositionVersion information required for this function must be fetched using the fetchParabolConfig and nonce from the fetchNonFungibleNotePositionNonce functions in the ParabolServer class. All steps are outlined below.

Fetch server-side information from ParabolServer

import { ParabolServer } from "@parabolfi/server";
import { SupportedChainIds } from "@parabolfi/core";
 
const parabolServer = new ParabolServer({
  apiKey,
});
 
const chainId = SupportedChainIds.ZKSYNC;
const response = await parabolServer.fetchParabolConfig([chainId]);
const parabolConfig = response[chainId];
 
if (!parabolConfig) {
  throw new Error("Parabol config not found");
}
 
const { NonFungibleNotePositionName, NonFungibleNotePositionVersion } =
  parabolConfig;
 
const nonceResponse = await parabolServer.fetchNonFungibleNotePositionNonce(
  walletAddress,
  [chainId]
);
 
const nonce = BigInt(nonceResponse[chainId]?.nonce) ?? 0n;
ℹ️

The NonFungibleNotePositionName and NonFungibleNotePositionVersion are used to construct the domain object in the preparePermitClaimSignature function. If you want, you can leave this part hardcoded after fetching it once.

Generate the signature

import { preparePermitClaimSignature } from "@parabolfi/core";
 
const tokenId = 6n;
const { domain, types, data, deadline } = preparePermitClaimSignature({
  chainId,
  tokenId,
  nonce,
  NonFungibleNotePositionName,
  NonFungibleNotePositionVersion,
});
 
// viem account signTypedData
const permitSignature = await account.signTypedData({
  domain,
  types,
  message: data,
  primaryType: "Permit",
});
ℹ️

You can use any method to sign the typed data.

Generate the calldata

import { permitClaimCalldata } from "@parabolfi/core";
 
const calldata = permitClaimCalldata({
  walletAddress,
  tokenId,
  permitSignature,
  deadline,
});

Parameters

  • walletAddress: Address - The wallet address of the claimer.
  • tokenId: bigint - The ID of the token to claim.
  • permitSignature: Hex - The permit signature.
  • deadline: bigint - The deadline for the permit.

Returns

  • string - The generated calldata for the permit claiming operation.
0x9d2d3586...

Notes

  • The wallet address must be a valid Ethereum address.
  • The permit signature must be a valid Ethereum signature.
  • The deadline is the timestamp at which the permit will expire. It is calculated as currentTimestamp + 1 hour.
  • This method is used for gasless transactions where the user signs a permit instead of sending an approval transaction.
  • It allows claiming a Note Position ERC-721 token without the need for a separate approval transaction.
  • The method validates the input parameters and throws a ParabolSDKError if they are invalid.