---
# System prepended metadata

title: tDec Demo Runbook
tags: [nucypher]

---

# tDec Demo Runbook

## How to read this document?

To understand how the demo works, read at least the _"Scenario G1: A ERC20 Balance Condition"_ - it shows how a complete, "green-path" demo works. Other demo scenarios are ommiting certain parts for brevity.

Demo URL: https://nucypher-ts-demo-tdec.netlify.app/

## Green Path Scenarios

### Scenario G1: A ERC20 Balance Condition

_"Owner of the connected wallet has at least 10 ERC20 tokens"_

#### Prerequisites

- Switch to **Rinkeby** testnet
- Get at least 100 ERC20 tokens: https://erc20faucet.com/
- Get some ETH: https://faucet.rinkeby.io/

Expected token address: `0xFab46E002BbF0b4509813474841E0716E6730136`

#### Set the Configuration

- The demo should work out-of-the-box on the Rinkeby network. 
- Simply click "FETCH TDEC CONFIG" button to load the configuration and proceed with the demo.
![](https://i.imgur.com/e0H80Jl.png)


#### Select EVM Condition

- Select "evm" condition here:

![](https://i.imgur.com/iX3PzpI.png)

#### Fill in Condition details

- Use ERC20 token address. 
- Set `:userAddress` as a method parameter.

![](https://i.imgur.com/OobKHVa.png)

- Your JSON preview should show:
```jsonld=
{
  "contractAddress": "0xFab46E002BbF0b4509813474841E0716E6730136",
  "chain": "Rinkeby",
  "standardContractType": "ERC20",
  "method": "balanceOf",
  "parameters": [
    ":userAddress"
  ],
  "returnValueTest": {
    "comparator": ">",
    "value": "10"
  }
}
```

#### Perform the rest of the flow

- Put in a message to be encrypted
- Click the "Encrypt" button
- Copy the encrypted message (you can click the copy icon)
- Paste the encrypted message into a step 3 box
- Click the "Decrypt" button
- You will be asked to sign a message
- The decrypted message shows in `Plaintext:` field


![](https://i.imgur.com/FciGMep.png)

- During the demo, you will be asked to sign a message confirming the ownership of the connected wallet. The signature is cached in `localStorage`.
- To remove cached signature, click here:
![](https://i.imgur.com/WdsLmzF.png)


### Scenario G2: Condition with A Logical Operator OR

_"Owner of the connected wallet satisfies the first or the second condition"_

#### Prerequisites

- This scenario builds on Scenario G1, so we need to satisfy their preconditions first

#### Create A Truthy ERC20 Condition

- Reproduce the ERC20 condition from previous scenario

![](https://i.imgur.com/OobKHVa.png)

#### Create A Falsy RPC Condition

- Select the "or" logical operator, and "rpc" condition type

![](https://i.imgur.com/qJZRwij.png)

- Add a falsy condition. The condition is falsy, because at this point the connected wallet actually has some ETH.

![](https://i.imgur.com/eQ7js9C.png)

- Your JSON preview should show:

```jsonld=
{
  "contractAddress": "0xFab46E002BbF0b4509813474841E0716E6730136",
  "chain": "Rinkeby",
  "standardContractType": "ERC20",
  "method": "balanceOf",
  "parameters": [
    ":userAddress"
  ],
  "returnValueTest": {
    "comparator": ">",
    "value": "10"
  }
}
{
  "operator": "or"
}
{
  "chain": "Rinkeby",
  "method": "eth_getBalance",
  "parameters": [
    ":userAddress"
  ],
  "returnValueTest": {
    "comparator": ">",
    "value": "0"
  }
}
```

#### Finish The Flow

- Note that we're expected to sign the message again - clear the signature cache if needed
- Encrypt, decrypt - you know the drill
- The condition should evaluate correctly

### Scenario G4: A ERC721 Ownership Condition

_"User owns a specific instance of an ERC721 token"_

#### Prerequisites

- Switch to Rinkeby testnet
- Get an NFT: https://numbersontap.cyberpnk.win/
    - Take note of your `tokenId`. You can find it transaction details on Etherscan.
- Get some ETH: https://faucet.rinkeby.io/

Expected NFT address: `0x70979C339131d811cB96cF363f70382ac4a36503`

#### Fill in Condition details

- Use ERC721 token address. 
- Set `tokenId` of your NFT as a method parameter.
- Set `:userAddress` as a return value test.

![](https://i.imgur.com/zQ73XTU.png)

- Your JSON preview should show:
```jsonld=
{
  "contractAddress": "0x70979C339131d811cB96cF363f70382ac4a36503",
  "chain": "Rinkeby",
  "standardContractType": "ERC721",
  "method": "ownerOf",
  "parameters": [
    12
  ],
  "returnValueTest": {
    "comparator": "==",
    "value": ":userAddress"
  }
}
```

### Scenario G5: A ERC721 Balance Condition

_"User owns at least one of the ERC721 tokens"_

#### Prerequisites

- Switch to Rinkeby testnet
- Get an NFT: https://numbersontap.cyberpnk.win/
- Get some ETH: https://faucet.rinkeby.io/

Expected NFT address: `0x70979C339131d811cB96cF363f70382ac4a36503`

#### Fill in Condition details

- Use ERC721 token address. 
- Set `:userAddress` as a return value test.

![](https://i.imgur.com/A4Oa0Xs.png)

- Your JSON preview should show:
```jsonld=
{
  "contractAddress": "0x70979C339131d811cB96cF363f70382ac4a36503",
  "chain": "Rinkeby",
  "standardContractType": "ERC721",
  "method": "balanceOf",
  "parameters": [
    ":userAddress"
  ],
  "returnValueTest": {
    "comparator": ">",
    "value": "0"
  }
}
```

#### Finish The Flow

- Note that we're expected to sign the message again - clear the signature cache if needed
- Encrypt, decrypt - you know the drill
- The condition should evaluate correctly

#### Transfer The NFT Away And Try Again

- Send the NFT to `0x69B8f4B65Fc366d94C8a3047719a72Bb94922bE8` address
- Wait until the transaction is settled
- Try to decrypt again
- The decryption should fail


## Red Path Scenarios

### Scenario R1: Decryption Fails on A Falsy Condition

_"User receives feedback about decryption failure"_

#### Create A Falsy Condition

- We set the "timelock" to 0, but the clock always displays a postive value (block number)

![](https://i.imgur.com/MKkwITI.png)

#### Attempt To Decrypt And Receive Errors

- Encrypt, decrypt - you know the drill
- The condition should evaluate correctly to **false**

![](https://i.imgur.com/A5LvzUY.png)

