Alexandria Library

Knowledge belongs to everyone, forever.

Developer docs

Alexandria Library runs on the Flow blockchain. All catalog and book content is stored on-chain. Read access is permissionless: anyone can query the contract with Cadence scripts — no wallet or account required. Projects like Flunks.net already compose on top of the library so users can read books from their apps.

Contract & network

  • Network: Flow mainnet
  • Contract address: 0xfed1adffd14ea9d0
  • Access node: https://rest-mainnet.onflow.org

Use Cadence scripts to read data; no authentication is needed for reads.

Public API (Alexandria contract)

View functions you can call from scripts:

  • getAllGenres() → [String]
  • getGenre(genre: String) → [String]?
  • getAuthors() → [String]?
  • getAuthor(author: String) → [String]?
  • getBook(bookTitle: String) → &Book
  • getBookChapterTitles(bookTitle: String) → [String]
  • getBookChapter(bookTitle: String, chapterTitle: String) → Chapter?
  • getBookParagraph(bookTitle: String, chapterTitle: String, paragraphIndex: Int) → String
  • getKeeper(bookTitle: String) → Address?

Cadence scripts

Copy-paste these scripts to read from the library from your app (e.g. with FCL fcl.query).

Get all genres

Returns all genres in the library catalog.

Args: none → Returns: [String]?

import Alexandria from 0xfed1adffd14ea9d0

access(all) 
fun main(): [String]?  {
    return Alexandria.getAllGenres()
}

Get books by genre

Returns book titles for a given genre.

Args: genre: String → Returns: [String]?

import Alexandria from 0xfed1adffd14ea9d0

access(all) 
fun main(genre: String): [String]?  {
    return Alexandria.getGenre(genre: genre)
}

Get all authors

Returns all authors in the library.

Args: none → Returns: [String]?

import Alexandria from 0xfed1adffd14ea9d0

access(all) 
fun main(): [String]? {
    return Alexandria.getAuthors()
}

Get books by author

Returns book titles for a given author.

Args: author: String → Returns: [String]?

import Alexandria from 0xfed1adffd14ea9d0

access(all) 
fun main(author: String): [String]?  {
    return Alexandria.getAuthor(author: author)
}

Get chapter titles

Returns chapter titles for a book.

Args: bookTitle: String → Returns: [String]

import Alexandria from 0xfed1adffd14ea9d0   

access(all) 
fun main(bookTitle: String): [String]  {

    return Alexandria.getBookChapterTitles(bookTitle: bookTitle)
}

Get book paragraph

Returns a single paragraph by book, chapter, and index.

Args: bookTitle: String, chapterTitle: String, paragraphIndex: Int → Returns: String

import Alexandria from 0xfed1adffd14ea9d0

access(all) 
fun main(bookTitle: String, chapterTitle: String, paragraphIndex: Int): String  {
    return Alexandria.getBookParagraph(bookTitle: bookTitle, chapterTitle: chapterTitle, paragraphIndex: paragraphIndex)
}

Get book (reference)

Returns a reference to the full book resource (chapters, paragraphs).

Args: bookTitle: String → Returns: &Alexandria.Book?

import Alexandria from 0xfed1adffd14ea9d0   

access(all) 
fun main(bookTitle: String): &Alexandria.Book?  {

    return Alexandria.getBook(bookTitle: bookTitle)
}