0.2.4 • Published 1 year ago
@whi/holochain-agent-client v0.2.4
Holochain Agent Client
A Javascript client for communicating with Holochain's App Interface API.
Overview
This client is guided by the interfaces defined in the holochain/holochain project.
Features
- Get app info
- Create client via app info call
- Call zome function
- Zome call serialization and signing
Install
npm i @whi/holochain-agent-client
Basic Usage
Each example assumes this code is present
import { AgentClient, HoloHashes } from '@whi/holochain-agent-client';
const { AgentPubKey, DnaHash } = HoloHashes;
const agent_hash = new AgentPubKey("uhCAkXZ1bRsAdulmQ5Tjw5rNJPXXudEVxMvhqEMPZtCyyoeyY68rH");
const dna_hash = new DnaHash("uhC0kzbVYMh7gso8s-O26hL4PfDTajGqHFkljyL8mdtokzoL-gRdd");
const app_interface_port = 45678;
Example
const client = new AgentClient( agent_hash, {
"memory": dna_hash,
}, app_interface_port );
await client.call("memory", "mere_memory", "save_bytes", Buffer.from("Hello World") );
Example of using AgentClient
with defined zomes
const client = new AgentClient( agent_hash, {
"memory": [ dna_hash, [ "mere_memory" ] ],
}, app_interface_port );
await client.call("memory", "mere_memory", "save_bytes", Buffer.from("Hello World") );
Example of using AgentClient
with defined zomes and functions
const client = new AgentClient( agent_hash, {
"memory": [ dna_hash, {
"mere_memory": [ "save_bytes", "retrieve_bytes" ],
}],
}, app_interface_port );
await client.call("memory", "mere_memory", "save_bytes", Buffer.from("Hello World") );
API Reference
See docs/API.md
Contributing
See CONTRIBUTING.md