Skip to content

Sunscreen-tech/parasol-python-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parasol Python Monorepo Template

This repository includes a sample to:

  1. Deploy a contract with FHE operations
  2. Interact with it as a contract client (i.e. call functions as a user of the contract)

Getting Started

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

Using The Test Network

The test network is deployed and available at: https://rpc.sunscreen.tech/parasol with Chain ID 574.

Using Anvil as a local testnet

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.

Install Python dependencies

pip install -r ./app/requirements.txt
pip install -r ./contracts/requirements.txt

Deploying A Contract

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.

To Anvil (local network)

Get test account

Simply run

anvil

and denote one of the account and private keys that get printed.

Deploy

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

To the test network

Create an account

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.

Deploy

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.

Interacting as A Client

cd app

With The Local Network (Anvil)

Configuring your account

python ./client.py --network local set-account --address **Account Address** --private_key **Account Private Key**

To Increment The Counter

python ./client.py --network local increment

To Get the Current Counter

python ./client.py --network local get-number

To Set A New Number Counter

python ./client.py --network local set-number --value 10

With The Test Network

Configuring your account

python ./client.py --network testnet create-account

To Increment The Counter

python ./client.py --network testnet increment

To Get the Current Counter

python ./client.py --network testnet get-number

To Set A New Number Counter

python ./client.py --network testnet set-number --value 10

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published