Python samples for the Swan SDK
- Install [
pip
andvirtualenv
][cloud_python_setup] if you do not already have them - Clone the repository
git clone https://github.com/swanchain/python-sdk-docs-samples.git
- Obtain authentication credentials.
To use
swan-sdk
, an Orchestrator API key is required.
- Go to Orchestrator Dashboard, switch network to Mainnet.
- Login through MetaMask.
- Click the user icon on the top right.
- Click 'Show API-Key' -> 'New API Key'
- Set up environment variables
Create a
.env
file in the root directory and add the following environment variables:
WALLET_ADDRESS=<your_wallet_address>
PRIVATE_KEY=<your_private_key>
SWAN_API_KEY=<your_swanchain_api_key>
Make sure to replace the placeholders with your actual values. And have enough balance in your wallet to run the test.
- Change directory to one of the sample folders, e.g. cd
computing
cd compute
- Set Up the Virtual Environment:**
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install the dependencies:
pip install -r requirements.txt
- Run the sample:
python -m pytest -s <test_file_name>.py