# new NillionClient(user_key, node_key, bootnodes)
Creates an instance of Nillion Client
Parameters:
Name | Type | Description |
---|---|---|
user_key |
UserKey
|
The user private key |
node_key |
NodeKey
|
The node private key |
bootnodes |
Array.<string>
|
The Nillion cluster bootnode websocket
multiaddresses. A websocket multiaddress has
|
Example
const user_key = UserKey.generate();
const node_key = NodeKey.from_seed('your-seed-here');
const client = new NillionClient(
user_key,
node_key,
bootnodes,
);
Classes
Members
# party_id
Get the party identifier for the current client.
Example
const partyId = nillionClient.party_id;
# user_id
Get the user identifier for the current user.
Example
const userId = nillionClient.user_id;
# static build_version
Get the build version of the Nillion client.
Example
const version = nillionClient.build_version;
Methods
# cluster_information(cluster_id) → {Promise.<ClusterDescriptor>}
Returns information about a Nillion cluster
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
Identifier of the target cluster |
The cluster descriptor for the given cluster
Promise.<ClusterDescriptor>
Example
const cluster_descriptor = await nillionClient.cluster_information(cluster_id);
# compute(cluster_id, bindings, store_ids, values, receipt) → {Promise.<string>}
Compute in the Nillion Network. This method invokes the
compute operation in the Nillion network. It returns a
compute ID that can be used by
compute_result
to fetch the results of this
computation.
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
Identifier of the targeted cluster |
bindings |
ProgramBindings
|
The program bindings for the computation |
store_ids |
Array.<string>
|
The store IDs of the values to use for the computation |
values |
NadaValues
|
Additional values to use for the computation |
receipt |
PaymentReceipt
|
The receipt for the payment made for this operation. |
A computation UUID.
Promise.<string>
Example
const bindings = new ProgramBindings();
bindings.add_input_party('Party1', '12D3KooWKbs29XBmtXZEFZwHBr39BsgbysPAmAS3RWWdtBBc7joH');
const values = new NadaValues();
values.insert('value1', NadaValue.new_public_integer('1'));
const result_id = await nillionClient.compute(cluster_id, bindings, ['store1'], values);
# compute_result(result_id) → {Promise.<Object>}
Fetch the result of the compute in the Nillion Network
Parameters:
Name | Type | Description |
---|---|---|
result_id |
string
|
The computation UUID returned after calling
|
- The result of the computation
Promise.<Object>
Example
const result = await nillionClient.compute_result(result_id);
# delete_values(cluster_id, store_id) → {Promise}
Delete values collection from the network.
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
UUID of the targeted preprocessing cluster |
store_id |
string
|
The store value operation identifier for the values collection that will be deleted. |
Promise
Example
await nillionClient.delete_values(cluster_id, store_id);
# request_price_quote(cluster_id, operation, receipt)
Request a price quote for an operation on the network.
This method asks the network to calculate a price quote for the specified operation. Payment and submission of the operation is the client's responsibility and must be done before the quote expires.
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
UUID of the targeted preprocessing cluster |
operation |
string
|
The operation to get a quote for. |
receipt |
PaymentReceipt
|
The receipt for the payment made for this operation. |
The price quoted for this operation
Example
const values = new nillion.NadaValues();
values.insert("int", nillion.NadaValue.new_public_integer("42"));
const operation = nillion.Operation.store_values(values);
const quote = await context.client.request_price_quote(
context.config.cluster_id,
operation,
);
# retrieve_permissions(cluster_id, store_id, receipt) → {Promise.<Permissions>}
Retrieve permissions for a group of values stored in the Nillion network.
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
The identifier of the target cluster |
store_id |
string
|
The store value identifier for the values collection where the values are |
receipt |
PaymentReceipt
|
The receipt for the payment made for this operation. |
The permissions associated to the values
Promise.<Permissions>
Example
const permissions = await nillionClient.retrieve_permissions(cluster_id, store_id);
# retrieve_value(cluster_id, store_id, value_id, receipt) → {Promise.<NadaValue>}
Retrieve a value already stored in Nillion
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
UUID of the targeted preprocessing cluster |
store_id |
string
|
The store value operation identifier for the values collection that will be retrieved. |
value_id |
string
|
The value identifier inside the values collection |
receipt |
PaymentReceipt
|
The receipt for the payment made for this operation. |
-
The value identified by
value_id
Promise.<NadaValue>
Example
const value = await nillionClient.retrieve_value(cluster_id, store_id, value_id);
# store_program(cluster_id, program_name, program, receipt)
Store a program in the Nillion Network
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
UUID of the targeted preprocessing cluster |
program_name |
string
|
The name of the program |
program |
UInt8Array
|
The compiled nada program in binary format |
receipt |
PaymentReceipt
|
The receipt for the payment made for this operation. |
The program ID associated with the program
Example
const program_id = await nillionClient.store_program(cluster_id, 'program_name', program);
# store_values(cluster_id, values, permissions, receipt) → {Promise.<string>}
Store values on the Nillion network
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
The targeted cluster identifier |
values |
NadaValues
|
The collection of values to store |
permissions |
Permissions
|
undefined
|
Optional permissions to be associated with the values. By default the user has full access to them. |
receipt |
PaymentReceipt
|
The receipt for the payment made for this operation. |
A store ID that can be used to retrieve the values.
Promise.<string>
Example
const values = new NadaValues();
values.insert('value1', NadaValue.new_public_integer('1'));
const store_id = await nillionClient.store_values(cluster_id, values);
# update_permissions(cluster_id, store_id, permissions, receipt) → {Promise.<string>}
Update permissions for a group of values stored in the Nillion network.
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
The identifier of the target cluster |
store_id |
string
|
The store value identifier for the values collection where the values are |
permissions |
Permissions
|
The permissions that will replace the existing permissions for the values |
receipt |
PaymentReceipt
|
The receipt for the payment made for this operation. |
The action ID corresponding to the update operation
Promise.<string>
Example
const permissions = Permissions.default_for_user(nillionClient.user_id);
permissions.add_update_permissions(["user_id"]);
const action_id = await nillionClient.update_permissions(cluster_id, store_id, permissions);
# update_values(cluster_id, store_id, values, receipt) → {Promise.<string>}
Update values stored in the Nillion network
Parameters:
Name | Type | Description |
---|---|---|
cluster_id |
string
|
UUID of the targeted preprocessing cluster |
store_id |
string
|
The store value operation identifier for the values collection that will be updated. |
values |
NadaValues
|
The new value collection that will replace the existing one |
receipt |
PaymentReceipt
|
The receipt for the payment made for this operation. |
The unique identifier of the update operation
Promise.<string>
Example
const values = new NadaValues();
values.insert('value1', NadaValue.new_public_integer('2'));
const action_id = await nillionClient.update_values(cluster_id, store_id, values);
# static enable_remote_logging()
Enable remote logging
Writes client logs to a websocket that can be accessed in URL: ws://127.0.0.1:11100/logs. You can use tools like websocat to access and read these logs.
Example
nillionClient.enable_remote_logging();
# static enable_tracking() → {Promise}
Enables tracking for the user.
Enables tracking of client actions (store, retrieve, compute ...)
Promise
Example
await nillionClient.enable_tracking();