Skip to main content

Reading and Writing Data to the Blockchain

Casper features several means of reading and writing data to global state, depending on user needs and complexity. Reading data from global state can be done off-chain or on-chain. Writing data requires on-chain interactions, due to the nature of the system.

Storage on global state can be accomplished with NamedKeys, a form of URef or through the use of dictionaries.

Due to the nature of Casper's serialization standard, NamedKeys should be used sparingly for smaller subsets of data. Developers should use dictionaries for larger subsets of mapped structures.


The query_global_state method available through the JSON-RPC allows users to read data from global state without performing on-chain actions.

Casper API

The Casper API includes the following for reading and writing to global state:

  • get_key

    Returns the requested NamedKey from the current context.

  • put_key

    Stores the given Key under the given name in the current context's named keys.

  • dictionary_get

    Retrieves the value stored under a dictionary_item_key.

  • dictionary_put

    Writes the given value under the given dictionary_item_key.