> For the complete documentation index, see [llms.txt](https://blocknote-js.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blocknote-js.gitbook.io/doc/data-streaming/stream-data-on-chain.md).

# Stream data on-chain

## Basic usage

```javascript
import  {Streamnote} from  "blocknote"

const options = {            
    title:    "", 
    mime:     "text/plain"
    getPayloadTransactionId: (payload_transaction_id) => {        
        // Return the payload_transaction_id.
        // It is required for those who want to read to the stream.
        console.log("stream id: "+payload_transaction_id);
    },     
    onFinish: (result) => { console.log("finish", result); }
}
const sender_mnemonic    = "gorilla shiver hood theory letter absorb arctic ...";
const stream             = new Streamnote(sender_mnemonic, options); 

stream.send("some data to stream, can be utf8, arrayBuffer or uint8array"); 
stream.send("send some more data");
stream.send("and a bit more");

stream.stop(); // Ends the stream.
```

## Constructor&#x20;

<table><thead><tr><th width="190">Name</th><th width="430">Description</th><th>Type</th></tr></thead><tbody><tr><td>sender_mnemonic</td><td>The sender's mnemonic</td><td>string</td></tr><tr><td>options</td><td>See the options table below</td><td>object</td></tr></tbody></table>

### Options

<table><thead><tr><th width="228">Name</th><th width="311">Description</th><th width="106">Type</th><th>Default</th></tr></thead><tbody><tr><td>title</td><td>The stream's title</td><td>string</td><td>Untitled</td></tr><tr><td>mime </td><td>The stream's mime type</td><td>string</td><td>plain/text</td></tr><tr><td>compression</td><td><p></p><ul><li>The compression algorithm's name: <code>brotli, gzip, lz4, lz-string, pako, snappy</code></li><li>"<code>none</code>" won't compress the data.</li></ul></td><td>string</td><td>none</td></tr><tr><td>aes_key</td><td>An AES key to encrypt the stream.<br><br><mark style="color:$info;">Do not set an AES key if you are already encrypting with a password.</mark></td><td>string</td><td></td></tr><tr><td>password</td><td>A password to encrypt the stream.<br>(The strength of the password is not verified)<br><br><mark style="color:$info;">Do not set a password if you are already encrypting with an AES key.</mark></td><td>string</td><td></td></tr><tr><td>encrypt_title</td><td>Encrypt the title.<br>This option will be ignored if <code>aes_key</code> or <code>password</code> is not set.</td><td>boolean</td><td>true</td></tr><tr><td>getPayloadTransactionId ⇒ (payload_transaction_id)</td><td>Callback returning the <code>payload_transaction_id</code> of the current stream, required by <code>StreamnoteReader</code> to listen to this stream.</td><td>function</td><td></td></tr><tr><td><p>onFinish </p><p>⇒ (result)</p></td><td>Callback executes once stream ends, returning a <code>result</code> object that contains the payload and the details of the stream.</td><td>function</td><td></td></tr><tr><td><p>onError</p><p>⇒ (error)</p></td><td>Triggered if an error occurs while sending the batch of transactions. Note that Blocknote will always retry to send a transaction when failed, so they are not throwable errors. It is more like a log of failing transaction. </td><td>function</td><td></td></tr></tbody></table>

***

## Methods

### <mark style="color:$primary;">send</mark>

#### Parameters

<table><thead><tr><th width="166">Name</th><th width="316">Description</th><th>Type</th></tr></thead><tbody><tr><td>raw_content</td><td>The content to stream</td><td>string, Uint8Array, Buffer</td></tr></tbody></table>

#### Return

`null`

***

### <mark style="color:$primary;">stop</mark>

Stop accepting new incoming data but sends the remaining content. \
Marks the stream as concluded.\
**Ensure not to omit it, or the** `StreamnoteReader` **will continually await new incoming data.**

#### Return

`null`
