CRUX Protocol

The CRUX Developer Hub

Welcome to the CRUX Developer Hub!

Learn more about CRUX, and about how to integrate CRUX Protocol into your Wallet.

Get Started    

Quickstart

1. Install SDK

CRUX supports the following platforms:

Upcoming:

  • Swift (Native iOS)

Instructions

Javascript platforms - 
Web, Electron

// Source code: [GitHub](https://github.com/cruxprotocol/js-sdk)
// Install via `npm`: `npm install @cruxpay/js-sdk`
// or include directly as a script - 
//`<script src="https://unpkg.com/@cruxpay/js-sdk/dist/cruxpay-sdk-dom.js"/>`


React Native - 

// Source code: [GitHub](https://github.com/cruxprotocol/rn-sdk)
// Install npm package `@cruxpay/rn-sdk`
// Add the JitPack repository to your build file in your root build.gradle at the end of repositories.
// Then add `com.github.cruxprotocol:android-sdk:v0.1` as dependency.

// NOTE: Check latest release version at `https://github.com/cruxprotocol/android-sdk/releases`


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

dependencies {
  implementation 'com.github.cruxprotocol:android-sdk:v0.1'
}

2. Initialize

To initialise the SDK you need a walletClientName.

You can get create and manage your walletClientName at CRUX Wallet Dashboard. Please feel free to contact us at [email protected] for any registration related queries.

import { CruxPay } from "@cruxpay/js-sdk";

let cruxClient = new CruxPay.CruxClient({
    walletClientName: 'testwallet',
    privateKey: "6bd397dc89272e71165a0e7d197b288ed5b1e44e1928c25455506f1968f" 
});

// Some operations require a privateKey to be injected - like registering a CRUX ID
import com.crux.sdk.CruxClient;
import com.crux.sdk.model.*;


CruxClientInitConfig.Builder configBuilder = new CruxClientInitConfig.Builder()
    .setWalletClientName("testwallet")
    .setPrivateKey("6bd397dc89272e71165a0e7d197b288ed5b1e44e1928c25455506f1968f");


CruxClient cruxClient = new CruxClient(configBuilder, androidContextObject);

Read more about Initialisation of SDK Client

3. Start Using!

// Resolve any existing CRUX ID for a currency
cruxClient.resolveCurrencyAddressForCruxID('[email protected]','btc').then((address) => {
    console.log(address);
})


// Create a new CRUX ID - [email protected]
cruxClient.registerCruxID('foo').then((result) => {
    console.log(result);
    // ID Will be owned by the injected private key
    // New IDs take 6-8 confirmations in the Bitcoin network to confirm.
})



// You can check the status of the ID by asking the SDK for the CruxID State
cruxClient.getCruxIDState().then((cruxIDState) => {
    console.log(cruxIDState);
})



// A registered ID allows you to associate cryptocurrency addresses
cruxClient.putAddressMap({
    'btc': {
        'addressHash':'1z2...42a'
    }, 
    'eth' {
        'addressHash':'0x12z2...2d'
    }
})
// Resolve any existing CRUX ID for a currency
cruxClient.resolveCurrencyAddressForCruxID( 
    "[email protected]", "xrp", 
    new CruxClientResponseHandler<CruxAddress>() {
        @Override
        public void onResponse(CruxAddress successResponse) {
            System.out.println(successResponse);
        }

        @Override
        public void onErrorResponse(CruxClientError failureResponse) {
            System.out.println(failureResponse);
        }
    }
);

// Create a new CRUX ID - [email protected]
cruxClient.registerCruxID("mynewid", 
    new CruxClientResponseHandler<Void>() {
        @Override
        public void onResponse(Void successResponse) {
            System.out.println(successResponse);
                // ID Will be owned by the injected private key
                // New IDs take 6-8 confirmations in the Bitcoin network to confirm.
        }

        @Override
        public void onErrorResponse(CruxClientError failureResponse) {
        }
    }
);
  
       


// You can check the status of the ID by asking the SDK for the CruxID State
cruxClient.getCruxIDState(
    new CruxClientResponseHandler<CruxIDState>() {
        @Override
        public void onResponse(CruxIDState successResponse) {
            System.out.println(successResponse);
        }

        @Override
        public void onErrorResponse(CruxClientError failureResponse) {
        }
    }
);



// A registered ID allows you to associate cryptocurrency addresses
private HashMap<String, CruxAddress> getCurrencyMap() {
    HashMap<String, CruxAddress> currencyMap = new HashMap<String, CruxAddress>();
    currencyMap.put("btc", new CruxAddress("1HX4KvtPdg9QUYwQE1kNqTAjmNaDG7w82V", null));
    currencyMap.put("eth", new CruxAddress("0x0a2311594059b468c9897338b027c8782398b481", null));
    currencyMap.put("tron", new CruxAddress("TG3iFaVvUs34SGpWq8RG9gnagDLTe1jdyz", null));
    currencyMap.put("xrp", new CruxAddress("rpfKAA2Ezqoq5wWo3XENdLYdZ8YGziz48h", "7777"));
    return currencyMap;
}

cruxClient.putAddressMap(getCurrencyMap(), 
    new CruxClientResponseHandler<CruxPutAddressMapSuccess>() {
        @Override
        public void onResponse(CruxPutAddressMapSuccess successResponse) {
            System.out.println(successResponse);
        }

        @Override
        public void onErrorResponse(CruxClientError failureResponse) {
        }
    }
);

Read more about SDK Integration Steps

Updated 7 months ago


What's Next

Detailed instructions on how to integrate CRUX into your SDK!

SDK Integration Steps

Quickstart


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.