Merkleized Metadata

RFC-0078: Merkleized Metadata Implementation

Calculating Metadata Hash/Digest

import { DedotClient, WsProvider } from 'dedot';
import { MerkleizedMetadata } from 'dedot/merkleized-metadata';

// Create a client
const provider = new WsProvider('wss://rpc.polkadot.io');
const client = await DedotClient.new(provider);

// Get metadata from the client
const metadata = client.metadata;

// - Or refetch it directly via runtime apis
// const metadata = await client.call.metadata.metadataAtVersion(15);

// Define chain-specific information
const chainInfo = {
  // These can be omitted as they'll be fetched from metadata
  // specVersion: client.runtimeVersion.specVersion,
  // specName: client.runtimeVersion.specName,
  // ss58Prefix: 0, // Polkadot

  // These are required
  tokenSymbol: 'DOT'
  decimals: 10,
};

// Create a merkleizer instance
const merkleizer = new MerkleizedMetadata(metadata, chainInfo);

// Calculate metadata hash
const hash = merkleizer.digest();

console.log('Metadata Hash:', hash);

Generating Proofs

Proof for extrinsic

Proof for extrinsic payload

Proof for extrinsic parts

This is equivalent to proofForExtrinsicPayload, except that each part of the transaction’s raw payload is calculated individually.

Last updated

Was this helpful?