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 --recursive
The 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 | sh
If you are on linux, also run the following:
apt update
apt install pkg-config
apt install libssl-dev
apt install build-essential cmake clang git
Then you can install our foundry fork:
cargo install --git https://github.com/Sunscreen-tech/foundry --profile local forge cast anvil --locked
To start your a local testnet:
anvil
Your 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.
pip install -r ./app/requirements.txt
pip install -r ./contracts/requirements.txt
The 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.
Once you modify it, update config.py
to match up the contract information once you edit your contracts.
Simply run
anvil
and denote one of the account and private keys that get printed.
Then set up the deployment information:
cd contracts
python ./execute.py --network local set-account --address **Account Address** --private_key **Account Private Key**
Finally deploy your contract:
python ./execute.py --network local deploy
First, you'll need to create an account in your wallet. You can create the account yourself (using MetaMask, etc.) or you can execute this command to create it AND set it
cd contracts
python ./execute.py --network testnet create-account
Then, Visit the faucet to fund it.
Finally, denote your account's private key and address for deployment.
python ./execute.py --network testnet deploy
If you haven't already funded your account, you'll be given a chance to do so, then hit enter.
cd app
python ./client.py --network local set-account --address **Account Address** --private_key **Account Private Key**
python ./client.py --network local increment
python ./client.py --network local get-number
python ./client.py --network local set-number --value 10
python ./client.py --network testnet create-account
python ./client.py --network testnet increment
python ./client.py --network testnet get-number
python ./client.py --network testnet set-number --value 10