# Walking through an example · Your first Rell app on Chromia · Learn Chromia

> With the setup complete, you can now submit a few transactions and query both the state and the transaction history to see how the two relate.

Source: https://chromia.com/learn/book-review/blockchain-transactions/example/

Your first Rell app on ChromiaLesson 20 of 26

1. [01Your first Rell app on Chromia](https://chromia.com/learn/book-review/introduction/)
2. [02Set up your project](https://chromia.com/learn/book-review/setup/)
3. [03Rell project structure](https://chromia.com/learn/book-review/rell-structure/)

Part 1: Define your first entity

1. [04Overview](https://chromia.com/learn/book-review/book-entity/)
2. [05Create your first entity](https://chromia.com/learn/book-review/book-entity/tables/)
3. [06Add your first operation](https://chromia.com/learn/book-review/book-entity/basic-operations/)
4. [07Query every book](https://chromia.com/learn/book-review/book-entity/write-queries/)

Part 2: Add a related entity

1. [08Overview](https://chromia.com/learn/book-review/book-review-entity/)
2. [09Define the book review entity](https://chromia.com/learn/book-review/book-review-entity/tables/)
3. [10Add an operation for creating book reviews](https://chromia.com/learn/book-review/book-review-entity/basic-operations/)
4. [11Query all reviews for a book](https://chromia.com/learn/book-review/book-review-entity/write-queries/)

Part 3: Checking and validating inputs

1. [12Overview](https://chromia.com/learn/book-review/input-verification/)
2. [13Verify inputs](https://chromia.com/learn/book-review/input-verification/input-verification/)
3. [14Return structured results from queries](https://chromia.com/learn/book-review/input-verification/structure/)

Part 4: Signing transactions and filtering queries

1. [15Overview](https://chromia.com/learn/book-review/sign-transaction/)
2. [16Sign a transaction](https://chromia.com/learn/book-review/sign-transaction/sign-transaction/)
3. [17Filter and sort query results](https://chromia.com/learn/book-review/sign-transaction/structure/)

Part 5: Blockchain state and transactions explained

1. [18Overview](https://chromia.com/learn/book-review/blockchain-transactions/)
2. [19How blockchain state and transactions work](https://chromia.com/learn/book-review/blockchain-transactions/query-transaction/)
3. [20Walking through an example](https://chromia.com/learn/book-review/blockchain-transactions/example/)

Part 6: Create the client

1. [21Overview](https://chromia.com/learn/book-review/build-client/)
2. [22Prerequisites](https://chromia.com/learn/book-review/build-client/prerequisites/)
3. [23Establishing a connection to Chromia](https://chromia.com/learn/book-review/build-client/sign-transaction/)
4. [24Query the blockchain using postchain-client](https://chromia.com/learn/book-review/build-client/query-blockchain/)
5. [25Complete the example](https://chromia.com/learn/book-review/build-client/complete-example/)

1. [26What’s next?](https://chromia.com/learn/book-review/what-next/)

[Learn](https://chromia.com/learn/)[Your first Rell app on Chromia](https://chromia.com/learn/book-review/)

20 / 26Part 5: Blockchain state and transactions explainedBeginner

# Walking through an example

With the setup complete, you can now submit a few transactions and query both the state and the transaction history to see how the two relate.

Start from a clean node. If the Chromia Node is running, stop it with `Ctrl+C` first, then wipe its data with this command:

shell

```nolines
chr node start --wipe
```

The command deletes every transaction on the blockchain and resets the current state. To confirm, run:

shell

```nolines
chr query get_all_books
```

You should get an empty array, which means the current state contains no books.

Now submit a transaction that creates a book. Misspell "Chromia" on purpose so you have something to fix later with an update:

shell

```nolines
chr tx create_book "ISBN001" "Crhomia 101" "Alice" --key-id "book_admin" --await
```

Expected output:

shell

```nolines
transaction with rid DF94A07EACBA673CC4ECA4A43D70CDA4FD30E4335E124B7153FB12A78FDD8CE9 was posted CONFIRMED
```

tip

To avoid passing `--key-id` on every transaction, set a default key in a `.chromia/config` file:

ini

```nolines
key.id = book_admin
```

The file can live in either of two places:

1. **Global config**: `~/.chromia/config` — used by every project unless something overrides it
2. **Project config**: `.chromia/config` inside your project folder — takes priority over the global file

With the default key configured, CLI transactions no longer need `--key-id`:

bash

```nolines
chr tx create_book "ISBN001" "Crhomia 101" "Alice" --await
```

The CLI picks up the configured key on its own.

For the complete rules on which config file wins, read
[Key pair reading flow](https://docs.chromia.com/build/cli/key-pair-management/#key-pair-reading-flow)

Once the transaction is in, list every book with the `get_all_books` command:

shell

```nolines
chr query get_all_books
```

You should see:

json

```
[
  {
    "author": "Alice",
    "isbn": "ISBN001",
    "title": "Crhomia 101"
  }
]
```

The new book now appears in the state/table. Next, query the transactions stored on the blockchain:

shell

```nolines
chr query get_transactions
```

The output is:

json

```
[
  [
    "body": [
      "blockchain_rid": x"B52F0A078993374201853649F807FDEDD6516A424557F311E2AF769761F89D40",
      "operations": [
        [
          "args": [
            "ISBN001",
            "Crhomia 101",
            "Alice"
          ],
          "name": "create_book"
        ]
      ],
      "signers": [
        x"035A25AB32B85E6A5B58A31A71CC709CED159096194984243159492CBA0FADF82F"
      ]
    ],
    "signatures": [
      x"91EFC02C2958698E71C41D2B020F9E4EF81F6C427FAA98667D6FF4B87857809E1ECE4C9C923B1E5659177B8D0635711E47A4EBB502217A437D3FFC89741E74DD"
    ]
  ]
]
```

This shows the transaction was recorded on the blockchain and the state changed to match.





To fix the misspelled title, you need an operation that updates a book's title. First, make the title field mutable in the book entity:

src/main/entities.rell

```
entity book {
  key isbn: text;
  mutable title: text;
  author: text;
}
```

Then add the update operation:

src/main/operations.rell

```
operation update_book(isbn: text, title: text){
  val adminPubkey = chain_context.args.admin_pubkey;
  require(op_context.is_signer(adminPubkey), "Only admin can update books");

  update book @ { .isbn == isbn }( .title = title );
}
```

The running node does not yet know about this operation. Update the Chromia Node with the following command and wait for the next block before testing:

shell

```nolines
chr node update
```

When the update is done, send a transaction that changes the book's title:

shell

```nolines
chr tx update_book "ISBN001" "Chromia 101" --key-id "book_admin" --await
```

Query the state and the blockchain transactions once more:

shell

```nolines
chr query get_all_books
```

The state now returns the corrected title:

json

```
[
  {
    "author": "Alice",
    "isbn": "ISBN001",
    "title": "Chromia 101"
  }
]
```

Query the blockchain transactions the same way:

shell

```nolines
chr query get_transactions
```

The output is:

json

```
[
  [
    "body": [
      "blockchain_rid": x"B52F0A078993374201853649F807FDEDD6516A424557F311E2AF769761F89D40",
      "operations": [
        [
          "args": [
            "ISBN001",
            "Crhomia 101",
            "Alice"
          ],
          "name": "create_book"
        ]
      ],
      "signers": [
        x"035A25AB32B85E6A5B58A31A71CC709CED159096194984243159492CBA0FADF82F"
      ]
    ],
    "signatures": [
      x"91EFC02C2958698E71C41D2B020F9E4EF81F6C427FAA98667D6FF4B87857809E1ECE4C9C923B1E5659177B8D0635711E47A4EBB502217A437D3FFC89741E74DD"
    ]
  ],
  [
    "body": [
      "blockchain_rid": x"B52F0A078993374201853649F807FDEDD6516A424557F311E2AF769761F89D40",
      "operations": [
        [
          "args": [
            "ISBN001",
            "Chromia 101"
          ],
          "name": "update_book"
        ]
      ],
      "signers": [
        x"035A25AB32B85E6A5B58A31A71CC709CED159096194984243159492CBA0FADF82F"
      ]
    ],
    "signatures": [
      x"FD9402B45ED52A238B0C756AFA1ABA5BD2F89C9AE44343E58FE76E207F4672CF0AF5C37F7209E5D9A474491671000FAFA9753A4BF2B5D16AE7C5C48CFA18A8E1"
    ]
  ]
]
```

The blockchain now holds two transactions: the one that created the book and the one that changed its title.

The state is the combined result of both transactions. Because every transaction affecting this book is recorded, you can trace back through the history and see exactly how the current state came to be.

To build and maintain decentralized applications well, you need a clear picture of how Rell, Chromia, the blockchain, and the state work together.

Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**How blockchain state and transactions work**](https://chromia.com/learn/book-review/blockchain-transactions/query-transaction/)[Next →**Part 6: Create the client**](https://chromia.com/learn/book-review/build-client/)
