Comment on page
Testing & Interacting
Now let's talk a little bit about testing for Fhenix FHE contracts. If you don't care about this and you just want to hack, we recommend at least skimming the Remix Section to understand how to use encryption/decryption APIs.
Some developers prefer a more manual approach at first - where you just want to quickly verify that something works, play around with a small function or just verify functionality without writing tests or setting up a full developer environment. To do this, we'll show how you can manually test contracts with FHE-encrypted inputs and outputs without using fhevmjs as a helper library.
Convieniently, LocalFhenix comes with APIs that perform encryption or decryption for you.
The APIs are:
For example, if I wanted to encrypt the number 259 as a uint16, I would use:
To decrypt a number, we use a GET request, with the encrypted string (returned from a
TFHE.reencryptfunction), such as:
Note: At the moment, to perform decryption you must provide the public key of the service for it to be able to decrypt data. That means you need to call the view function of the FHE-enabled contract with the key from the
As we mentioned in previous sections, Fhenix uses extensions to the standard EVM to enable FHE functionality. To write unit tests, we use LocalFhenix instead of hardhat network - this is similar to deploying & testing contracts on Ganache. To see an example of how to write unit tests & create CI workflows you can refer to our reference wrapped ERC20 contract repo.