Skip to content

dispatchUpdateToChain

dispatchUpdateToChain(stmtEntry, creatorUri, authorAccount, authorizationUri, signCallback): Promise<StatementUri>

Dispatches a statement update transaction to the CORD blockchain.

Parameters

stmtEntry: IStatementEntry

The statement entry object containing the necessary information for updating the statement on the blockchain. This includes the digest, element URI, creator URI, space URI, and optionally a schema URI.

creatorUri: did:cord:3${string}

The DID URI of the creator of the statement. This identifier is used to authorize the transaction.

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.

signCallback: SignExtrinsicCallback

A callback function that handles the signing of the transaction.

Returns

Promise<StatementUri>

The element URI of the updated statement.

Remarks

This function is used to update an existing statement on the blockchain. It first checks if the statement with the given digest and space URI already exists. If it does, the function constructs and submits a transaction to update the statement. The transaction is authorized by the creator and signed by the provided author account.

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

const stmtEntry = {
// ... initialization of statement properties ...
};
const creatorUri = 'did:cord:creator_uri';
const authorAccount = // ... initialization ...
const authorizationUri = 'auth:cord:example_uri';
const signCallback = // ... implementation ...
dispatchUpdateToChain(stmtEntry, creatorUri, authorAccount, authorizationUri, signCallback)
.then(statementUri => {
console.log('Statement updated with URI:', statementUri);
})
.catch(error => {
console.error('Error dispatching statement update to chain:', error);
});

Source

statement/src/Statement.chain.ts:342