dispatchRegisterToChain
dispatchRegisterToChain(
stmtEntry,authorAccount,authorizationUri):Promise<StatementUri>
This function dispatches a statement entry to a blockchain after preparing the extrinsic and signing it.
Parameters
Section titled “Parameters”• stmtEntry: IStatementEntry
The statement entry object containing the necessary information for registering the statement on the blockchain. This includes the digest, element URI, creator URI, space URI, and optionally a schema URI.
• authorAccount: CordKeyringPair
The blockchain account used to sign and submit the transaction.
• authorizationUri: `auth:cord:${string}`
The URI of the authorization used for the statement.
Returns
Section titled “Returns”Promise<StatementUri>
The element URI of the registered statement.
Remarks
Section titled “Remarks”This function is responsible for registering a new statement on the blockchain. It checks if the statement with the given digest and space URI already exists on the chain. If it does not exist, the function constructs and submits a transaction to register the statement. The transaction is authorized by the creator and signed by the provided author account.
Throws
Section titled “Throws”- Thrown when there is an error during the dispatch process, such as issues with constructing the transaction, signing, or submission to the blockchain.
Example
Section titled “Example”const stmtEntry = { // ... initialization of statement properties ...};const creatorUri = 'did:cord:creator_uri';const authorAccount = // ... initialization ...const authorizationUri = 'auth:cord:example_uri';const signCallback = // ... implementation ...
dispatchRegisterToChain(stmtEntry, creatorUri, authorAccount, authorizationUri, signCallback) .then(statementUri => { console.log('Statement registered with URI:', statementUri); }) .catch(error => { console.error('Error dispatching statement to chain:', error); });