Broadcasting transactions

client.broadcast prepares, signs and broadcasts operations to Blurt Layer 1.

For the difference between transactions, operations, signatures and authorities, see Blockchain model.

Private keys are application secrets. Do not hard-code them in source code. Use environment variables, encrypted stores, wallet integrations or user-controlled signing flows.

These snippets are not part of the safe read-only examples/ set. Do not run them against real accounts without understanding the required authority and irreversible side effects.

const { Client, PrivateKey } = require('@beblurt/dblurt');

const client = new Client(rpcList);
const key = PrivateKey.fromString(process.env.BLURT_POSTING_KEY);

const confirmation = await client.broadcast.vote({
voter: 'alice',
author: 'bob',
permlink: 'hello-blurt',
weight: 10000
}, key);

console.log(confirmation.id);
const key = PrivateKey.fromString(process.env.BLURT_ACTIVE_KEY);

const confirmation = await client.broadcast.transfer({
from: 'alice',
to: 'bob',
amount: '1.000 BLURT',
memo: 'Thanks!'
}, key);

console.log(confirmation.id);

Use typed builders for common social/community operations when you need preview, dry-run or external signing UX:

const {
buildFollowOperation,
buildReblogOperation,
Client,
PrivateKey
} = require('@beblurt/dblurt');

const followOp = buildFollowOperation({ follower: 'alice', following: 'bob' });
const reblogOp = buildReblogOperation({ account: 'alice', author: 'bob', permlink: 'hello-blurt' });

console.log(followOp[1]); // exact custom_json payload before signing

For direct broadcast, use client.broadcast.customJson() or the social convenience helpers such as follow, unfollow, mute, unmute, reblog, undoReblog, communitySubscribe, communityUnsubscribe and readNotification:

const key = PrivateKey.fromString(process.env.BLURT_POSTING_KEY);

await client.broadcast.follow('alice', 'bob', key);

For custom application-specific payloads, use the generic operation shape:

const key = PrivateKey.fromString(process.env.BLURT_POSTING_KEY);

await client.broadcast.customJson({
required_auths: [],
required_posting_auths: ['alice'],
id: 'my-app',
json: JSON.stringify({ action: 'ping', ts: Date.now() })
}, key);

Use pure content builders when applications need preview, dry-run, external signing or custom confirmation before broadcasting posts and replies:

const { buildPostOperation } = require('@beblurt/dblurt');

const operation = buildPostOperation({
author: 'alice',
title: 'Hello Blurt',
body: 'Body text',
tags: ['blurt', 'sdk'],
app: 'my-app/1.0'
});

console.log(operation[1]); // exact comment operation before signing

The builders normalize permlinks and tags, construct json_metadata, and return regular comment operations. There is no Layer 1 protocol limit on the number of metadata tags; DEFAULT_CONTENT_TAG_LIMIT follows the broad Blurt ecosystem convention of eight tags and can be overridden per call with maxTags. They deliberately do not add application-specific attribution footers, moderation policy, confirmation UX or key-handling policy.

const tx = await client.broadcast.prepareTransaction([
['vote', {
voter: 'alice',
author: 'bob',
permlink: 'hello-blurt',
weight: 10000
}]
]);

const signed = client.broadcast.sign(tx, key);
console.log(signed.signatures);

The helper obtains chain properties, prepares a transaction, signs it with the provided key or keys, and sends it through the configured RPC client.