Ethereum Web3 implementation for mobile (android & ios) Kotlin Multiplatform development

Overview

GitHub license Download kotlin-version

Mobile Kotlin web3

This is a Kotlin MultiPlatform library that ...

Table of Contents

Features

...

Requirements

  • Gradle version 6.8+
  • Android API 16+
  • iOS version 11.0+

Versions

  • kotlin 1.5.20
    • 0.1.0
    • 0.2.0

Installation

root build.gradle

allprojects {
    repositories {
        mavenCentral()
    }
}

project build.gradle

dependencies {
    commonMainApi("dev.icerock.moko:web3:0.2.0")
}

Usage

...

Samples

More examples can be found in the sample directory.

Set Up Locally

Contributing

All development (both new features and bug fixes) is performed in develop branch. This way master sources always contain sources of the most recently released version. Please send PRs with bug fixes to develop branch. Fixes to documentation in markdown files are an exception to this rule. They are updated directly in master.

The develop branch is pushed to master during release.

More detailed guide for contributers see in contributing guide.

License

Copyright 2021 IceRock MAG Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Add transform argument for Web3RpcRequest

    Add transform argument for Web3RpcRequest

    Web3RpcRequest(
        method = "eth_sendRawTransaction",
        params = listOf(signedTransaction),
        paramsSerializer = String.serializer(),
        resultSerializer = String.serializer(),
        transform = ::TransactionHash
    )
    

    @Alex009, what do you think about such a thing?

    It's useful for cases when we want to wrap request result in typed stuff like on screenshot below: image

    Now that works fine and I can add a request to the separate entity, but when I try to use it with a batch request, it becomes kinda verbose because I have a String output, but not a TokenCryptoCurrency? one.

    enhancement 
    opened by y9san9 2
  • Refactor types for HEX

    Refactor types for HEX

    We should introduce convenient types for HEX strings:

    • hex string interface with 3 members HexString#withoutPrefix, HexString#prefixed, HexString#bigInt.
    • value class for any valid hex string. checks if the string matches format.
    • value class HexN(size: Int) for sized hexes (N - bytes count), delegates hex string interface with value class and additionally check the size
    • shortcuts such as Hex32, Hex16, etc. for use in library.

    And make ContractAddress (and similar classes) also delegate hex string interface with Hex20 class.

    enhancement 
    opened by y9san9 1
  • Add shortcuts for Web3Serializer

    Add shortcuts for Web3Serializer

    abstract class Web3Deserializer : DeserializationStrategy {
        override fun descriptor = /* STRING */
        override fun decode(decoder) {
            val string = decoder.decodeString()
            return decode(string.chunked(size = PART_SIZE * 2).map { it.hexStringToByteArray() })
        }
        abstract fun decode(chunks: List<ByteArray>)
    }
    

    And other help classes for SerializationStrategy and KSerializer (composition of this twos), so I won't write boilerplate with chunked and converting to hex

    enhancement 
    opened by y9san9 1
  • Remove infura dependence

    Remove infura dependence

    Since Infura is just a realization of web3 protocol, all names related to infura should be changed to names related to web3 (e.g. infuraUrl => web3Url). Pros: It is open source project and we won't push users to use infura. Cons: Migration, but it shouldn't cause a lot of problems since there is only one tech-preview project use this library.

    enhancement 
    opened by y9san9 1
  • Invalid HexString.fillToSizedHex behaviour

    Invalid HexString.fillToSizedHex behaviour

    append here references to the StringBuilder but not the the String

    https://github.com/icerockdev/moko-web3/blob/38b427785bce2a23211039ad51d31d553a7deab1/web3/src/commonMain/kotlin/dev.icerock.moko.web3/hex/internal/hexFormatUtil.kt#L7-L22

    opened by y9san9 0
  • iosSimulatorArm64 support

    iosSimulatorArm64 support

    So I already implemented this on my fork by creating a separate branch: ionspinbignum

    It is using ionspin's bignum library which supports arm64 targets already instead of soywiz's kbignum as the big number library. kbignum would need to put a new release out to support arm64.

    In addition, to me, it seems like ionspin's library is more actively maintained and has more features. Would switching to using ionspin's big number library be a possibility to support arm64 targets?

    opened by luca992 1
  • Transaction signing

    Transaction signing

    I know it was mentioned that transaction signing would be supported soon in #5. But, I see there's no issue created for it, so I'm just making one here. I'm just wondering is the eta is still for this month? Also, if any help is needed I'd be to contribute, lmk!

    opened by luca992 6
  • Documentation or example of calling a Contract method?

    Documentation or example of calling a Contract method?

    I'm trying to simply get the name of a ERC721 contract.

        val apiKey = "..."
        val web3: Web3 = Web3("https://mainnet.infura.io/v3/$apiKey")
        val smartContractString = "..."
        val smartContractJson = Json.parseToJsonElement(smartContractString).jsonObject
        val networkData : JsonObject = smartContractJson["networks"]!!.jsonObject[networkId]?.jsonObject!!
        val adr  = networkData["address"]?.jsonPrimitive?.content!!
        val abis = smartContractJson["abi"]!!.jsonArray
    
        val sc = SmartContract(web3, ContractAddress(adr), abis))
        
        val names = sc.read("name", emptyList())
                { l ->
                    l.map {
                        it.toString()
                    }
                }
        val contractName = names[0]
            
    

    First of all I'm not really sure what a valid mapper would look like? Or why it would return multiple values from one read. Do you have any examples? And second, names ends up being empty, so nothing is being returned? Any help on the correct way to call a contract method would be appreciated.

    documentation 
    opened by luca992 14
  • Implement all serializers for soliditylang

    Implement all serializers for soliditylang

    This is a meta issue

    https://docs.soliditylang.org/en/v0.5.3/abi-spec.html#argument-encoding

    Children:

    • Static Types
      • [x] uint256
      • [x] address
      • [x] uint8
      • [x] #96
      • [ ] todo // add all not implemented types here
    • Dynamic Types
      • [x] #21
      • [x] #74
      • [x] #85
      • [x] #86
      • [ ] Array serializer with fixed amount of elements T[k]
    enhancement help wanted 
    opened by y9san9 0
  • Implement gradle plugin for generation classes from ABI of smart contracts

    Implement gradle plugin for generation classes from ABI of smart contracts

    now we check at runtime that smart contract call is valid for ABI. but will be better if we will generate all necessary functions from ABI - it will give to us strong types and less errors like "invalid type" or "not all arguments passed".

    for generation we can use https://github.com/square/kotlinpoet for storage of ABI files we can use https://github.com/icerockdev/moko-resources

    enhancement 
    opened by Alex009 0
