Quickstart (Testnet)

TACo SDK allows you to use threshold encryption & decryption in your apps.

In just a few minutes you will able to:

  • Encrypt your data

  • Describe decryption conditions with onchain data

  • Threshold-decrypt your data when these conditions are met

Installation

Install taco and ethers with your favorite package manager:

$ npm install @nucypher/taco ethers@5.7.2

Configuration

In order to run the code examples below, you will need the ritualId encryption parameter. Your wallet address (encryptor) will also have to be allow-listed for this specific ritual. Please reach out to us here in order to receive ritualId and allow-list access, or use the publicly available testnet rituals.

Encrypt your data

With ritualId and a web3 provider from ethers, we can taco.encrypt our data:

import { initialize, encrypt, conditions, domains } from '@nucypher/taco';
import { ethers } from "ethers";

// We have to initialize the TACo library first
await initialize();

const web3Provider = new ethers.providers.Web3Provider(window.ethereum);

const ownsNFT = new conditions.predefined.erc721.ERC721Ownership({
  contractAddress: '0x1e988ba4692e52Bc50b375bcC8585b95c48AaD77',
  parameters: [3591],
  chain: 5,
});

const message = "my secret message";

const messageKit = await encrypt(
  web3Provider,
  domains.TESTNET,
  message,
  ownsNFT,
  ritualId,
  web3Provider.getSigner() 
);

Decrypt your data

Now we just have to pass the messageKit to the intended recipient:

import { initialize, decrypt, domains, getPorterUri } from '@nucypher/taco';
import { ethers } from "ethers";

// We have to initialize the TACo library first
await initialize();

const web3Provider = new ethers.providers.Web3Provider(window.ethereum); 

const decryptedMessage = await decrypt(
  web3Provider,
  domains.TESTNET,
  messageKit,
  getPorterUri(domains.TESTNET),
  web3Provider.getSigner()
);

Since ownsNFT condition refers to an NFT owned by the recipient, decrypt call will prompt the recipient to sign a message and prove the ownership of the caller's wallet.

Next steps

Learn more about using TACo on the testnet - Testnet Integration.

Learn more about testnet trust assumptions and limitations - Testnet Trust Assumptions

Example applications

The following samples showcase integrations with React-based web apps, and serve as an 'end-to-end' reference for creating conditions-based encryption & decryption:

Last updated