PERS SDK - v2.3.26 / Exports / TokenService
Platform-Agnostic Token Service
Contains token business logic and operations that work across platforms. No framework dependencies - pure TypeScript business logic. Matches framework TokenApiService capabilities exactly.
- getRemoteTokens
- getRemoteTokenTypes
- getRemoteActiveCreditToken
- getRemoteRewardTokens
- getRemoteStatusTokens
- getTokenByContractAddress
- getTokenMetadata
- getRewards
- getStamps
- createTokenMetadata
- updateTokenMetadata
- toggleTokenActive
- createToken
- updateToken
- setMainnetContract
- toggleTokenMetadataStatus
- createTokenType
- deleteTokenMetadata
- exportMetadataCSV
• new TokenService(tokenApi): TokenService
| Name | Type |
|---|---|
tokenApi | TokenApi |
token/services/token-service.ts:25
▸ getRemoteTokens(options?): Promise<PaginatedResponseDTO<TokenDTO>>
PUBLIC: Get all remote tokens with pagination
| Name | Type |
|---|---|
options? | PaginationOptions |
Promise<PaginatedResponseDTO<TokenDTO>>
token/services/token-service.ts:34
▸ getRemoteTokenTypes(options?): Promise<PaginatedResponseDTO<TokenTypeDTO>>
PUBLIC: Get all remote token types with pagination
| Name | Type |
|---|---|
options? | PaginationOptions |
Promise<PaginatedResponseDTO<TokenTypeDTO>>
token/services/token-service.ts:41
▸ getRemoteActiveCreditToken(): Promise<TokenDTO>
PUBLIC: Get active credit token
Promise<TokenDTO>
token/services/token-service.ts:48
▸ getRemoteRewardTokens(options?): Promise<PaginatedResponseDTO<TokenDTO>>
AUTH: Get reward tokens with pagination
| Name | Type |
|---|---|
options? | PaginationOptions |
Promise<PaginatedResponseDTO<TokenDTO>>
token/services/token-service.ts:55
▸ getRemoteStatusTokens(options?): Promise<PaginatedResponseDTO<TokenDTO>>
AUTH: Get status tokens with pagination
| Name | Type |
|---|---|
options? | PaginationOptions |
Promise<PaginatedResponseDTO<TokenDTO>>
token/services/token-service.ts:62
▸ getTokenByContractAddress(contractAddress, contractTokenId): Promise<TokenDTO>
PUBLIC: Get token by contract address ✅ FIXED: Matches framework parameter types exactly
| Name | Type |
|---|---|
contractAddress | string |
contractTokenId | null | string |
Promise<TokenDTO>
token/services/token-service.ts:70
▸ getTokenMetadata(options?): Promise<PaginatedResponseDTO<TokenMetadataDTO>>
Get all token metadata with filtering, pagination, and include relations
Useful for displaying rewards (ERC1155) or stamps (ERC721) in tables. Non-admin users always get active metadata only.
| Name | Type | Description |
|---|---|---|
options? | TokenMetadataQueryParams | Filter, pagination, and include options |
Promise<PaginatedResponseDTO<TokenMetadataDTO>>
Paginated response with token metadata
Example
const rewards = await tokenService.getTokenMetadata({
tokenType: 'ERC1155',
include: ['mintCount', 'burnCount', 'token']
});token/services/token-service.ts:91
▸ getRewards(options?): Promise<PaginatedResponseDTO<TokenMetadataDTO>>
Get rewards (ERC1155 token metadata) with filtering, pagination, and include relations
Convenience method for fetching reward metadata.
| Name | Type | Description |
|---|---|---|
options? | RewardsFilterOptions | Filter, pagination, and include options (tokenType is set automatically) |
Promise<PaginatedResponseDTO<TokenMetadataDTO>>
Paginated response with reward metadata
Example
const rewards = await tokenService.getRewards({
include: ['mintCount', 'burnCount', 'token', 'ownerBusiness']
});token/services/token-service.ts:110
▸ getStamps(options?): Promise<PaginatedResponseDTO<TokenMetadataDTO>>
Get stamps (ERC721 token metadata) with filtering, pagination, and include relations
Convenience method for fetching stamp metadata.
| Name | Type | Description |
|---|---|---|
options? | StampsFilterOptions | Filter, pagination, and include options (tokenType is set automatically) |
Promise<PaginatedResponseDTO<TokenMetadataDTO>>
Paginated response with stamp metadata
Example
const stamps = await tokenService.getStamps({
include: ['mintCount', 'burnCount', 'token', 'ownerBusiness']
});token/services/token-service.ts:129
▸ createTokenMetadata(tokenId, tokenData): Promise<TokenDTO>
ADMIN: Create token metadata
| Name | Type |
|---|---|
tokenId | string |
tokenData | TokenMetadataCreateRequestDTO |
Promise<TokenDTO>
token/services/token-service.ts:140
▸ updateTokenMetadata(metadataId, tokenData): Promise<TokenMetadataDTO>
ADMIN: Update token metadata (ERC721 only) Note: Existing minted NFTs retain their original metadata - this only affects future mints
| Name | Type |
|---|---|
metadataId | string |
tokenData | TokenMetadataCreateRequestDTO |
Promise<TokenMetadataDTO>
token/services/token-service.ts:148
▸ toggleTokenActive(tokenId): Promise<TokenDTO>
ADMIN: Toggle token active status
| Name | Type |
|---|---|
tokenId | string |
Promise<TokenDTO>
token/services/token-service.ts:155
▸ createToken(tokenData): Promise<TokenDTO>
ADMIN: Create new token
| Name | Type |
|---|---|
tokenData | TokenCreateRequestDTO |
Promise<TokenDTO>
token/services/token-service.ts:162
▸ updateToken(tokenId, tokenData): Promise<TokenDTO>
ADMIN: Update token
| Name | Type |
|---|---|
tokenId | string |
tokenData | TokenUpdateRequestDTO |
Promise<TokenDTO>
token/services/token-service.ts:169
▸ setMainnetContract(tokenId, contractAddress, chainId): Promise<TokenDTO>
ADMIN: Set mainnet contract address
| Name | Type |
|---|---|
tokenId | string |
contractAddress | string |
chainId | number |
Promise<TokenDTO>
token/services/token-service.ts:176
▸ toggleTokenMetadataStatus(metadataId): Promise<TokenMetadataDTO>
ADMIN: Toggle token metadata status
| Name | Type |
|---|---|
metadataId | string |
Promise<TokenMetadataDTO>
token/services/token-service.ts:183
▸ createTokenType(tokenType): Promise<TokenTypeDTO>
ADMIN: Create token type
| Name | Type |
|---|---|
tokenType | TokenTypeDTO |
Promise<TokenTypeDTO>
token/services/token-service.ts:190
▸ deleteTokenMetadata(metadataId): Promise<void>
ADMIN: Delete token metadata (soft delete)
Soft deletes token metadata. Will fail if metadata is in use.
| Name | Type | Description |
|---|---|---|
metadataId | string | ID of the token metadata to delete |
Promise<void>
Throws
409 Conflict if metadata is in use by campaigns/redemptions
token/services/token-service.ts:202
▸ exportMetadataCSV(options?): Promise<Blob>
ADMIN: Export token metadata to CSV
Returns a CSV file containing all token metadata for the tenant. Supports date range filtering.
| Name | Type | Description |
|---|---|---|
options? | Object | Export options (dateFrom, dateTo) |
options.dateFrom? | string | - |
options.dateTo? | string | - |
Promise<Blob>
Promise resolving to CSV blob
Throws
When not authenticated as tenant admin