Releases(release/0.18.0)
Owner
IceRock Development
Kotlin Multiplatform developers team
IceRock Development
An app architecture for Kotlin/Native on Android/iOS. Use Kotlin Multiplatform Mobile.

An app architecture for Kotlin/Native on Android/iOS. Use Kotlin Multiplatform Mobile. 项目架构主要分为原生系统层、Android/iOS业务SDK层、KMM SDK层、KMM业务逻辑SDK层、iOS sdkfra

libill 4 Nov 20, 2022
Location Service Manager for Kotlin Multiplatform Mobile iOS and android

Location Service Manager for Kotlin Multiplatform Mobile iOS and android Features Provides simple permission settings Dramatically reduce the amount o

LINE 55 Dec 10, 2022
Kotlin Multiplatform Mobile demo for Android and iOS - app for viewing Cat pictures

CatViewerDemo Android demo iOS demo Kotlin Multiplatform Mobile demo for Android and iOS. App for viewing Cat pictures from Cats API. This sample show

Martin Rajniak 111 Dec 18, 2022
A local storage management library for Kotlin Multiplatform Mobile iOS and android

A local storage management library for Kotlin Multiplatform Mobile iOS and android Features iOS and Android local storage in one interface Provides ge

LINE 20 Oct 30, 2022
🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture

GithubSearchKMM Github Repos Search - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Depend

Petrus Nguyễn Thái Học 50 Jan 7, 2023
Opinionated Redux-like implementation backed by Kotlin Coroutines and Kotlin Multiplatform Mobile

