# Hello World Quickstart · Chromia Docs (concept)

> This quickstart guide shows you how to send transactions to a blockchain node running Rell and retrieve information from it using the postchain-client library.

Source: https://docs.chromia.com/build/clients/postchain-clients/javascript-typescript/hello-world-quickstart/

# Hello World Quickstart

On this page

* [Prerequisites](#prerequisites)
* [Create the client project](#create-the-client-project)
* [Client setup](#client-setup)
* [Understanding the Rell backend](#understanding-the-rell-backend)
* [Run client code](#run-client-code)
* [Next steps](#next-steps)

This quickstart guide shows you how to send transactions to a blockchain [node](https://docs.chromia.com/get-started/about/architecture/node/) running
[Rell](https://docs.chromia.com/rell/rell-intro/) and retrieve information from it using the postchain-client library. The
postchain-client allows you to connect the frontend of your dapp to the backend.

Get the Rell Backend

You can get the complete Rell backend from the
[Hello World repository](https://github.com/ChromiaProject/hello-world-chromia), or follow this guide to add the client
integration. For the complete backend setup, see
[Build and run the Hello World dapp](https://docs.chromia.com/get-started/create-dapp/run-dapp-cli/).

This tutorial assumes you have a Rell backend running. If you don't have one yet, see
[Build and run the Hello World dapp with Chromia CLI](https://docs.chromia.com/get-started/create-dapp/run-dapp-cli/) to create the
backend first. You can connect the frontend at a later stage.

## Prerequisites

* [Node.js 18+](https://nodejs.org/en/download/)
* Your [Hello World backend](https://docs.chromia.com/get-started/create-dapp/run-dapp-cli/) is running and you have the Blockchain RID

## Create the client project

Create a separate TypeScript project and initialize it.

Terminal

```
mkdir my-rell-client && cd my-rell-client
npm init -y
npm install postchain-client --save
npm install -D typescript @types/node tsx
npx tsc --init
mkdir src
```

## Client setup

The code establishes the client connections, creates, signs, and posts a transaction to the blockchain node, and
retrieves information through a query. For detailed explanation of the code setup, see
[JavaScript/TypeScript client reference](https://docs.chromia.com/build/clients/postchain-clients/javascript-typescript/reference/).

Create **`my-rell-client/src/index.ts`** and paste in the code below, replacing `<BlockchainRID>` with your
[**Blockchain RID**](https://docs.chromia.com/reference/terminology/#blockchain-rid-brid) obtained from the node output. For information on finding
**Blockchain RID**, see
[Build and run the Hello World dapp with Chromia CLI](https://docs.chromia.com/get-started/create-dapp/run-dapp-cli/).

TypeScript

```
import { createClient } from "postchain-client";

async function simpleClient() {
  // Key pair (DEV-ONLY, replace for anything beyond localhost)
  const adminPubkey = Buffer.from("031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f", "hex");
  const adminPrivkey = Buffer.from("0101010101010101010101010101010101010101010101010101010101010101", "hex");

  // Connection setup
  const nodeUrl = "http://localhost:7740/"; // Using default postchain node REST API port
  const blockchainRid = "<BlockchainRID>"; // Dapp Blockchain RID
  const client = await createClient({
    nodeUrlPool: [nodeUrl],
    blockchainRid,
  });

  // Transaction
  /*const { status, statusCode, transactionRid } = */ await client.signAndSendUniqueTransaction(
    {
      operations: [
        {
          name: "set_name",
          args: ["Developer"],
        },
      ],
      signers: [adminPubkey],
    },
    { privKey: adminPrivkey, pubKey: adminPubkey }
  );

  // Query
  const result = await client.query("hello_world");
  console.log(result); // Hello Developer!
}

simpleClient().catch((e) => {
  console.error(e);
});
```

Browser compatibility

This example uses Node's built-in `Buffer`. In a Node.js environment, no extra configuration is needed. If you run the
same code in a browser/bundler (for example Vite or webpack 5), you will hit:

Plain text

```
ReferenceError: Buffer is not defined
```

To fix this, install the [`buffer`](https://www.npmjs.com/package/buffer) package and add at the top of your code:

TypeScript

```
import { Buffer } from "buffer";
(globalThis as any).Buffer = Buffer;
```

This makes `Buffer` available globally, just like in Node.js.

## Understanding the Rell backend

The client code works with the operation and query specified in the Rell file `main.rell`. If you created your backend
using the [Hello World guide](https://docs.chromia.com/get-started/create-dapp/run-dapp-cli/), the code in the `main.rell` file is as
follows:

Rell

```
module;

object my_name {
  mutable name = "World";
}

operation set_name(name) {
  my_name.name = name;
}

query hello_world() = "Hello %s!".format(my_name.name);
```

The project structure for the client setup should be as follows:

Terminal

```
my-rell-client
    |--node_modules
    |--src
    |   |--index.ts
    |--package-lock.json
    |--package.json
    |--tsconfig.json
```

## Run client code

From the project root:

Terminal

```
npx tsx src/index.ts
```

After running the code, you should see:

Terminal

```
Hello Developer!
```

Congratulations! With the help of the postchain-client library, you have successfully sent transactions and retrieved
information from a blockchain node running Rell.

## Next steps

* Explore the [JavaScript/TypeScript client reference](https://docs.chromia.com/build/clients/postchain-clients/javascript-typescript/reference/) for advanced features
* Learn about [queries](https://docs.chromia.com/build/cookbook/query-creation/) and [transactions](https://docs.chromia.com/build/cookbook/transaction-creation/) in the cookbook
* Check out the [React Kit](https://docs.chromia.com/build/clients/react-kit/) for easier React integration

[View this page on docs.chromia.com](https://docs.chromia.com/build/clients/postchain-clients/javascript-typescript/hello-world-quickstart/)Content mirrored from the live docs
