Skip to main content
Version: 1.0

Paths

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. The identifier must start with a letter and can only be followed by letters, numbers, or the underscore _. 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


_10
fun toString(): String

Returns the string representation of the path.


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

There are also utilities to produce paths from strings:


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

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


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

Rate this page