ICP-PY-CORE is a maintained and extended fork of ic-py.
This version introduces a modular architecture, protocol upgrades, and new APIs while preserving compatibility with the IC ecosystem.
Highlights:
- β
Modular structure under
src/(icp_agent,icp_identity,icp_candid, etc.) - β
Updated boundary node v3 endpoints (
/api/v3/canister/.../call) - β
Optional certificate verification via
blst - β Type-safe Candid encoding/decoding
- β
Pythonic high-level
Agent.update()andAgent.query()methods
π Special thanks to the original ic-py author for their foundational work.
pip install icp-py-coreIf you use the Candid parser, we pin
antlr4-python3-runtime==4.9.3.
For optional certificate verification, see the blst section below.
Each component is isolated for clarity and extensibility:
src/
βββ icp_agent/ # Agent & HTTP Client
βββ icp_identity/ # ed25519 / secp256k1 identities
βββ icp_candid/ # Candid encoder/decoder
βββ icp_principal/ # Principal utilities
βββ icp_certificate/ # Certificate validation
βββ icp_core/ # Unified facade (one-line import)
Import everything from a single entrypoint:
from icp_core import (
Agent, Client,
Identity, DelegateIdentity,
Principal, Certificate,
encode, decode, Types,
)All update calls now target Boundary Node v3 endpoints:
/api/v3/canister/<canister_id>/call
Enable verifiable responses via BLS12-381 signatures with blst:
agent.update("canister-id", "method_name", [{'type': Types.Nat, 'value': 2}], verify_certificate=True)from icp_core import Identity
iden = Identity(privkey="833fe62409237b9d62ec77587520911e9a759cec1d19755b7da901b96dca3d42")
print(iden.sender().to_str())from icp_core import Agent, Client, Identity
iden = Identity()
client = Client("https://ic0.app")
agent = Agent(iden, client)from icp_core import Types
result = agent.update(
"wcrzb-2qaaa-aaaap-qhpgq-cai",
"set",
[{'type': Types.Nat, 'value': 2}],
verify_certificate=True,
return_type=[Types.Nat],
)reply = agent.query("wcrzb-2qaaa-aaaap-qhpgq-cai", "get", [])
print(reply)git clone https://github.com/supranational/blst
cd blst/bindings/python
# For Apple Silicon (if needed)
# export BLST_PORTABLE=1
python3 run.me
export PYTHONPATH="$PWD:$PYTHONPATH"Or copy to site-packages manually:
BLST_SRC="/path/to/blst/bindings/python"
PYBIN="python3"
SITE_PURE="$($PYBIN -c 'import sysconfig; print(sysconfig.get_paths()[\\"purelib\\"])')"
SITE_PLAT="$($PYBIN -c 'import sysconfig; print(sysconfig.get_paths()[\\"platlib\\"])')"
cp "$BLST_SRC/blst.py" "$SITE_PURE"/
cp "$BLST_SRC"/_blst*.so "$SITE_PLAT"/Use WSL2 (Ubuntu) for best compatibility.
- π§© Candid encode & decode
- π ed25519 & secp256k1 identities
- π§Ύ Principal utilities (strict DER mode)
- βοΈ High-level canister calls via Agent
- πͺ Support for Ledger / Governance / Management / Cycles Wallet
- π Sync & async APIs
from icp_core import Agent, Client, Identity, Types
client = Client("https://ic0.app")
iden = Identity()
agent = Agent(iden, client)
# Update (auto-encode [42])
agent.update("wcrzb-2qaaa-aaaap-qhpgq-cai", "set_value", [42], verify_certificate=True)
# Query (auto-encode empty args)
res = agent.query("wcrzb-2qaaa-aaaap-qhpgq-cai", "get_value", None, return_type=[Types.Nat])
print(res)Migrating from ic-py? See MIGRATION.md for:
- New package layout (
icp_*subpackages and theicp_corefacade) - Endpoint changes (v3 call)
- Argument auto-encoding in
Agent.update()/Agent.query() - Certificate verification flag
We maintain release notes on GitHub Releases:
https://github.com/eliezhao/icp-py-core/releases
See ROADMAP.md
β
Milestone 1: v3 endpoint migration & polling stability
β
Milestone 2: Certificate verification with blst
π Milestone 3: ICRC utilities, Candid enhancements, type reflection
- Current release: v1.0.0
Special thanks to the IC community and contributors to the original ic-py.
icp-py-core continues this legacy with modern Python standards and long-term maintenance.
