The Python SDK Utility for Circle Web3 Services
Project description
Circle Web3 APIs Python SDK
The Circle Web3 Python SDK provides convenient access to the Circle Web3 APIs for applications written in Python. For the API reference, see the Circle Web3 API Docs. Also see this project's PyPI Package Page [TODO].
Requirements
Python 3.10+.
Java 11 and Node 10+ (optional for contributing and development).
Installation
The recommended way of installation is using the Python Package Index (PyPI):
pip install circle-developer-controlled-wallets
pip install circle-smart-contract-platform
pip install circle-user-controlled-wallets
Environment Setup (for Development)
We recommend using pyenv with pyenv-virtualenv for managing Python versions and virtual environments.
Installing pyenv
# Install via Homebrew
brew install pyenv
Installing pyenv-virtualenv
brew install pyenv-virtualenv
Shell Configuration
Add the following to your ~/.zshrc (source):
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init - zsh)"
eval "$(pyenv virtualenv-init -)"
After adding these lines, restart your terminal or run source ~/.zshrc.
Setting Up Your Development Environment
-
Install Python (reads version from
.python-version):pyenv install -
Create a virtual environment for this project:
pyenv virtualenv $(basename $(pwd))
-
Set the virtualenv for this project directory (enables auto-activation):
pyenv local $(basename $(pwd))
-
Verify the setup:
# Should show the virtualenv name pyenv version # Should show Python 3.10.x python --version
The virtualenv will auto-activate when you enter the project directory (requires eval "$(pyenv virtualenv-init -)" in your shell config above).
Installing Python Dependencies
Python dependencies will be installed after building the SDK (see Development section below).
Development
Prerequisites
Complete the Environment Setup section above before proceeding.
Building the SDK
-
Initialize git submodules:
git submodule update --init --recursive
-
Build the OpenAPI specifications:
(cd w3s-openapi-internal && npm ci && make bundle)
-
Install Node dependencies:
npm ci -
Generate the SDK code from OpenAPI specifications:
npm run build
-
Install built SDK distribution packages:
npm run install-dist
Running Tests
# Run all tests
npm run test:all
# Run only unit tests
npm run test
# Run only e2e tests
npm run test:e2e
Usage
Initialize circle web3 API clients. To secure your entity secret and circle API key. Set the API key and entity secret as environment variables. Learn more about entity secret management here
export CIRCLE_ENTITY_SECRET="Your entity secret"
export CIRCLE_WEB3_API_KEY="Your API KEY"
from circle.web3 import utils
dcw_client = utils.init_developer_controlled_wallets_client(api_key="Your API KEY", entity_secret="Your entity secret")
scp_client = utils.init_smart_contract_platform_client(api_key="Your API KEY", entity_secret="Your entity secret")
ucw_client = utils.init_user_controlled_wallets_client(api_key="Your API KEY")
Using client to make a transaction.
from circle.web3 import user_controlled_wallets
# Create a API instance
ucw_client = utils.init_user_controlled_wallets_client(api_key="<your-api-key>")
api_instance = user_controlled_wallets.PINAuthenticationApi(ucw_client)
try:
api_request = user_controlled_wallets.UserTokenRequest.from_dict({"userId": "test-user"})
api_response = api_instance.get_user_token(api_request)
print(api_response.data.user_token)
except user_controlled_wallets.ApiException as e:
print("Exception when calling PINAuthenticationApi->get_user_token: %s\n" % e)
Contributions
Please follow the Conventional Commits format for all commits when creating a contributing pull request for this repo.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file circle_web3_sdk_util-9.3.0.tar.gz.
File metadata
- Download URL: circle_web3_sdk_util-9.3.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3411b6aa59ae4cce0d71177a164f84417b8b7a101c8ddacce50afd325af43cca
|
|
| MD5 |
7c02b17d6c8cc983fdb4d4edd66f6c4f
|
|
| BLAKE2b-256 |
3a84b789ab34da2d4de162929bfdcd7eff177db19d8ea196c7c73ee30060cc74
|