npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

secret-network-ccl

v1.0.3

Published

Secret Network's Confidential Comutation Layer

Downloads

60

Readme

Secret Network Confidential Computation Layer (CCL)

A complete, compact, and simple encryption + RNG toolkit for EVM chains, written in TypeScript.

Features

  • Data encryption (key/value store) on EVM
  • Generate on-chain verifiable randomness on EVM
  • Connected to 20+ EVM Chains

Secret Network Documentation

See Secret Network documentation for a complete guide

Installing

npm i secret-network-ccl

Environment Configuration

Add EVM private key and API endpoint to your .env file:

PRIVATE_KEY=1987d98c566f622124850322fd3a064751bdabe20f50ca9fejfldf83720 INFURA_ENDPOINT=7bb38fdfdlfjldjf022734325edecdf0eS

Encrypted Payloads

With encryptData you can encrypt a string in a Secret Network smart contract which can be queried with a password.

Select the EVM chain that you want to use to execute the Secret Network smart contract and update your secretPathAddress with the correct gateway contract address. For this example, we are using Sepolia:

let secretPathAddress = "0x3879E146140b627a5C858a08e507B171D9E43139";

encryptData requires privateKey, endpoint, secretPathAddress, , network, data, and password parameters:

const { encryptData } = require('secret-network-ccl');

let privateKey = process.env.PRIVATE_KEY;
let endpoint = `https://sepolia.infura.io/v3/${process.env.INFURA_ENDPOINT}`;
let secretPathAddress = "0x3879E146140b627a5C858a08e507B171D9E43139";
let data = "I want to encrypt this data";
let password = "password";
let network = "testnet"
//use "mainnet" for network if contract is deployed on Secret mainnet 

encryptData(privateKey, endpoint, secretPathAddress, network data, password);

Verifiable Randomness

With requestRandomness you can request an array of up to 2000 random numbers on chain from Secret Network.

Select the EVM chain that you want to use to execute the Secret Network smart contract and update your secretPathAddress with the correct gateway contract address. For this example, we are using Sepolia:

let secretPathAddress = "0x3879E146140b627a5C858a08e507B171D9E43139"

requestRandomness requires privateKey, endpoint, secretPathAddress, network, numbers, and max parameters:

numbers is the amount of numbers you want to request

max is the the max range the numbers can be. Ex: If you set max to 200, the largest random number that can be returned is 200.

const {requestRandomness} = require('./node_modules/secret-network-ccl')

let privateKey = process.env.PRIVATE_KEY;
let endpoint = `https://sepolia.infura.io/v3/${process.env.INFURA_ENDPOINT}`;
let secretPathAddress = "0x3879E146140b627a5C858a08e507B171D9E43139";
let numbers = "15";
let max = "5"; 
let network = "testnet"
//use "mainnet" for network if contract is deployed on Secret mainnet 

requestRandomness(privateKey, endpoint, secretPathAddress, network, numbers, max); 

Executing Secret contracts

With executeSecretContract you can execute any SecretPath-compatible smart contract on Secret Network.

Select the EVM chain that you want to use to execute the Secret Network smart contract and update your secretPathAddress with the correct gateway contract address. For this example, we are using Sepolia:

let secretPathAddress = "0x3879E146140b627a5C858a08e507B171D9E43139"

For this example, we are going to execute the key value store contract on Secret Network.

executeSecretContract requires the Secret contractAddress, codeHash, network,handle (ie the function you want to execute in the Secret Network contract), and any parameters needed for the handle function, which in this case is data and password.

const {executeSecretContract} = require('./node_modules/secret-network-ccl')
const dotenv = require('dotenv');
dotenv.config();

const contractAddress = "secret1s79j3uaa0g49ncur884vv80ucz7hdwgltgke52";
const contractCodeHash = "f0947ac3d0459bd5ccc24a43aa18762325f7582dc7919b4557ecf98b81345261";
let privateKey = process.env.PRIVATE_KEY;
let endpoint = `https://sepolia.infura.io/v3/${process.env.INFURA_ENDPOINT}`;
let secretPathAddress = "0x3879E146140b627a5C858a08e507B171D9E43139";
let data = { key: "data", value: "moonbeam" }
let password = { key: "password", value: "1234" };
let handle = "request_encrypt";
let network = "testnet"
//use "mainnet" for network if contract is deployed on Secret mainnet 

executeSecretContract( privateKey, endpoint, secretPathAddress, routing_contract, routing_code_hash, network, handle,  data,
  password); 

Querying Secret contracts

With querySecretContract you can query any SecretPath-compatible smart contract on Secret Network.

For this example, we are going to query the key value store contract on Secret Network.

querySecretContract requires the Secret contractAddress, codeHash, network, handle (ie the name of the query function you want to query in the Secret Network contract), and any parameters needed for the query, which in this case is password.

const {querySecretContract} = require('./node_modules/secret-network-ccl')
const dotenv = require('dotenv');
dotenv.config();

const contractAddress = "secret1s79j3uaa0g49ncur884vv80ucz7hdwgltgke52";
const contractCodeHash = "f0947ac3d0459bd5ccc24a43aa18762325f7582dc7919b4557ecf98b81345261";
let password = { password: "2" }
let handle = "retrieve_data";
let network = "testnet"
//use "mainnet" for network if contract is deployed on Secret mainnet 

querySecretContract(  contractAddress, contractCodeHash, network, handle,
  password);