Store and Retrieve Data on the Bulletin Chain¶
Introduction¶
The Bulletin Chain is a Polkadot SDK runtime, developed by Parity in the paritytech/polkadot-bulletin-chain repository, that provides data storage with IPFS-compatible content addressing through its TransactionStorage and DataRenewal pallets. You can use it to store static sites, images, media assets, application data, or any other files that benefit from availability and censorship-resistance.
In this tutorial, you walk through a common developer scenario: storing an image on the Bulletin Chain and obtaining its CID (Content Identifier) so it can be referenced from a dApp, NFT metadata, or any IPFS-compatible system. The same steps apply to any file type, including documents, JSON configs, and HTML pages.
The endpoint is configuration. The steps work against a Bulletin Chain node you run locally or against any deployment you have access to. For TestNet access, see Get TestNet Tokens on developers.polkadot.com.
Prerequisites¶
- Node.js v18 or higher.
- The WebSocket endpoint of a Bulletin Chain node.
- An account authorized to store data on that chain, as described in the next section.
- An image or file to store, at most 2 MiB per transaction. For larger files, you can chunk your data. For details, see Size Limits.
Get Authorization¶
The Bulletin Chain has no token balances. Instead, an account needs an authorization before it can store data. An authorization grants your account a specific number of transactions and bytes that you can use for storage, and it expires at a set block.
The authorize_account(who, transactions, bytes) extrinsic of the TransactionStorage pallet grants authorizations. It requires the authorizer origin: Root, or an account or parachain allowed to grant authorizations. You cannot self-authorize. For details, see Who Grants Authorization.
- Local development chain: The
//Aliceaccount has sudo access and can grant authorizations. Submitauthorize_accountfor your account through theSudopallet with any client that supports Polkadot SDK chains. - TestNet: See Get TestNet Tokens on developers.polkadot.com.
Note
Once an authorization expires, unused allowance is not refunded, and you need a new authorization.
Store Your Image¶
Now that your account is authorized, you can store your image on-chain. This tutorial uses Polkadot API (PAPI), a third-party TypeScript library, to submit extrinsics from the TransactionStorage pallet. You can also submit the same extrinsics with other clients that support Polkadot SDK chains, for example Polkadot.js Apps.
Set Up the Project¶
-
Create and initialize a new project:
-
Install the required dependencies:
-
Fetch the Bulletin Chain metadata and generate typed descriptors:
Replace
INSERT_BULLETIN_WS_ENDPOINTwith the WebSocket endpoint of your Bulletin Chain node, for examplews://127.0.0.1:9944for a node running locally on the default port. This command downloads the chain metadata and generates typed descriptors for all pallet interactions.
Store an Image¶
Create a file named store-data.ts with the following content:
import { createClient } from 'polkadot-api';
import { getWsProvider } from 'polkadot-api/ws';
import { bulletin } from '@polkadot-api/descriptors';
import { sr25519CreateDerive } from '@polkadot-labs/hdkd';
import {
DEV_PHRASE,
entropyToMiniSecret,
mnemonicToEntropy,
} from '@polkadot-labs/hdkd-helpers';
import { getTxCreator } from 'polkadot-api/tx-creator';
import { CID } from 'multiformats/cid';
import { readFile } from 'fs/promises';
// WebSocket endpoint of the Bulletin Chain node you connect to
const BULLETIN_RPC = 'INSERT_BULLETIN_WS_ENDPOINT';
// Base URL of an IPFS gateway that serves Bulletin Chain data
const IPFS_GATEWAY = 'INSERT_IPFS_GATEWAY_URL';
// Path to the image you want to store
const FILE_PATH = 'INSERT_IMAGE_PATH';
async function main() {
// Create the client connection
const client = createClient(getWsProvider(BULLETIN_RPC));
// Get the typed API for the Bulletin Chain
const api = client.getTypedApi(bulletin);
console.log('Connected to Bulletin Chain');
// Derive a signer from a mnemonic
const miniSecret = entropyToMiniSecret(mnemonicToEntropy(DEV_PHRASE));
const derive = sr25519CreateDerive(miniSecret);
const hdkdKeyPair = derive('//Alice');
const signer = getTxCreator(
hdkdKeyPair.publicKey,
'Sr25519',
hdkdKeyPair.sign
);
// Read the image to store
const fileData = await readFile(FILE_PATH);
console.log(`Read file: ${FILE_PATH} (${fileData.length} bytes)`);
// Submit the store transaction
// Note: the signing account must have an active authorization (see Get Authorization section)
console.log('Submitting store transaction...');
const result = await api.tx.TransactionStorage.store({
data: new Uint8Array(fileData),
}).createAndSubmit(signer);
console.log(
`Transaction included in block #${result.block.number} (${result.block.hash})`
);
// Check events for the Stored event containing the CID
for (const event of result.events) {
if (event.type === 'TransactionStorage' && event.value.type === 'Stored') {
// Decode the raw CID bytes into a standard IPFS CID string
const cid = CID.decode(event.value.value.cid);
console.log('\nImage stored successfully!');
console.log(`Index: ${event.value.value.index}`);
console.log(`Content hash: ${event.value.value.content_hash}`);
console.log(`CID: ${cid.toString()}`);
console.log(`\nRetrieve via IPFS gateway:`);
console.log(`${IPFS_GATEWAY}/ipfs/${cid.toString()}`);
}
}
// Disconnect the client
client.destroy();
}
main().catch(console.error);
Replace the following placeholders:
INSERT_BULLETIN_WS_ENDPOINT: The same WebSocket endpoint you used to generate the descriptors.INSERT_IPFS_GATEWAY_URL: The base URL of an IPFS HTTP gateway that serves data from your Bulletin Chain deployment, if one exists. The script only prints this URL.INSERT_IMAGE_PATH: The path to your image, for example./logo.png. Ensure the file is at most 2 MiB.
The script signs with the //Alice development account. To use a different authorized account, derive the signer from that account's mnemonic instead of DEV_PHRASE.
Run the script:
You should see output similar to:
Save the CID and the content hash. You need them to retrieve and renew your data.
Verify Your Stored Image¶
The script prints the block in which your transaction was included and the data from the TransactionStorage.Stored event: the index of the transaction in the block, the content hash, and the CID. To verify the stored image independently, look up that block with a block explorer or any client connected to your node and check for the TransactionStorage.Stored event.
Retrieve Your Data¶
The Bulletin Chain follows a "write-to-chain, read-from-network" architecture: you retrieve data from collator nodes using the CID. For a full overview of retrieval methods, see IPFS Integration and Data Retrieval.
The recommended decentralized approach is to connect directly to Bulletin Chain collator nodes using Helia (a lean IPFS implementation) and retrieve data by CID over libp2p.
This method requires the multiaddresses of the collator nodes you connect to. See the Bulletin Chain repository for Helia configuration examples.
Where an IPFS HTTP gateway that fetches from Bulletin Chain collator nodes is deployed, it serves data at <gateway>/ipfs/<CID>. You can open that URL in a browser or fetch it programmatically:
const gateway = 'INSERT_IPFS_GATEWAY_URL';
const cid = 'INSERT_CID';
const response = await fetch(`${gateway}/ipfs/${cid}`);
const data = await response.arrayBuffer();
console.log(`Retrieved ${data.byteLength} bytes`);
Replace INSERT_IPFS_GATEWAY_URL with the gateway's base URL and INSERT_CID with the CID string you received when storing your data (for example, bafk2bzacea6wlxy...).
Provisional
Retrieval through the Smoldot light client with the bitswap_block RPC is planned but not yet available.
Note
Stored data is only available within the retention period set by the runtime's RetentionPeriod parameter. After that, the data is pruned from the chain and is no longer retrievable unless it has been renewed.
Renew Your Data¶
If you need your image to remain available beyond the retention period, renew it before it expires. Register a renewal with the DataRenewal pallet, identifying your data by the content hash that the store script printed:
console.log('Registering renewal...');
const result = await api.tx.DataRenewal.renew({
entry: { type: 'ContentHash', value: 'INSERT_CONTENT_HASH' },
}).createAndSubmit(signer);
console.log(`Renewal registered in block: ${result.block.hash}`);
You should see output similar to:
The renew call registers a one-time renewal. When the retention period of your data ends, the chain stores the data again, so it stays available for another full retention period. The renewal is paid from your authorization when you register it. Each content hash can have only one registered renewal at a time, so registering again before this one takes effect fails with RenewalAlreadyEnabled.
The DataRenewal pallet also provides the following alternatives:
force_renew: Renews the data immediately. It takes the sameentryargument asrenew.enable_auto_renew: Renews the data at the end of every retention period. It takes the data's content hash. Each renewal after the first is charged to your authorization, and recurring renewal stops if your authorization cannot cover it.
Warning
You can also identify the data by its position, using the block number and the Index value that the store script printed:
A position identifies one stored copy of the data and stays valid until that copy's retention period ends. Each renewal stores a new copy at a new block number and index. When a renew takes effect, the original copy expires at the same time, and calls that use its position fail with RenewedNotFound. After force_renew, the original copy keeps its position until its own period ends, so renewing that position again stores another copy. The content hash always resolves to the latest copy.
Where to Go Next¶
| Created: November 17, 2026