A Python SDK for interacting with JPYCv2 contracts
Project description
Core SDK
A Python SDK to interact with the JPYCv2's core contracts. Ideal for those who want to interact with JPYC protocol in any Python-backend environments.
🪄 Usage
1. Install jpyc_core_sdk Package
# uv
$ uv add jpyc_core_sdk
# poetry
$ poetry add jpyc_core_sdk
# pip
$ pip install jpyc_core_sdk
2. Configure SDK Clients
from jpyc_core_sdk import JPYC, SdkClient
# Configure SDK client using default RPC endpoint
client = SdkClient(
chain_name="ethereum",
network_name="mainnet",
private_key={PRIVATE_KEY},
)
# Or configure SDK client using custom RPC endpoint
client = SdkClient(
chain_name="ethereum",
network_name="mainnet",
private_key={PRIVATE_KEY},
rpc_endpoint={CUSTOM_RPC_ENDPOINT},
)
# Configure JPYC client
jpyc = JPYC(client=client)
[!TIP] As for sensitive data such as private keys or api keys, we strongly recommend using some secure storage and read them from the securely embedded environment variables. This reflects our design decision of not using any environment variables within the SDK itself, aiming to make it as flexible as possible for the developers. Also, using some arbitrary environmental variables often results in unexpected behaviors (e.g., naming conflicts).
3. Call JPYC Contracts
Use the configured JPYC client to call JPYC's contract functions wherever you would like.
from {CONFIG_FILE} import jpyc
...
# Call a contract function (e.g., transfer)
tx_hash = jpyc.transfer(
to={TO_ADDRESS},
value=2025,
)
...
[!NOTE]
- More code examples are available at
examplesdirectory.- More detailed development documentation is available at
docsdirectory.
⛓️ Supported Networks
Please use one of the combinations of chain-network names when configuring the SDK clients.
[!TIP] For local testing & development, you could use
localhost-devnetpair.
| Chain Name | Network Names |
|---|---|
ethereum |
mainnet, sepolia |
polygon |
mainnet, amoy |
gnosis |
mainnet, chiado |
avalanche |
mainnet, fuji |
astar |
mainnet |
shiden |
mainnet |
localhost |
devnet |
💬 Supported Providers
We're currently supporting HTTPProvider (the most simple & widely-used one) only. More providers (notably WebSocketProvider) are to be supported in the near future, so stay tuned!
🛠 Development
[!IMPORTANT] Sections below are mainly for the advanced users (e.g., contributors of this repo).
📦 Package Management
Add packages
# add packages for production
$ uv add {package_name}
# add packages for development
$ uv add --dev {package_name}
Remove packages
# remove production packages
$ uv remove {package_name}
# remove development packages
$ uv remove --dev {package_name}
🔎 Testing
Please see README at tests directory.
✅ Static Code Analysis
[!NOTE] Analysis results are also to be checked on our CI workflow.
Linting
# run linter without fixing
$ uv run ruff check {dir_name}
# run linter & auto-fix (if available)
$ uv run ruff check {dir_name} --fix
Formatting
# run formatter without fixing
$ uv run ruff format {dir_name} --check
# run formatter & auto-fix
$ uv run ruff format {dir_name}
Type Checking
# run mypy
$ uv run mypy {dir_name}
Pre-Commit Hooks
Pre-commit script is configured at .pre-commit-config.yaml. This automatically runs the configured hooks before executing any git commit commands. You could also simulate the hooks by running the following.
# simulate pre-commit hooks without creating an actual commit
$ uv run pre-commit run --all-files
📝 Comments & Docstrings
Docstrings should be written in the Google-style.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jpyc_core_sdk-1.0.3.tar.gz.
File metadata
- Download URL: jpyc_core_sdk-1.0.3.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d6bdffab18fbd1ec5c37d4654ba5aa3f0b2fa8608ce0ae5e48f9aba4b25cfe7
|
|
| MD5 |
7c053a445df88e54e1f3fb7d949ec2ef
|
|
| BLAKE2b-256 |
072d03e8ebe0d3cd8abb1e6d9187207378083db90a041ae3f391e1b9544f1f3a
|
File details
Details for the file jpyc_core_sdk-1.0.3-py3-none-any.whl.
File metadata
- Download URL: jpyc_core_sdk-1.0.3-py3-none-any.whl
- Upload date:
- Size: 27.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8bf906485e7abb8bda5259834c042938930e349161d5e791d3e50a0404a30bb
|
|
| MD5 |
a6d610f92854de029b2b25dfffac790e
|
|
| BLAKE2b-256 |
136c8329d59e48569ce6c124085285ad3d81a70e488b7a8a7db3f7d8b085de31
|