Retrieve one key

Returns

Retrieves the content value for the queried key for an address. If no aggregate for this address and the key is found, null will be returned.

Usage

import { aggregates } from 'aleph-js'

await aggregates.fetch_one(address, key)

Required parameters

ParameterDescription

address** ** - string

The chain address the Aggregate was created for.

key** ** - string

The key the Aggregate was created for.

Optional parameters

In addition to the required parameters above, an object of optional parameters can be passed following the key like so:

aggregates.fetch_one(address, key,{api_server: "https://api2.aleph.im"})

  • api_server - string

    Default: "https://api1.aleph.im"

    Target API server

Example

RETRIEVE AGGREGATE
import { aggregates } from 'aleph-js'

await aggregates.fetch_one(account.address, 'mykey')

Aleph returns the content for the key and the address queried if one is found.

RESPONSE
// If an aggregate is found for the key and the address
// The content for the key is returned
{ 'a': 1, 'b': 2 }

// If none are found - null is returned
null

Last updated