# Kiln Connect SDK
## Overview
Welcome to the Python Kiln Connect SDK which provides facilities
around Staking using the Kiln API. It is composed of three parts:
- [API layer](https://github.com/kilnfi/sdk-py/tree/main/kiln_connect/openapi_client) which facilities usage of the Kiln API,
- [Integration layer](https://github.com/kilnfi/sdk-py/tree/main/kiln_connect/) which provides facilities around the Kiln API,
- [CLI](https://github.com/kilnfi/sdk-py/tree/main/kiln_cli/) which showcases the two previous parts.
The SDK is typically used as follows: a `KilnConnect` instance is
created from a `KilnConfig`, the SDK then provides access to different
parts:
- `accounts` for Kiln Accounts facilities
- `eth` for Ethereum facilities
- `xtz` for Tezos facilities
Optionally, the SDK can be configured with multiple integrations
(similar to the concept of modules), which can be referred later via
their name.
For example, here we create a `KilnConnect` object from a config
initialized from the environment. This config has a Fireblocks
integration called `fireblocks` (configured with a specific vault
account and API key), we then stake on Ethereum using the fireblocks
integration.
```python
import kiln_connect
config = kiln_connect.KilnConfig.from_env()
kc = kiln_connect.KilnConnect(config)
kc.eth.stake(integration='fireblocks', account_id='...', wallet='...', amount_wei=32000000000000000000)
```
The following integrations are currently supported:
- [Fireblocks](https://github.com/kilnfi/sdk-py/tree/main/docs/README.md#fireblocks)
## Configuration
There are two ways to configure the SDK, either manually by creating a
`KilnConfig` object or by using the environment. For simplicity, we
recommend using the environment to start with, and then switch to
`KilnConfig` as your usage becomes more specific.
### Via Environment
Kiln Connect can be configured from the environment by using the
helper `KilnConfig.from_env()`, as follows:
```python
import kiln_connect
def example():
with kiln_connect.KilnConnect(kiln_connect.KilnConfig.from_env()) as kc:
pass
```
This helper builds a `KilnConfig` by looking at the following
environment variables:
| Variable Name | Description | Example | Misc |
|-------------------------------|---------------------------------------------|----------------------------------------|----------|
| `KILN_ENV` | Environment to use | `devnet`, `testnet`, `mainnet` | Required |
| `KILN_API_URL` | Kiln Endpoint to target | `https://api.testnet.kiln.fi` | Required |
| `KILN_API_TOKEN` | Kiln API token | `kiln_...` | Required |
| `FIREBLOCKS_API_KEY` | API key for Fireblocks Integration | `123e4567-e89b-12d3-a456-426614174000` | Optional |
| `FIREBLOCKS_RAW_KEY_PATH` | Path to PEM key for Fireblocks Integration | `~/.fireblocks.pem` | Optional |
| `FIREBLOCKS_VAULT_ACCOUNT_ID` | Vault Account ID for Fireblocks Integration | `7` | Optional |
### Via KilnConfig
The `KilnConfig` required to initialize the API is defined
as follows:
```python
class KilnConfig:
"""Configuration of the Kiln Connect SDK.
"""
kiln_base_url: str # https://api.testnet.kiln.fi/
kiln_api_token: str # kiln_...
integrations: list[IntegrationConfig] # optional list of integration configs
class IntegrationConfig:
"""Configuration of a Kiln integration.
"""
name: str # user-defined name of the integration (i.e: "")
provider: str # type of the integration (i.e: "fireblocks")
parameters: dict # python dict
```
For example:
```python
import kiln_connect
config = kiln_connect.KilnConfig(
kiln_base_url='https://api.testnet.kiln.fi',
kiln_api_token='kiln_...',
integrations=[
# Fireblocks Integration to stake on ETH_TEST3 (goerli)
# from vault account 7 using raw key present in file
# ~/.fireblocks.pem.
kiln_connect.IntegrationConfig(
name='fireblocks-testnet',
provider='fireblocks',
parameters={
'api_token': '...',
'raw_key_path': '~/.fireblocks.pem',
'vault_account_id': 7,
'assets': {
'eth': 'ETH_TEST3',
}
}
)
]
)
```
#### Fireblocks
Here is the expected configuration for the optional Fireblocks
integration:
```python
{
'api_token': '<Fireblocks API token>',
'raw_key_path': '<Fireblocks raw key path>',
'vault_account_id': <Fireblocks Vault Account ID>,
'assets': {
'eth': 'ETH_TEST3',
},
}
```
Where assets is a dictionnary used to know which asset to use whenever
staking on a given protocol. The following protocols are supported:
- `eth` (available via `KilnConnect.eth.stake`)
## Usage
The simplest way to start using the SDK is to look at examples
implemented in the [CLI](https://github.com/kilnfi/sdk-py/tree/main/kiln_cli/); it is kept simple to showcase the SDK.
API facilities:
- [Accounts](https://github.com/kilnfi/sdk-py/tree/main/docs/AccountsApi.md)
- [Ethereum](https://github.com/kilnfi/sdk-py/tree/main/docs/EthApi.md)
- [Solana](https://github.com/kilnfi/sdk-py/tree/main/docs/SolApi.md)
- [Tezos](https://github.com/kilnfi/sdk-py/tree/main/docs/XtzApi.md)
Integrations facilities:
- [Fireblocks](https://github.com/kilnfi/sdk-py/tree/main/docs/README.md#fireblocks)
Raw data
{
"_id": null,
"home_page": "https://kiln.fi/",
"name": "kiln-connect",
"maintainer": "s. rannou",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "mxs@sbrk.org",
"keywords": "staking,blockchain",
"author": "s. rannou",
"author_email": "mxs@sbrk.org",
"download_url": "https://files.pythonhosted.org/packages/76/20/cec533d0dcc1e6535d2f7ccdf11d8f7a8c8e39b757c56575c87d00d61d8e/kiln_connect-1.0.0.dev8.tar.gz",
"platform": null,
"description": "# Kiln Connect SDK\n\n## Overview\n\nWelcome to the Python Kiln Connect SDK which provides facilities\naround Staking using the Kiln API. It is composed of three parts:\n\n- [API layer](https://github.com/kilnfi/sdk-py/tree/main/kiln_connect/openapi_client) which facilities usage of the Kiln API,\n- [Integration layer](https://github.com/kilnfi/sdk-py/tree/main/kiln_connect/) which provides facilities around the Kiln API,\n- [CLI](https://github.com/kilnfi/sdk-py/tree/main/kiln_cli/) which showcases the two previous parts.\n\nThe SDK is typically used as follows: a `KilnConnect` instance is\ncreated from a `KilnConfig`, the SDK then provides access to different\nparts:\n\n- `accounts` for Kiln Accounts facilities\n- `eth` for Ethereum facilities\n- `xtz` for Tezos facilities\n\nOptionally, the SDK can be configured with multiple integrations\n(similar to the concept of modules), which can be referred later via\ntheir name.\n\nFor example, here we create a `KilnConnect` object from a config\ninitialized from the environment. This config has a Fireblocks\nintegration called `fireblocks` (configured with a specific vault\naccount and API key), we then stake on Ethereum using the fireblocks\nintegration.\n\n```python\nimport kiln_connect\n\nconfig = kiln_connect.KilnConfig.from_env()\nkc = kiln_connect.KilnConnect(config)\n\nkc.eth.stake(integration='fireblocks', account_id='...', wallet='...', amount_wei=32000000000000000000)\n```\n\nThe following integrations are currently supported:\n\n- [Fireblocks](https://github.com/kilnfi/sdk-py/tree/main/docs/README.md#fireblocks)\n\n## Configuration\n\nThere are two ways to configure the SDK, either manually by creating a\n`KilnConfig` object or by using the environment. For simplicity, we\nrecommend using the environment to start with, and then switch to\n`KilnConfig` as your usage becomes more specific.\n\n### Via Environment\n\nKiln Connect can be configured from the environment by using the\nhelper `KilnConfig.from_env()`, as follows:\n\n```python\nimport kiln_connect\n\ndef example():\n with kiln_connect.KilnConnect(kiln_connect.KilnConfig.from_env()) as kc:\n pass\n```\n\nThis helper builds a `KilnConfig` by looking at the following\nenvironment variables:\n\n| Variable Name | Description | Example | Misc |\n|-------------------------------|---------------------------------------------|----------------------------------------|----------|\n| `KILN_ENV` | Environment to use | `devnet`, `testnet`, `mainnet` | Required |\n| `KILN_API_URL` | Kiln Endpoint to target | `https://api.testnet.kiln.fi` | Required |\n| `KILN_API_TOKEN` | Kiln API token | `kiln_...` | Required |\n| `FIREBLOCKS_API_KEY` | API key for Fireblocks Integration | `123e4567-e89b-12d3-a456-426614174000` | Optional |\n| `FIREBLOCKS_RAW_KEY_PATH` | Path to PEM key for Fireblocks Integration | `~/.fireblocks.pem` | Optional |\n| `FIREBLOCKS_VAULT_ACCOUNT_ID` | Vault Account ID for Fireblocks Integration | `7` | Optional |\n\n### Via KilnConfig\n\nThe `KilnConfig` required to initialize the API is defined\nas follows:\n\n```python\nclass KilnConfig:\n \"\"\"Configuration of the Kiln Connect SDK.\n \"\"\"\n kiln_base_url: str # https://api.testnet.kiln.fi/\n kiln_api_token: str # kiln_...\n integrations: list[IntegrationConfig] # optional list of integration configs\n\nclass IntegrationConfig:\n \"\"\"Configuration of a Kiln integration.\n \"\"\"\n name: str # user-defined name of the integration (i.e: \"\")\n provider: str # type of the integration (i.e: \"fireblocks\")\n parameters: dict # python dict\n```\n\nFor example:\n\n```python\nimport kiln_connect\n\nconfig = kiln_connect.KilnConfig(\n kiln_base_url='https://api.testnet.kiln.fi',\n kiln_api_token='kiln_...',\n\n integrations=[\n # Fireblocks Integration to stake on ETH_TEST3 (goerli)\n # from vault account 7 using raw key present in file\n # ~/.fireblocks.pem.\n kiln_connect.IntegrationConfig(\n name='fireblocks-testnet',\n provider='fireblocks',\n parameters={\n 'api_token': '...',\n 'raw_key_path': '~/.fireblocks.pem',\n 'vault_account_id': 7,\n 'assets': {\n 'eth': 'ETH_TEST3',\n }\n }\n )\n ]\n)\n```\n\n#### Fireblocks\n\nHere is the expected configuration for the optional Fireblocks\nintegration:\n\n```python\n{\n 'api_token': '<Fireblocks API token>',\n 'raw_key_path': '<Fireblocks raw key path>',\n 'vault_account_id': <Fireblocks Vault Account ID>,\n 'assets': {\n 'eth': 'ETH_TEST3',\n },\n}\n```\n\nWhere assets is a dictionnary used to know which asset to use whenever\nstaking on a given protocol. The following protocols are supported:\n\n- `eth` (available via `KilnConnect.eth.stake`)\n\n## Usage\n\nThe simplest way to start using the SDK is to look at examples\nimplemented in the [CLI](https://github.com/kilnfi/sdk-py/tree/main/kiln_cli/); it is kept simple to showcase the SDK.\n\nAPI facilities:\n\n- [Accounts](https://github.com/kilnfi/sdk-py/tree/main/docs/AccountsApi.md)\n- [Ethereum](https://github.com/kilnfi/sdk-py/tree/main/docs/EthApi.md)\n- [Solana](https://github.com/kilnfi/sdk-py/tree/main/docs/SolApi.md)\n- [Tezos](https://github.com/kilnfi/sdk-py/tree/main/docs/XtzApi.md)\n\nIntegrations facilities:\n\n- [Fireblocks](https://github.com/kilnfi/sdk-py/tree/main/docs/README.md#fireblocks)\n",
"bugtrack_url": null,
"license": "",
"summary": "",
"version": "1.0.0.dev8",
"project_urls": {
"Homepage": "https://kiln.fi/",
"Repository": "https://github.com/kilnfi/sdk-py"
},
"split_keywords": [
"staking",
"blockchain"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3133cdd259a63b2356f36359eef3231f4c38e7ea69cae425e8d2e4dc6fa053ac",
"md5": "d53811bd2f91091a6a93828fe8e625e4",
"sha256": "ed7a12b17dddbc3c6fc2852f2d821467559558cd42c0483a7ca6ceab554c8309"
},
"downloads": -1,
"filename": "kiln_connect-1.0.0.dev8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d53811bd2f91091a6a93828fe8e625e4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 1312354,
"upload_time": "2023-07-04T14:40:03",
"upload_time_iso_8601": "2023-07-04T14:40:03.951946Z",
"url": "https://files.pythonhosted.org/packages/31/33/cdd259a63b2356f36359eef3231f4c38e7ea69cae425e8d2e4dc6fa053ac/kiln_connect-1.0.0.dev8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7620cec533d0dcc1e6535d2f7ccdf11d8f7a8c8e39b757c56575c87d00d61d8e",
"md5": "fbe68dd2f4f91c7a2d31395100c2e0ac",
"sha256": "cf2cc920a2c433b84fa863ba78bf744c759303fbd59ed8dded8be9f9a8432863"
},
"downloads": -1,
"filename": "kiln_connect-1.0.0.dev8.tar.gz",
"has_sig": false,
"md5_digest": "fbe68dd2f4f91c7a2d31395100c2e0ac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 207049,
"upload_time": "2023-07-04T14:40:07",
"upload_time_iso_8601": "2023-07-04T14:40:07.330745Z",
"url": "https://files.pythonhosted.org/packages/76/20/cec533d0dcc1e6535d2f7ccdf11d8f7a8c8e39b757c56575c87d00d61d8e/kiln_connect-1.0.0.dev8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-04 14:40:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kilnfi",
"github_project": "sdk-py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "kiln-connect"
}