Python samples for the Swan SDK
- Clone the repository
git clone https://github.com/swanchain/python-sdk-docs-samples.git
- Obtain authentication credentials.
To use swan-sdk
, an Swan API Key is required.
Steps to get an Swan API Key:
- Go to Swan Console. Make sure you're under the Mainnet environment.
- Login through MetaMask.
- Click 'Generate API Key'.
- Store your API Key safely, do not share with others.
To use the swan-sdk
Multi-Chain Storage (MCS) service, an MCS API key is required.
Steps to get a MCS API Key:
- Go to Multi Chain Storage. Make sure you're under the Mainnet environment.
- Login through MetaMask.
- Click the gear icon on the top right and select 'Setting'.
- Click 'Create API Key'.
- Store your API Key safely, do not share with others.
- 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>
MCS_API_KEY=<your_mcs_api_key>
Make sure to replace the placeholders with your actual values. And have enough balance in your wallet to run the test.
- 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 compute/<sample_name>.py
python storage/<sample_name>.py