Skip to content
Français

ArtifactContract

import type { ArtifactContract } from "@elie-laloum/outpost";
  • encodeRequired
    (value: T) => Promise<Uint8Array>
    Validate a value and return the bytes to store. Rejects a value the contract does not accept.
  • decodeRequired
    (bytes: Uint8Array) => Promise<T>
    Turn stored bytes back into a validated value. Rejects bytes the contract does not accept.
  • nameRequired
    string
    Contract name, nonempty and at most 1024 characters. A read requires the same name.
  • versionRequired
    string
    Contract version you choose, nonempty and at most 1024 characters. A read requires the same version, so change it when the format changes.
  • encodingRequired
    "json" | "binary"
    json for a defineJsonArtifact() contract, binary for a defineBinaryArtifact() contract. A read requires the same encoding.
export interface ArtifactContract<T> extends ArtifactIdentity {
  encode(value: T): Promise<Uint8Array>;
  decode(bytes: Uint8Array): Promise<T>;
}