🚀 Getting StartedPublish Your Docs🍓 Interact with FHE rollup

🍓 Interact with FHE rollup

Prerequisites

Before starting, ensure the following is ready:

Importing Keys for Token Operations

Before performing any operations like creating, minting, or transferring tokens, you need to import the necessary keys into the system. The keys include the token deployer’s private key, which is required for initiating these transactions.

In this step, you’ll import the token deployer’s private key from the file test-data/keys/token_deployer_private_key.json.

make import-keys

Make sure you have this step completed before attempting any of the other token operations mentioned above. It ensures that the system can authenticate and execute operations securely.

Step-by-Step Guide to FHE Rollup Interaction

1. Creating Confidential Tokens

This step creates a new encrypted token using the sov_bank_fhe module. These tokens are secured with FHE, ensuring privacy.

make test-fhe-create-token
  • What happens: This command mints 1,000 confidential tokens to the sov1l6n...r94 address.
  • Expected output: In the terminal, you’ll see a message indicating that the token creation has been submitted. Wait 5–10 seconds for the transaction to be processed.
  • Server logs: Check the server logs to monitor the FHE operations and verify the token creation.

2. Minting Additional Tokens

If you want to mint more tokens to the same address or another address, you can do so easily.

make test-fhe-mint-token
  • What happens: Mints an additional 500 tokens to the specified address.
  • Expected output: Similar to the token creation, you’ll see confirmation in the logs, and the total token supply will increase.
  • Verification: Follow the next step to query the total supply and ensure the minting operation was successful.

3. Querying Token Supply

You can query the total supply of the tokens either in their encrypted (ciphertext) or decrypted (plaintext) form.

  • Encrypted supply (Ciphertext): This shows the token supply in its encrypted form, preserving privacy.

    make test-fhe-token-raw-supply-of
  • Decrypted supply (Plaintext): This reveals the actual token supply.

    make test-fhe-token-supply-of
  • Expected output: Depending on which command you run, you’ll get either the encrypted or plaintext token supply. Server logs will confirm successful querying.

4. Transferring Confidential Tokens

Transfer tokens between two addresses using the FHE rollup.

make test-fhe-token-transfer
  • What happens: This transfers 100 encrypted tokens from sov1l6n...r94 to sov15vs...7gc.
  • Expected output: You’ll see confirmation of the transaction in the terminal and logs, with a delay of 5–10 seconds for the operation to process.

5. Querying User Balances

You can check the token balance of any user in two forms: encrypted or decrypted.

Encrypted Balance (Ciphertext)

This command queries the encrypted balance:

curl -sS -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"confidentialToken_rawBalanceOf","params":{"user_address":"sov1l6n...r94", "token_id":"TOKEN_ID"},"id":1}' \
http://127.0.0.1:12345

Decrypted Balance (Plaintext)

To get the actual balance:

curl -sS -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"confidentialToken_balanceOf","params":{"user_address":"sov1l6n...r94", "token_id":"TOKEN_ID"},"id":1}' \
http://127.0.0.1:12345
  • Expected output: Depending on the chosen method, you’ll receive the encrypted or plaintext balance. The logs will confirm that the balance was fetched.

Feel free to explore more features and operations in Cyferio SDK, and don’t hesitate to reach out if you encounter any issues!