Skip to content

fetchRatingDetailsfromChain

fetchRatingDetailsfromChain(ratingUri, timeZone?): Promise<IRatingChainStatus | null>

Fetches and decodes the details of a specific rating entry from the blockchain.

This asynchronous function is designed to retrieve a rating entry from the blockchain using its URI. It translates the blockchain’s encoded rating entry into a more readable and structured format. If the rating entry is found, it decodes the details using the decodeEntryDetailsfromChain function. If the entry does not exist on the blockchain, the function returns null. This function is crucial for retrieving and interpreting rating data stored on the blockchain, making it accessible and usable for further processing or display.

Parameters

ratingUri: rating:cord:${string}

The URI of the rating entry to be fetched from the blockchain.

timeZone?: string= 'GMT'

The timezone to be used for date and time conversions (default is ‘GMT’).

Returns

Promise<IRatingChainStatus | null>

  • A promise that resolves to the decoded rating entry details or null if not found.

Example

// Example usage of the function
const ratingUri = 'ratingUri123';
fetchRatingDetailsfromChain(ratingUri, 'GMT')
.then(entryDetails => {
if (entryDetails) {
console.log('Rating Entry Details:', entryDetails);
} else {
console.log('Rating Entry not found on the chain.');
}
})
.catch(error => {
console.error('Error fetching rating details:', error);
});

Source

network-score/src/Scoring.chain.ts:519