fhEVM
WebsiteLibrariesProduct & ServicesDevelopersSupport
0.6
0.6
  • Welcome to fhEVM
  • White paper
  • Getting Started
    • Overview
    • Quick Start
      • Remix
        • 1. Setting up Remix
        • 2. Connect your wallet to Remix
        • 3. Deploying ConfidentialERC20
        • 4. Interacting with the contract
      • Hardhat
        • Prerequisites
        • 1. Setting up Hardhat
        • 2. Writing contracts
        • 3. Testing in mocked mode
        • 4. Deploying the contract
        • 5. Interacting with the contract
  • Tutorials
    • See all tutorials
  • Smart contract
    • Key features
    • Configuration
    • FhEVM contracts
    • Supported types
    • Operations on encrypted types
    • Access Control List
      • ACL examples
    • Encrypted Inputs
    • Decryption
      • Decryption
      • Decryption in depth
      • Re-encryption
    • If sentences
    • Branching in FHE
    • AsEbool, asEuintXX, asEaddress and asEbytesXX operations
    • Generate random numbers
    • Error handling
    • Gas estimation
    • Debug decrypt
    • Using Foundry
  • Frontend
    • Setup
    • Build a web application
    • Using React.js
    • Using Next.js
    • Using Vue.js
    • Using Node or Typescript
    • Using the CLI
    • Common webpack errors
  • Explanations
    • Architectural overview
    • FHE on blockchain
    • fhEVM components
    • Encryption, decryption, re-encryption, and computation
  • References
    • Table of all addresses
    • Smart contracts - fhEVM API
    • Frontend - fhevmjs lib
    • Repositories
  • Developer
    • Contributing
    • Development roadmap
    • Release note
    • Feature request
    • Bug report
    • Status
Powered by GitBook

Libraries

  • TFHE-rs
  • Concrete
  • Concrete ML
  • fhEVM

Developers

  • Blog
  • Documentation
  • Github
  • FHE resources

Company

  • About
  • Introduction to FHE
  • Media
  • Careers
On this page
  • Prerequisite
  • Step 1. Connecting the deployed contract
  • Step 2. Mint tokens to your account
  • Step 3. Verify total supply
  • Step 4. Check your balance
  • Step 5. Transfer tokens
  • Step 6. Verify updated balance
  • Next steps
  • 1. Resources
  • 2. Tools
  • 3. Community

Was this helpful?

Export as PDF
  1. Getting Started
  2. Quick Start
  3. Remix

4. Interacting with the contract

Previous3. Deploying ConfidentialERC20NextHardhat

Last updated 2 months ago

Was this helpful?

After deploying your first fhEVM contract using Remix, this guide shows you how to interact with it directly in Remix using the Zama Plugin.

Prerequisite

Before interacting with your deployed contract, ensure the following:

  • Deployment completed: You have successfully deployed the MyConfidentialERC20 contract (see ).

  • MetaMask wallet: Your MetaMask wallet is connected to the Sepolia testnet(see ). You might want to prepare an additional wallet as the receiver to mock the transfer function.

  • Zama Plugin in Remix: The Zama Plugin is installed and accessible in Remix (see ).

Step 1. Connecting the deployed contract

To perform transactions directly in Remix, your contract needs to be connected to the Zama Plugin:

  1. Open Deploy & run transaction from the side bar

  2. In "Deployed Contract", copy the address of the MYCONFIDENTIALERC20 contract that you just deployed.

  3. Open the Zama Plugin from the side menu.

  4. Paste the contract address into the "At address" field under the Deploy section.

  5. Click At address.

If the address was entered correctly, the MyConfidentialERC20.sol contract will be displayed in the "Deployed Contract" inside the Zama Plugin.

Click to expand the contract, you'll see the interface to interact with all the functions of your contract. ConfidentialERC20Mintable supports all standard ERC-20 functions, but adapted for encrypted values, including:

  • transfer: Securely transfers encrypted tokens.

  • approve: Approves encrypted amounts for spending.

  • transferFrom: Transfers tokens on behalf of another address.

  • balanceOf: Returns the encrypted balance of an account.

  • totalSupply: Returns the total token supply.

Step 2. Mint tokens to your account

From here, you can mint confidential ERC20 token to your account:

  1. Copy your wallet address from MetaMask.

  2. Inside Zama Plugin, click to expand the mint function of your contract.

  3. Enter your wallet address and the amount of tokens to mint (e.g., 1000).

  4. Click Submit.

  5. Confirm the transaction in MetaMask.

Once sccussful, you should see the message in the terminal.

Step 3. Verify total supply

After a successful mint transaction, click the totalSupply to reflect the minted tokens (e.g., 1000).

Step 4. Check your balance

To verify your account balance:

  1. Click to expand the balanceOf function.

  2. Enter your wallet address.

  3. Click Submit to verify your account balance.

Your balance is stored as encrypted data using FHE. No one else can view if except you.

To view the balance in plaintext:

  • Click the re-encrypt option

  • Confirm the transaction in Metamask

You can see that the ciphertext is decrypted and your balance is the amount that you just minted.

Step 5. Transfer tokens

To transfer confidential ERC20 tokens to another account:

  1. Copy the address of the receiver's wallet.

  2. Click transfer to expand the function, set the following parameters:

    • To: Enter the wallet address of reveiver.

    • encryptedAmount: Specify the amount that you want to transfer (e.g.1000). Choose euint64.

    • inputProof: Check the input box.

  3. Click Submit to proceed.

  4. Confirm the transaction in MetaMask.

If successful, you should see the message in the terminal.

Step 6. Verify updated balance

After making a transfer, you can verify your updated account balance:

  1. Perform re-encryption to confirm the changes, you should see the remaining token in your account.(e.g., 900 tokens remaining).

Always re-encrypt to validate ciphertext transformations and confirm operations.


Next steps

🎉 Congratulations on completing this tutorial! You’ve taken the first step in building confidential smart contracts using fhEVM. It's time now to take the next step and build your own confidential dApps!

1. Resources

To continue your journey and deepen your knowledge, explore the resources below.

2. Tools

Use out-of-box templates and frameworks designed for developers to build confidential dapps easily.

Smart contract development

Frontend development

3. Community

Join the community to shape the future of blockchain together with us.

Use the balanceOf function again to check the updated balance of your original account (see the .)

: Understand the core technology behind fhEVM, including its cryptographic foundations and use cases.

: Expand your skills with hands-on demos and tutorials crafted to guide you through various real-world scenarios.

: If you have a chatGPT plus account, try out our custom ChatGPT model tailored for Solidity and fhEVM developers.

: A developer-friendly starting point for building and testing smart contracts on fhEVM.

: Access standardized contracts for encrypted operations.

: Quickly develop FHE-compatible dApps using a clean React.js setup.

: Build scalable, server-rendered dApps with FHE integration.

: Develop responsive and modular dApps with FHE support in Vue.js.

: Join the community to get the latest update, have live discussion with fellow developers and Zama team.

: Get support on all technical questions related to fhEVM

: Participate to tackle challenges and earn rewards in cash.

Read the Whitepaper
See more demos and tutorials
Try out AI coding assistant
Hardhat Template
fhEVM Contracts Library
React.js Template
Next.js Template
Vue.js Template
Discord
Community Forum
Zama Bounty Program
Step 5: Check your balance
Step 3
Step 2
Step 1