Skip to content

fetchFromChain

fetchFromChain(spaceUri): Promise<ISpaceDetails | null>

Fetches space details from the blockchain based on a given space URI.

Parameters

spaceUri: space:cord:${string}

The unique identifier (URI) of the space to be fetched.

Returns

Promise<ISpaceDetails | null>

A promise that resolves to the space details if found. The details include information such as the space URI, creator DID, transaction capacity, and other relevant data.

Remarks

This function queries the CORD blockchain to retrieve details about a specific space, identified by the spaceUri. It decodes the blockchain data into a more accessible format. If the space details are not found or cannot be decoded, the function throws an error.

Throws

  • Thrown when no space is found with the provided URI.

Throws

  • Thrown when an error occurs during the fetching process.

Example

const spaceUri = 'space:example_uri';
fetchFromChain(spaceUri)
.then(spaceDetails => {
console.log('Space Details:', spaceDetails);
})
.catch(error => {
if (error instanceof SDKErrors.ChainSpaceMissingError) {
console.error('Space not found:', spaceUri);
} else {
console.error('Error fetching space from chain:', error);
}
});

Source

chain-space/src/ChainSpace.chain.ts:614