Backend Zome Functions API

Complete reference for all Holochain zome functions across all domains.

Zome Function Architecture

All zome functions follow consistent patterns for input validation, error handling, and return types.

Standard Function Pattern

#![allow(unused)]
fn main() {
#[hdk_extern]
pub fn create_entity(input: CreateEntityInput) -> ExternResult<Record> {
    let entity_hash = create_entry(&EntryTypes::Entity(input.clone()))?;

    let record = get(entity_hash.clone(), GetOptions::default())?
        .ok_or(wasm_error!(WasmErrorInner::Guest(String::from("Could not find the just created Entity"))))?;

    let path = Path::from("all_entities");
    create_link(path.path_entry_hash()?, entity_hash.clone(), LinkTypes::AllEntities, ())?;

    Ok(record)
}
}

Service Types Zome

DNA: requests_and_offers
Zome: service_types

Functions

create_service_type(input: CreateServiceTypeInput) -> ExternResult<Record>

Creates a new service type with pending status.

Input:

#![allow(unused)]
fn main() {
pub struct CreateServiceTypeInput {
    pub name: String,
    pub description: String,
    pub tags: Vec<String>,
}
}

Output: Record containing the created service type entry

get_all_service_types() -> ExternResult<Vec<Record>>

Retrieves all service types from the DHT.

Output: Vector of all service type records

get_service_type(service_type_hash: ActionHash) -> ExternResult<Option<Record>>

Retrieves a specific service type by hash.

approve_service_type(service_type_hash: ActionHash) -> ExternResult<Record>

Updates service type status to approved.

reject_service_type(service_type_hash: ActionHash) -> ExternResult<Record>

Updates service type status to rejected.

search_service_types_by_tag(tag: String) -> ExternResult<Vec<Record>>

Searches service types by tag.

Requests Zome

DNA: requests_and_offers
Zome: requests

Functions

create_request(input: CreateRequestInput) -> ExternResult<Record>

Creates a new request.

Input:

#![allow(unused)]
fn main() {
pub struct CreateRequestInput {
    pub title: String,
    pub description: String,
    pub service_type_hash: ActionHash,
    pub urgency: UrgencyLevel,
    pub time_preference: TimePreference,
    pub interaction_type: InteractionType,
}
}

get_active_requests() -> ExternResult<Vec<Record>>

Retrieves all active requests from the "requests.active" path.

get_archived_requests() -> ExternResult<Vec<Record>>

Retrieves all archived requests from the "requests.archived" path.

archive_request(request_hash: ActionHash) -> ExternResult<bool>

Archives a request by moving it from active to archived path and updating status.

update_request(input: UpdateRequestInput) -> ExternResult<Record>

Updates an existing request.

fulfill_request(request_hash: ActionHash) -> ExternResult<Record>

Marks a request as fulfilled.

close_request(request_hash: ActionHash) -> ExternResult<Record>

Closes a request.

Offers Zome

DNA: requests_and_offers
Zome: offers

Functions

create_offer(input: CreateOfferInput) -> ExternResult<Record>

Creates a new offer.

get_active_offers() -> ExternResult<Vec<Record>>

Retrieves all active offers from the "offers.active" path.

get_archived_offers() -> ExternResult<Vec<Record>>

Retrieves all archived offers from the "offers.archived" path.

archive_offer(offer_hash: ActionHash) -> ExternResult<bool>

Archives an offer by moving it from active to archived path and updating status.

accept_offer(offer_hash: ActionHash) -> ExternResult<Record>

Accepts an offer.

close_offer(offer_hash: ActionHash) -> ExternResult<Record>

Closes an offer.

Users Zome

DNA: requests_and_offers
Zome: users

Functions

create_user_profile(input: CreateUserProfileInput) -> ExternResult<Record>

Creates a user profile.

get_all_user_profiles() -> ExternResult<Vec<Record>>

Retrieves all user profiles.

get_user_profile(agent_hash: AgentPubKey) -> ExternResult<Option<Record>>

Gets a specific user profile by agent hash.

update_user_profile(input: UpdateUserProfileInput) -> ExternResult<Record>

Updates a user profile.

Organizations Zome

DNA: requests_and_offers
Zome: organizations

Functions

create_organization(input: CreateOrganizationInput) -> ExternResult<Record>

Creates a new organization.

get_all_organizations() -> ExternResult<Vec<Record>>

Retrieves all organizations.

add_organization_member(input: AddMemberInput) -> ExternResult<()>

Adds a member to an organization.

remove_organization_member(input: RemoveMemberInput) -> ExternResult<()>

Removes a member from an organization.

Administration Zome

DNA: requests_and_offers
Zome: administration

For the full administration design including the progenitor bootstrap mechanism see The Progenitor Pattern and Administration Zome Specification.

Functions

is_progenitor(_: ()) -> ExternResult<bool>

Returns true if the calling agent is the network progenitor. Compares the caller's genesis agent key against the progenitor_pubkey embedded in DNA properties.

Authorization: none required — any agent may call this to check their own status.

add_administrator(input: EntityActionHashAgents) -> ExternResult<bool>

Adds one or more agents to the administrator list.

Input:

#![allow(unused)]
fn main() {
pub struct EntityActionHashAgents {
    pub original_action_hash: ActionHash,
    pub previous_action_hash: ActionHash,
    pub agents: Vec<AgentPubKey>,
}
}

Output: true when a new admin link was created; false if the agent is already an administrator (idempotent).

Authorization: caller must be the network progenitor or an existing administrator.

remove_administrator(input: EntityActionHashAgents) -> ExternResult<bool>

Removes an agent from the administrator list.

Authorization: caller must be an existing administrator. Returns LastAdminError if removing would leave the network with no administrators.

get_all_administrators() -> ExternResult<Vec<Record>>

Returns all current administrator records.

get_agent_administration(agent: AgentPubKey) -> ExternResult<Option<Record>>

Returns the administration record for a specific agent, or None if they are not an administrator.

suspend_user(input: SuspendUserInput) -> ExternResult<Record>

Suspends a user with a reason. Caller must be an administrator.

unsuspend_user(agent: AgentPubKey) -> ExternResult<Record>

Lifts a suspension. Caller must be an administrator.

update_entity_status(input: UpdateEntityStatusInput) -> ExternResult<Record>

Updates the status (Pending, Accepted, Rejected, SuspendedIndefinitely, SuspendedTemporarily) of a user or organization. Caller must be an administrator.

Error Handling

All zome functions use consistent error handling patterns:

#![allow(unused)]
fn main() {
// Standard error pattern
pub fn example_function() -> ExternResult<Record> {
    let result = some_operation()
        .map_err(|e| wasm_error!(WasmErrorInner::Guest(format!("Operation failed: {}", e))))?;

    Ok(result)
}
}

Validation Rules

Input Validation

  • All string inputs are validated for minimum length
  • Required fields are checked for presence
  • Enum values are validated against allowed options

Entry Validation

  • All entries must pass integrity validation
  • References to other entries are verified
  • Status transitions follow defined workflows
  • Link creation follows proper authorization
  • Link targets are validated for existence
  • Link types are checked for correctness

Integration Points

hREA Integration

Service types can be automatically mapped to hREA ResourceSpecifications when approved.

Cross-Zome Communication

Zomes communicate through links and shared entry types for maintaining consistency.

This zome function reference provides the complete backend API for the Holochain application.