Giter VIP home page Giter VIP logo

mx-sdk-erdkotlin's Introduction

Elrond Kotlin SDK

This is the kotlin implementation of Elrond SDK

This project was primarily designed for Android but is also compatible with any Kotlin-friendly app since it doesn't use the Android SDK

Usage

This SDK is built with the clean architecture principles.
Interaction are done through usecases

Here is an example for sending a transaction.

// Create a wallet from mnemonics
val wallet = Wallet.createFromMnemonic(..., 0)

// Get information related to this address (ie: balance and nonce)
val account = ErdSdk.getAccountUsecase().execute(Address.fromHex(wallet.publicKeyHex))

// Get the network informations
val networkConfig = ErdSdk.getNetworkConfigUsecase().execute()

// Create the transaction object
val transaction = Transaction(
    sender = account.address,
    receiver = Address.fromHex(...),
    value = 1000000000000000000.toBigInteger(), // 1 xEGLD
    data = "Elrond rocks !",
    chainID = networkConfig.chainID,
    gasPrice = networkConfig.minGasPrice,
    gasLimit = networkConfig.minGasLimit,
    nonce = account.nonce
)

// Send transaction.
// Signature is handled internally
val sentTransaction = ErdSdk.sendTransactionUsecase().execute(transaction, wallet)
Log.d("Transaction", "tx:${sentTransaction.txHash}")

In a real world example, the usescases would be injected
The sample application showcase how to do it on Android with Hilt framework (see the Sample App).

Usecases list

API
Usecase Endpoint
GetAccountUsecase GET address/:bech32Address
GetAddressBalanceUsecase GET address/:bech32Address/balance
GetAddressNonceUsecase GET address/:bech32Address/nonce
GetAddressTransactionsUsecase GET address/:bech32Address/transactions
GetTransactionInfoUsecase GET transaction/:txHash
GetTransactionStatusUsecase GET transaction/:txHash/status
SendTransactionUsecase POST transaction/send
EstimateCostOfTransactionUsecase POST transaction/cost
GetNetworkConfigUsecase GET network/config
QueryContractUsecase POST vm-values/query
QueryContractHexUsecase POST vm-values/hex
QueryContractStringUsecase POST vm-values/string
QueryContractIntUsecase POST vm-values/int

Contract

Usecase Description
CallContractUsecase Interact with a Smart Contract (execute function): equivalent to erdpy contract call
DNS
Usecase Description
RegisterDnsUsecase Send a register transaction to the appropriate DNS contract from given user and with given name: equivalent to erdpy dns register
GetDnsRegistrationCostUsecase Gets the registration cost from a DNS smart contract: equivalent to erdpy dns registration-cost
CheckUsernameUsecase Can be useful for validating a text field before calling RegisterDnsUsecase

Configuration

// default value is ProviderUrl.DevNet
ErdSdk.setNetwork(ProviderUrl.MainNet)

// configure the OkHttpClient
ErdSdk.elrondHttpClientBuilder.apply {
    addInterceptor(HttpLoggingInterceptor())
}

Build

The SDK is not yet uploaded to a maven repository
You can build the jar from the sources by running mvn package

Sample App

For a complete example you can checkout this sample application

mx-sdk-erdkotlin's People

Contributors

alexandre-saddour avatar bogdan-rosianu avatar iulianpascalau avatar

Stargazers

Nicholas Reich avatar Florin Tiron avatar  avatar  avatar Andrei Băncioiu avatar Dragos Dit avatar Cioclea Doru Octavian avatar  avatar

Watchers

Felix avatar Robert Sasu avatar James Cloos avatar  avatar Claudiu-Marcel Bruda avatar Alin Cruceat avatar Traian Anghel avatar Andrei Băncioiu avatar Lucas Willems avatar Laurentiu Ciobanu avatar Beniamin Cosma avatar Tudor Morar avatar Dan Popa avatar Ciprian Draghici avatar Claudiu Lataretu avatar Dragos Dit avatar Radu Chis avatar Cristi Corcoveanu avatar  avatar Darius Peteleaza avatar Valentin Lup avatar  avatar Mircea Gherman avatar Joseph Tamas avatar Berciu Liviu avatar  avatar Gabriel Matei avatar  avatar

mx-sdk-erdkotlin's Issues

Support for abi deserialisation

As of now the erdjs libarary offers the possibility to use the abi json file as a way to serialise/deserialise the data to/from the blockchain. Sadly there is no such library open sourced that works for every abi format and for custom specific classes that the libraries offer ( e.g. Address). In terms of creating a unified ecosystem to display data from both web and mobile, an abi decoder that reproduces the outcome of the one used in erdjs is required.

Intent to Maiar app for login and signing transaction

The library the way it is now can only create a Wallet instance based on the given mnemonics and sign transactions and so on. As a developer I want to offer the users the possibility to login with the library using the maiar app.
Basically the sdk needs to write intents for the Maiar app to authenticate and later sign transactions, and the maiar app has to have defined in the such use cases used by the erdkotlin sdk.

Ledger support?

This lib doesn't support a hardware ledger like the js version, right?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.