Skip to main content

Custom Market Metadata

You specify a custom market metadata type that extends the zeitgeist standard or that is a completely different type.


If you do not adhere to the zeitgeist official metadata specification your created markets might not show up in the indexer and the application.

1. Creating the type.

First we construct a type of custom market metadata we want to attach to our markets.

type CustomMarketMetadata = {
__meta: "markets";
customValue: string;

Note that the literal tag __meta: "markets" is required on the custom market metadata type.

2. Initializing the SDK

Next we initialize the sdk with the custom metadata as a generic.

const sdk = await create(

Or if we want to use a local test node

const sdk = await create<MetadataStorage<CustomMarketMetadata>>({
provider: "wss://localhost:9944",
storage: createStorage({
node: { url: "localhost:5001" },

3. Creating a custom Market

Then we can create a market with the custom metadata.

const params: CreateStandaloneMarketParams<typeof sdk> = {
metadata: {
__meta: 'markets',
customValue: 'custom text value',

const response = await
const { market } = await response.saturate().unwrap()

const marketMetadata: CustomMarketMetadata = await market.fetchMetadata().unwrap()

console.log(`Market created with custom metadata: ${marketMetadata.customValue}`)

Using typescript will give you strong type checking when creating and fetching metadata for markets with custom metadata types.

4. Extending Standard Metadata (optional)

If you want to make sure the market shows up in the indexer and the application you should extend the standard metadata.

import { MarketMetadata } from "@zeitgeistpm/sdk";

type CustomMarketMetadata = MarketMetadata & {
__meta: "markets";
customValue: string;

Note that in this example you would also have to pass question, description etc to the metadata when creating a market.

Ref official metadata spec

Indexer and Custom Metadata


Note that the custom metadata is not indexed and if you want to use it in your application you have to fetch it manually.

We can still fetch it after the market is fetched if we have access to rpc/storage.

const sdk = await create(

const market = (await!;

// Question, slug etc are indexed so can be accessed directly

// the custom value have to be fetched from IPFS
const metadata = await market.fetchMetadata().unwrap();