Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Reedyuk/jsonrpc-kotlin-client
https://github.com/Reedyuk/jsonrpc-kotlin-client
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Reedyuk/jsonrpc-kotlin-client
- Owner: Reedyuk
- License: gpl-3.0
- Created: 2021-08-03T18:42:15.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-05-30T18:50:45.000Z (over 1 year ago)
- Last Synced: 2024-08-02T09:26:26.296Z (6 months ago)
- Language: Kotlin
- Size: 210 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-kotlin-multiplatform - apollo - JSON-RPC Kotlin Multiplatform client. (Libraries / Network)
README
# JSON-RPC Kotlin Client
[![Kotlin](https://img.shields.io/badge/kotlin-1.8.20-blue.svg)](http://kotlinlang.org)
![badge][badge-android]
![badge][badge-native]
![badge][badge-js]A Kotlin Multiplatform Library for performing JSON-RPC 2.0 commands.
Taken inspiration from [SwiftJSONRPC](https://github.com/kolyasev/SwiftJSONRPC)
## Running
The library works on the following platforms: `Android`, `iOS`, `JavaScript`.## Usage
Create client object with base url:```kotlin
val client = RPCClient(clientUrl)
```Create a subclass of the RPCService object
```kotlin
val service = object : RPCService(client) {
suspend fun sha(): String {
val sha = invoke("web3_sha3", arrayOf("0x68656c6c6f20776f726c64"))
return sha.content
}
}
```Invoke the service function call to get the result.
```kotlin
val shaResult = service.sha()
```I would recommend you look at the unit tests to get a better idea. I will be working on another library which uses this library, so will link back to here for more inspiration.
[badge-android]: http://img.shields.io/badge/platform-android-brightgreen.svg?style=flat
[badge-native]: http://img.shields.io/badge/platform-native-lightgrey.svg?style=flat
[badge-js]: http://img.shields.io/badge/platform-js-yellow.svg?style=flat