ArrayStorage

Interface
Persistent smart contract array storage. Only usable as a SmartContract property. See the Properties and Storage chapter of the main guide for more information.
export interface ArrayStorage<T extends SerializableValue> extends Iterable<T> { 
  readonly [Symbol.iterator]: () => IterableIterator<T>; 
  readonly length: number; 
  readonly forEach: (callback: (value: T, idx: number) => void) => void; 
  readonly push: (...items: T[]) => number; 
  readonly pop: () => T | undefined; 
  [n: number]: T; 
  readonly [OpaqueTagSymbol0]: unique symbol; 
} 

Properties

length
number
Gets the length of the array. This is a number one higher than the highest element defined in an array.

Static Methods

for

Constructs a new ArrayStorage instance. Only usable as a SmartContract property.
for<T extends SerializableValue>(): ArrayStorage<T>; 

Methods

__@iterator

() => IterableIterator<T> 

forEach

Executes a provided function once per each value in storage.
(callback: (value: T, idx: number) => void) => void 

push

Appends new elements to storage, and returns the new length of the array.
(...items: T[]) => number 

pop

Removes the last element from an array and returns it.
() => T | undefined 

Example

class MySmartContract extends SmartContract { 
 private readonly pendingAddresses = 
   ArrayStorage.for<Address>(); 
 public addPendingAddress(address: Address): void { 
   this.pendingAddresses.push(address); 
 } 
} 
  • @neo-one/client
  • @neo-one/smart-contract
DOCS
InstallationMain ConceptsAdvanced GuidesAPI ReferenceContributing
CHANNELS
GitHubStack OverflowDiscord ChatTwitterYouTube
COPYRIGHT © 2021 NEO•ONE