Skip to main content

Store Values

Store secret values (SecretBlob or SecretInteger values) in the network by the cluster, secret values, permissions, and payment receipt.

Create a SecretBlob to Store

Create a SecretBlob, with one or more secret strings encoded as bytearrays

const secretName = 'my-password'
const secretValue = 'abcdefg'
const nillionSecret = new nillion.NadaValues();
const byteArraySecret = new TextEncoder().encode(secretValue);
const secretBlob = nillion.NadaValue.new_secret_blob(byteArraySecret);
nillionSecret.insert(secretName, secretBlob);

Create a SecretInteger to Store

Create a SecretInteger with one or more secrets values

const secretName = 'my-score'
const secretValue = 100
const nillionSecret = new nillion.NadaValues();
const secretInteger = nillion.NadaValue.new_secret_integer(
secretValue.toString()
);
nillionSecret.insert(secretName, secretInteger);

Get a Quote to Store Values

const ttl_days = 30; // set how long to store values
const storeOperation = nillion.Operation.store_values(
nillionSecret,
ttl_days
);

const quote = await getQuote({
client: nillionClient,
operation: storeOperation,
});

Pay to Store Values and get Payment Receipt

src/nillion/components/StoreSecretForm.tsx
loading...

Store Secrets JavaScript Helper Function

src/nillion/helpers/storeSecrets.ts
loading...