Skip to main content

Getting Started

This guide focuses on an example where decryption is permitted only after a specific block height has been reached. It demonstrates how to get started using block-based conditions to control access to encrypted data on-chain & off-chain .

The dcipher network provides two implementation options to handle blocklock encryption in your decentralized applications:

  1. blocklock-solidity - Solidity library for implementing on-chain blocklock encryption & decryption process directly in your smart contracts.
  2. blocklock-js - JavaScript/TypeScript library for handling off-chain blocklock encryption & decryption in your frontend or backend applications, and this also provides utility tools for blocklock requests.

Choose the implementation that best fits your use case:

  • Choose Solidity Library if you need to:

    • Implement blocklock encryption & decryption directly in your smart contracts
    • The decrypted data will be used in smart contract
    • Integrate with other on-chain protocols
  • Choose JavaScript Library if you need to:

    • Generate encrypted data off-chain
    • Prepare conditional encryption requests before sending to smart contracts
    • Handle encryption/decryption in your frontend/backend applications

Installation Options

Option 1: Solidity Library

For on-chain conditional encryption, install the Solidity library using one of these methods:

Using Foundry (recommended):

forge install randa-mu/blocklock-solidity

Using npm (for Hardhat):

npm install blocklock-solidity

Continue to Solidity Implementation Guide

Option 2: JavaScript/TypeScript Library

For off-chain conditional encryption, install the JavaScript library:

npm install blocklock-js

This includes smart contract TypeScript bindings and features designed to simplify the process of generating encrypted data off-chain for the dcipher network.

The library includes:

  • TypeScript bindings for smart contract interaction
  • Utilities for generating encrypted data off-chain
  • Tools for creating conditional encryption requests
  • Automatic decryption key handling based on chain height conditions

It enables developers to encrypt data tied to a user-specified future chain height securely. The encrypted data can then be used to create on-chain conditional encryption requests in smart contracts. Once the specified chain height is reached, the user’s smart contract will automatically receive the decryption key used for performing on-chain decryption.

Continue to client-side JavaScript Implementation Guide

Additional Resources