verifyOffchainMessageEnvelope

function verifyOffchainMessageEnvelope(
    offchainMessageEnvelope,
): Promise<void>;

Asserts that there are signatures present for all of an offchain message's required signatories, and that those signatures are valid given the message.

Parameters

ParameterType
offchainMessageEnvelopeOffchainMessageEnvelope

Returns

Promise<void>

Example

import { isSolanaError, SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE } from '@solana/errors';
import { verifyOffchainMessageEnvelope } from '@solana/offchain-messages';
 
try {
    await verifyOffchainMessageEnvelope(offchainMessageEnvelope);
    // At this point the message is valid and signed by all of the required signatories.
} catch (e) {
    if (isSolanaError(e, SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE)) {
        if (e.context.signatoriesWithMissingSignatures.length) {
            console.error(
                'Missing signatures for the following addresses',
                e.context.signatoriesWithMissingSignatures,
            );
        }
        if (e.context.signatoriesWithInvalidSignatures.length) {
            console.error(
                'Signatures for the following addresses are invalid',
                e.context.signatoriesWithInvalidSignatures,
            );
        }
    }
    throw e;
}

On this page