Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit 796fc67

Browse files
README: update for solana
GitOrigin-RevId: f6b852723f633f672ff09d11e91f5034942132cd
1 parent 4ae63a1 commit 796fc67

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ pip install kin-sdk-v2
1414
## Overview
1515
The SDK contains two main components: the `Client` and the `WebhookHandler`. The `Client` is used for blockchain
1616
actions, such as creating accounts sending payments, while the `WebhookHandler` is meant for developers who wish to make
17-
use of Agora Webhooks. For a high-level overview of how to integrate Kin and make use of Agora, please refer to the [website documentation](https://docs.kin.org).
17+
use of Agora Webhooks. It is recommended that developers read the [website documentation](https://docs.kin.org) prior to using this SDK.
18+
19+
1820

1921
## Client
2022
The main component of this library is the `Client` class, which facilitates access to the Kin blockchain.
@@ -36,10 +38,12 @@ client = Client(Environment.TEST, app_index=1)
3638
```
3739

3840
Additional options include:
39-
- `whitelist_key`: The private key of an account that will be used to co-sign all transactions.
41+
- `whitelist_key`: The private key of an account that will be used to co-sign all transactions. Should only be set for Kin 3.
4042
- `grpc_channel`: A specific `grpc.Channel` to use. Cannot be set if `endpoint` is set.
4143
- `endpoint`: A specific endpoint to use in the client. Cannot be set if `grpc_channel` is set.
4244
- `retry_config`: A custom `agora.client.RetryConfig` to configure how the client retries requests.
45+
- `kin_version`: The version of Kin to use. Defaults to 3.
46+
- `default_commitment`: (Kin 4 only) The commitment requirement to use by default for Kin 4 Agora requests. See the [website documentation](https://docs.kin.org/solana#commitment) for more information.
4347

4448
### Usage
4549
#### Create an Account
@@ -57,13 +61,21 @@ Next, submit it using `create_account`:
5761
client.create_account(private_key)
5862
```
5963

64+
In addition to the mandatory `private_key` parameter, `create_account` has the following optional parameters:
65+
- `commitment`: (Kin 4 only) Indicates to Solana which bank state to query. See the [website documentation](https://docs.kin.org/solana#commitment) for more details.
66+
- `subsidizer`: (Kin 4 only) The private key of an account to use as the funder of the transaction instead of the subsidizer configured on Agora.
67+
6068
#### Get a Transaction
61-
The `get_transaction` method gets transaction data by transaction hash.
69+
The `get_transaction` method gets transaction data by transaction id.
6270
```python
63-
tx_hash = b'txhash'
64-
transaction_data = client.get_transaction(tx_hash)
71+
# tx_id is either a 32-byte Stellar transaction hash or a 64-byte Solana transaction signature
72+
tx_id = b'<txid>'
73+
transaction_data = client.get_transaction(tx_id)
6574
```
6675

76+
In addition to the mandatory `tx_id` parameter, `get_transaction` has the following optional parameters:
77+
- `commitment`: (Kin 4 only) Indicates to Solana which bank state to query. See the [website documentation](https://docs.kin.org/solana#commitment) for more details.
78+
6779
#### Get an Account Balance
6880
The `get_balance` method gets the balance of the provided account, in [quarks](https://docs.kin.org/terms-and-concepts#quark).
6981
```python
@@ -75,6 +87,9 @@ public_key = PrivateKey.random().public_key
7587
balance = client.get_balance(public_key)
7688
```
7789

90+
In addition to the mandatory `public_key` parameter, `get_balance` has the following optional parameters:
91+
- `commitment`: (Kin 4 only) Indicates to Solana which bank state to query. See the [website documentation](https://docs.kin.org/solana#commitment) for more details.
92+
7893
#### Submit a Payment
7994
The `submit_payment` method submits the provided payment to Agora.
8095
```python
@@ -97,9 +112,15 @@ A `Payment` has the following required properties:
97112
- `quarks`: The amount of the payment, in [quarks](https://docs.kin.org/terms-and-concepts#quark).
98113

99114
Additionally, it has some optional properties:
100-
- `channel`: The private key of a [channel](https://docs.kin.org/how-it-works#channels) account to use as the source of the transaction. If unset, `sender` will be used as the transaction source.
115+
- `channel`: (Kin 2 and Kin 3 only) The private key of a [channel](https://docs.kin.org/how-it-works#channels) account to use as the source of the transaction. If unset, `sender` will be used as the transaction source.
101116
- `invoice`: An [Invoice](https://docs.kin.org/how-it-works#invoices) to associate with this payment. Cannot be set if `memo` is set.
102117
- `memo` A text memo to include in the transaction. Cannot be set if `invoice` is set.
118+
- `subsidizer`: (Kin 4 only) The private key of an account to use as the funder of the transaction instead of the subsidizer configured on Agora.
119+
120+
`submit_payment` also has the following optional properties:
121+
- `commitment`: (Kin 4 only) Indicates to Solana which bank state to query. See the [website documentation](https://docs.kin.org/solana#commitment) for more details.
122+
- `sender_resolution`: (Kin 4 only) Indicates which type of account resolution to use for the payment sender.
123+
- `dest_resolution`: (Kin 4 only) Indicates which type of account resolution to use for the payment destination.
103124

104125
#### Submit an Earn Batch
105126
The `submit_earn_batch` method submits a batch of earns to Agora from a single account. It batches the earns into fewer
@@ -132,8 +153,11 @@ A single `Earn` has the following properties:
132153
The `submit_earn_batch` method has the following parameters:
133154
- `sender`: The private key of the account from which the earns will be sent.
134155
- `earns`: The list of earns to send.
135-
- `channel`: (optional): The private key of a [channel](https://docs.kin.org/how-it-works#channels) account to use as the transaction source. If not set, `sender` will be used as the source.
156+
- `channel`: (optional, Kin 2 and Kin 3 only) The private key of a [channel](https://docs.kin.org/how-it-works#channels) account to use as the transaction source. If not set, `sender` will be used as the source.
136157
- `memo`: (optional) A text memo to include in the transaction. Cannot be used if the earns have invoices associated with them.
158+
- `commitment`: (Kin 4 only) Indicates to Solana which bank state to query. See the [website documentation](https://docs.kin.org/solana#commitment) for more details.
159+
- `sender_resolution`: (Kin 4 only) Indicates which type of account resolution to use for the payment sender.
160+
- `dest_resolution`: (Kin 4 only) Indicates which type of account resolution to use for the payment destination.
137161

138162
### Examples
139163
A few examples for creating an account and different ways of submitting payments and batched earns can be found in `examples/client`.
@@ -201,6 +225,8 @@ def events_endpoint_func(request):
201225
- `req_body`: The string request body.
202226

203227
#### Sign Transaction Webhook
228+
The sign transaction webhook is used to sign Kin 3 transactions with a whitelisted Kin 3 account to remove fees. On Kin 4, the webhook can be used to simply approve or reject transactions submitted by mobile clients.
229+
204230
To use the `WebhookHandler` with the Sign Transaction webhook, developers should define a function that accepts a sign transaction request and response object and verifies the request in some way and modifies the response object as needed:
205231
```python
206232
from agora.webhook.sign_transaction import SignTransactionRequest, SignTransactionResponse
@@ -218,7 +244,7 @@ from agora.webhook.sign_transaction import SignTransactionRequest, SignTransacti
218244
webhook_handler = WebhookHandler('mysecret')
219245

220246
def verify_request(req: SignTransactionRequest, resp: SignTransactionResponse) -> None:
221-
# verify the transaction inside `req`, and modify `resp` as needed.
247+
# verify the transaction inside `req`, and modify `resp` as needed (e.g. by calling `sign`).
222248
return
223249

224250
# This will vary depending on which framework is used.

0 commit comments

Comments
 (0)