getOffchainMessageV1Decoder

function getOffchainMessageV1Decoder(): VariableSizeDecoder<OffchainMessageV1>;

Returns a decoder that you can use to convert a byte array (eg. one that conforms to the OffchainMessageBytes type) to an OffchainMessageV1 object.

Returns

VariableSizeDecoder<OffchainMessageV1>

Example

import { getOffchainMessageV1Decoder } from '@solana/offchain-messages';
 
const offchainMessageDecoder = getOffchainMessageV1Decoder();
const offchainMessage = offchainMessageDecoder.decode(
    offchainMessageEnvelope.content,
);
console.log(`Decoded a v1 offchain message`);

Throws in the event that the message bytes represent a message of a version other than 1.

On this page