Integrate TACo into apps
Last updated
Last updated
Note that using TACo in production requires a unique DKG initialization ritual, unique DKG public key, and a unique cohort of nodes running TACo software. These are available via a unique ritualID
parameter. See the Mainnet Access page for instructions on how to initialize a DKG ritual.
taco
domainBefore we install taco
, we need to consider which domain we would like to use:
MAINNET
(mainnet
network) - production environment
TESTNET
(tapir
network) - stable testnet that matches mainnet
DEVNET
(lynx
network) - bleeding-edge testnet used for internal development and future features
Once you've picked a network, install @nucypher/taco
from with the appropriate tag based on the chosen network. To find the appropriate version, refer to the "Tags" column in the "Current Tags" section.
You can learn more about the current state of mainnet
and test networks here:
taco
To begin, we need to install the taco
, and taco-auth
libraries:
For this guide, we'll need a few extra packages:
To use taco
, we have to call initialize
method first. This method takes care of initializing the WASM module for taco
dependencies.
With this out of the way, we're ready to use taco
in our app.
Before we encrypt our data, we have to define the decryption conditions.
We will now specify the condition that must be met to access the data. In this tutorial, we will require that the requester owns an ERC721 token on Ethereum mainnet with a token ID of 5954
.
We can create more complex conditions by combining them with CompoundCondition
We're ready to encrypt our plaintext and gate access to the encrypted contents with our conditions, NFTOwnership
.
The resulting messageKit
contains the encrypted data and associated conditions.
Finally, we will test the conditional access control service by requesting decryption:
At decryption time, the requester will be asked to verify their address by signing a message from their wallet. If the requester's address controls the minimum number (or greater) of the specified NFT, they are eligible to receive the requisite number of decryption fragments. By assembling these fragments, they can decrypt the encrypted data and view the plaintext.
This is the complete, end-to-end example of taco
integration
Conditions are the requirements for a data recipient to access the plaintext data – i.e. what they will need to prove later to gain decryption rights. There are multiple we can use here, including predefined conditions such as ERC721Ownership.
The ERC721Ownership
condition checks the owner of a given token ID. It can be customized by using the ownerOf
contract method and comparing it with the requestor's signature. For more information, see the section.