Skip to content
No description, website, or topics provided.
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
gradle/wrapper
scatterandroid
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Scatter Android

ScatterAndroid simulates Scatter plugin for EOS blockchain in WebView, and allows client apps to:

  • Retrieve account
  • Sign transactions
  • Sign arbitrary messages

Installation

Step 1: Add library

You can download a jar from GitHub's releases page.

Or use Gradle:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    implementation 'com.github.paytomat:ScatterAndroid:2.0.0'
}

Step 2: Configure

Create ScatterClientobject, which implements actions, which you wish to handle:

private ScatterClient scatterClient = new ScatterClient() {
        @Override
        public void getAccount(AccountReceived onAccountReceived) {
            /*some code*/
        }

         /*other actions*/
    };

Create Scatter object, where webView - is your WebView:

Scatter scatterImplementation = new ScatterFactory().getScatter(webView, scatterClient, true);

Third boolean parameter indicate which Scatter implementation you would like to use: false (recommended) for socket implementation, true for js implementation.

Don`t forget to enable Javascript:

webView.getSettings().setJavaScriptEnabled(true);

Clean all after your activity/fragment destroys:

scatterImplementation.onDestroy();

Usage examples

Send EOS account to Scatter

        @Override
        public void getAccount(AccountReceived onAccountReceived) {
            onAccountReceived.onAccountReceivedSuccessCallback(accountName);
        }

Sign arbitrary message

        @Override
        public void completeMsgTransaction(MsgTransactionRequestParams params, MsgTransactionCompleted onMsgTransactionCompleted) {
            //generate signature
            Signature signature = signTransactionRaw(Hex.decode(params.getData()), privateKey).getSignature();
            onMsgTransactionCompleted.onMsgTransactionCompletedSuccessCallback(signature.toString());
        }

Sign transaction

        @Override
        public void completeTransaction(TransactionRequestParams transactionRequestParams, TransactionCompleted onTransactionCompleted) {
            //try to make transaction
            Transaction transaction = makeTransaction(transactionRequestParams, privateKey);
            String[] signatures = transaction.getSignatures();
            onTransactionCompleted.onTransactionCompletedSuccessCallback(signatures);
        }

Send errors to Scatter

onTransactionCompleted.onTransactionCompletedErrorCallback(new ResponseCodeInfo(ResponseType.UNKNOWN_ERROR, ResponseCode.UNKNOWN_ERROR), "Error");
You can’t perform that action at this time.