CoRed CoRed is Redux-like implementation that maintains the benefits of Redux's core idea without the boilerplate. No more action types, action creato

Kittinun Vantasin 28 Dec 10, 2022
Kotlin Multiplatform Mobile + Mobile Declarative UI Framework (Jetpack Compose and SwiftUI)

Kotlin Multiplatform Mobile + Mobile Declarative UI Framework (Jetpack Compose and SwiftUI)

Kotchaphan Muangsan 3 Nov 15, 2022
KMM RSS Reader: an open-source, mobile, cross-platform application built with Kotlin Multiplatform Mobile.

KMM RSS Reader This is an open-source, mobile, cross-platform application built with Kotlin Multiplatform Mobile. It's a simple RSS reader, and you ca

Kotlin 1.4k Jan 4, 2023
Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in Kotlin with Jetpack Compose and a backed in Kotlin hosted on AppEngine.

Conferences4Hall Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in K

Gérard Paligot 98 Dec 15, 2022
Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.

Codename One - Cross Platform Native Apps with Java or Kotlin Codename One is a mobile first cross platform environment for Java and Kotlin developers

Codename One 1.4k Jan 9, 2023
A Bluetooth kotlin multiplatform "Cross-Platform" library for iOS and Android

Blue-Falcon A Bluetooth "Cross Platform" Kotlin Multiplatform library for iOS, Android, MacOS, Raspberry Pi and Javascript. Bluetooth in general has t

Andrew Reed 220 Dec 28, 2022
Dependency Injection library for Kotlin Multiplatform, support iOS and Android

Multiplatform-DI library for Kotlin Multiplatform Lightweight dependency injection framework for Kotlin Multiplatform application Dependency injection

Anna Zharkova 32 Nov 10, 2022
Simple Kotlin Multiplatform PrayerTimes App for iOS and Android

Kotlin Multiplatform ___ _______ ___ / _ \_______ ___ _____ ___/_ __(_)_ _ ___ ___ / _ | __

Ahmed El-Helw 26 Nov 9, 2022
Kotlin Multiplatform Sample - Android, iOS, Web, Desktop

KMP-Sample Kotlin Multiplatform Sample Android iOS Web (Compose for web) Desktop (Compose for desktop) ?? Structure Diagram ?? Build At least android

안홍범 14 Dec 13, 2022
A Kotlin Multiplatform Project using TMDB Api. Currently supports Android,iOS,Desktop and web platforms

A Kotlin Multiplatform Project using TMDB Api(https://www.themoviedb.org/). Currently this project is implemented in following platforms Andr

Jackson E J 11 Nov 10, 2022
BlurHash support for iOS, Android and JVM via Kotlin Multiplatform

blurhash A Kotlin Multiplatform library to use blurhash in your Android App, iOS / Mac App & JVM Backend. Android iOS JVM Why? If you've tried using b

Niklas Baudy 19 Nov 17, 2022
A Gradle plugin for Kotlin Multiplatform projects that generate a XCFramework for Apple targets or a FatFramework for iOS targets, and manages the publishing process in a CocoaPod Repository.

KMP Framework Bundler KMP Framework Bundler is a Gradle plugin for Kotlin Multiplatform projects that generate a XCFramework for Apple targets or a Fa

Marco Gomiero 17 Oct 29, 2022
A powerful tool (iOS & Android) that focuses on mobile operation behavior!

DiDiPrism,中文名:小桔棱镜,是一款专注于移动端操作行为的工具,涵盖APP操作回放、操作检测、以及数据可视化能力。我们在整个方案的实现过程中沉淀出了一套技术框架,希望可以逐步开源出来帮助更多人,同时也希望棱镜在大家的合力下能够更快的成长。 它有哪些亮点? 零入侵 业务代码无需任何适配。 高可

DiDi 1.6k Dec 22, 2022
Runtime Mobile Security (RMS) 📱🔥 - is a powerful web interface that helps you to manipulate Android and iOS Apps at Runtime

Runtime Mobile Security (RMS) ?? ?? by @mobilesecurity_ Runtime Mobile Security (RMS), powered by FRIDA, is a powerful web interface that helps you to

Mobile Security 2k Dec 20, 2022