This repository includes a sample to:
- Deploy a contract with FHE operations
- Interact with it as a contract client (i.e. call functions as a user of the contract)
You can deploy and interact with contracts via our testnet or install a single-node network on your dev machine to test locally. First ensure the sub-modules are synced:
git submodule update --init --recursiveThe test network is deployed and available at: https://rpc.sunscreen.tech/parasol with Chain ID 574.
First, you'll need cargo; if you don't have it, the easiest way is to install via rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shIf you are on linux, also run the following:
apt updateapt install pkg-configapt install libssl-devapt install build-essential cmake clang gitThen you can install our foundry fork:
cargo install --git https://github.com/Sunscreen-tech/foundry --profile local forge cast anvil --lockedFor more info on foundry, see the official docs.
To start your a local testnet:
anvilYour network is ready! You will have 10 accounts and 10 private keys available for use. If you didn't change any defaults, your network should be available at http://127.0.0.1:8545 with Chain ID 31337.
cd ./contracts & npm installcd ./app/counter & npm installThe deployment code exists in the contracts folder.
The contract we will deploy exists under the src directory. It contains the Counter.sol contract, which is the one we are deploying. We suggest using this as a starting point to see how the process works before modifying it.
Simply run
anviland denote one of the account and private keys that get printed.
Go to hardhat.config.ts and add the private key for your account WITHOUT the '0x' prefix to the local account.
NOTE You need to put a valid private-key value for both, the testnet and local. Hardhat doesn't like it if the values are bad, even if unused.
Then deploy your contract:
npx hardhat run --network local scripts/deploy.tsFirst, you'll need to create an account in your wallet and then, Visit the faucet to fund it.
Finally, denote your account's private key and address for deployment.
Go to hardhat.config.ts and add the private key for your account WITHOUT the '0x' prefix to the testnet account.
####Deploy Then deploy your contract:
npx hardhat run --network testnet scripts/deploy.tscd app/counternpm start