Skip to main content
Version: Next


Account storage stores objects under paths. Paths consist of a domain and an identifier.

Paths start with the character /, followed by the domain, the path separator /, and finally the identifier. For example, the path /storage/test has the domain storage and the identifier test.

There are two valid domains: storage and public.

Paths in the storage domain have type StoragePath, and paths in the public domain have the type PublicPath. Both StoragePath and PublicPath are subtypes of Path.

The storage domain stores storable objects, such as resources and structs. Objects stored under the storage domain are only accessible through account references which are authorized with a storage entitlement.

The public domain stores capabilities, which are accessible by anyone.

Path functions

fun toString(): String

Returns the string representation of the path.

let storagePath = /storage/path
storagePath.toString() // is "/storage/path"

There are also utilities to produce paths from strings:

fun PublicPath(identifier: string): PublicPath?
fun StoragePath(identifier: string): StoragePath?

Each of these functions take an identifier and produce a path of the appropriate domain:

let pathID = "foo"
let path = PublicPath(identifier: pathID) // is /public/foo