Links

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 @threshold-network/taco [email protected]

Configuration

In order to run the code examples below, you will need the ritualId encryption parameter. Please reach out to us here if you don't already have it.

Encrypt your data

With ritualId and a web3 provider from ethers, we can taco.encrypt our data:
import taco, { conditions } from '@threshold-network/taco'
import { ethers } from "ethers";
const web3Provider = ethers.getDefaultProvider();
const ownsNFT = new conditions.predefined.ERC721Ownership({
contractAddress: '0x1e988ba4692e52Bc50b375bcC8585b95c48AaD77',
parameters: [3591],
chain: 5,
});
const messageKit = await taco.encrypt(
web3Provider,
message,
ownsNFT,
ritualId
);

Decrypt your data

Now we just have to pass the messageKit to the intended recipient:
import taco from '@threshold-network/taco'
import { ethers } from "ethers";
const web3Provider = ethers.getDefaultProvider();
const decryptedMessage = await taco.decrypt(
web3Provider,
messageKit,
web3Provider.getSigner()
);
Since ownsNFT condition refers to an NFT owned by the recipient, taco.decrypt call will prompt the recipient to sign a message and prove the ownership of the caller's wallet.

Next steps

TODO: Link to TACo explainer? High-level overview + trust assumptions
TODO: A list of the most popular/interesting/handy "recipes" for using/integrating TACo into your app.
  • Learn more about conditions here
  • ... about composing conditions here
  • ...