Guides
Dash CoreDash PlatformDash.orgDash User DocsLog In
Hey! These docs are for version 0.17.0, which is no longer officially supported. Click here for the latest version, 0.25-redirect!


# Overview

In this tutorial we will update existing data on Dash Platform. Data is stored in the form of [documents](🔗) which are encapsulated in a [state transition](🔗) before being submitted to DAPI.

## Prerequisites

  • [node.js](🔗) (v12+)

  • Basic familiarity with JavaScript asychronous functions using [async/await](🔗)

  • The Dash JavaScript SDK is initialized (covered in [Connecting to EvoNet](🔗))

  • Access to a previously created document (e.g., one created using the [Submit Documents tutorial](🔗))

# Code

Initializing the Client with a contract identity

The example below shows how access to contract documents via `<contract name>.<contract document>` syntax (e.g. `tutorialContract.note`) can be enabled by passing a contract identity to the constructor. Please refer to the [Dash SDK documentation](🔗) for details.

Wallet Operations

Currently, the JavaScript SDK does not cache wallet information, and therefore, it re-syncs the entire Core chain for some wallet operations (e.g. `client.getWalletAccount()`). This can result in wait times of 5+ minutes. An upcoming release will add a persistence feature to cache wallet information during initial sync so that subsequent access is much faster.



# What's happening

After we initialize the Client, we retrieve the document to be updated via `platform.documents.get` using its `id`. Once the document has been retrieved, we must submit it to [DAPI](🔗) with the desired data updates. Documents are submitted in batches that may contain multiple documents to be created, replaced, or deleted. In this example, a single document is being updated.

The `platform.documents.broadcast` method then takes the document batch (e.g. `{replace: [noteDocument]}`) and an identity parameter. Internally, it creates a [State Transition](🔗) containing the previously created document, signs the state transition, and submits the signed state transition to DAPI.