NFT Subscription SDK

API Reference

Initialization

new SubscriptionSDK({ chain: 'sepolia', walletClient })

Core Methods

MethodParametersReturns
subscribe(merchantId: bigint, token: Address | "ETH")Promise<Hash>
checkAccess(merchantId: bigint, address?: Address)Promise<boolean>
getMerchantBalance(merchantId: bigint, token: Address | "ETH")Promise<bigint>
withdrawMerchantBalance(merchantId: bigint, token: Address | "ETH")Promise<Hash>
formatAmount(amount: bigint, decimals: number)string
parseAmount(amount: string, decimals: number)bigint
waitForTransaction(hash: Hash)Promise<TransactionReceipt>
getAddress()Address | undefined
isConnected()boolean
getChainId()number
getContracts()ContractAddresses

Merchant Methods (v2)

MethodParametersReturns
registerMerchantWithMetadata(params: RegisterMerchantParams)Promise<{hash, merchantId, metadataStored}>
getMerchantMetadata(merchantId: bigint)Promise<MerchantMetadata | null>
updateMerchantMetadata(params: UpdateMetadataParams)Promise<boolean>
getMerchantComplete(merchantId: bigint)Promise<{onChain, metadata}>
registerMerchant(params: OnChainParams)Promise<{hash, merchantId}>
setMerchantPrice(params: PriceParams)Promise<Hash>
getMerchantPlan(merchantId: bigint)Promise<MerchantPlan>
withdrawMerchantBalance(params: WithdrawParams)Promise<Hash>

Services

MethodParametersReturns
sdk.merchantsMerchantServiceFull merchant management with v2 metadata support
sdk.subscriptionsSubscriptionServicesubscribe, getSubscriptionStatus, isSubscriptionActive, getSubscriptionPrice
sdk.tokensTokenServicegetTokenInfo, getBalance, approve, approveIfNeeded
sdk.nftsNFTServicegetBalance, safeTransferFrom, getFullMetadata, getTokenURI
sdk.eventsEventMonitoringServicemonitorPaymentEvents, monitorSubscriptionLifecycle, stopMonitoring
sdk.analyticsAnalyticsServicegetPlatformStatistics, getMerchantStatistics, getMerchantRevenue
sdk.adminAdminServicesetPlatformFee, pausePlatform, withdrawPlatformFees
sdk.reactiveReactiveNetworkServicesubscribeToPaymentEvents, subscribeToCronJob, watchReactiveEvents

Event Monitoring

MethodParametersReturns
startEventMonitoring(listeners: EventListeners)void
stopEventMonitoring()void
on(event: string, callback: Function)void
off(event: string, callback: Function)void

Types

SDKConfig

chain?string
walletClient?WalletClient
publicClient?PublicClient
privateKey?string
rpc?string
readOnly?boolean

RegisterMerchantParams (v2)

payoutAddress?Address
subscriptionPeriod?number
gracePeriod?number
name?string
description?string (optional)
logo?string (optional)
metadataApiUrl?string (optional)

MerchantMetadata

merchantId?string
name?string
description?string
logo?string | null
createdAt?string
updatedAt?string

SubscriptionStatus

isActive?boolean
expiresAt?bigint
renewalCount?bigint
lastRenewal?bigint
merchantId?bigint

EventListeners

onPaymentReceived?EventCallback<PaymentEvent>
onSubscriptionMinted?EventCallback<SubscriptionMintedEvent>
onSubscriptionRenewed?EventCallback<SubscriptionRenewedEvent>
onSubscriptionExpired?EventCallback<SubscriptionExpiredEvent>
onMerchantRegistered?EventCallback<MerchantRegisteredEvent>
onMerchantWithdrawal?EventCallback<MerchantWithdrawalEvent>

Events

payment:received
subscription:minted
subscription:renewed
subscription:expired
merchant:registered
merchant:withdrawal