CruxPay is a protocol which aims to link any blockchain address to a human-readable name, and let users interact with each other and dApps with ease.
First you need to get cruxpay sdk into your project. This can be done using the following methods:
npm install @cruxpay/js-sdk
To initialize the sdk, you need to minimally pass a javascript object with following details:-
cruxdev
as the value which is already configured for our dev test users. It has 5 pre-registered crypto symbols for a fast start. You can contact us at telegram channel for registration of your own walletClientName.m/889'/0'/0'
) for CruxPay keypair node derivation with respect to account indices.**Note:** Cruxprotocol JS SDK is case insensetive for cryptocurrency symbols and will always output lowercase symbols.
Example below shows how to a cruxClient instance. These are the SDK Operation exposed.
let cruxClientOptions = {
walletClientName: 'cruxdev',
privateKey: "6bd397dc89272e71165a0e7d197b280c7a88ed5b1e44e1928c25455506f1968f" // (optional parameter)
}
let cruxClient = new CruxClient(cruxClientOptions);
That's it! now you can use the cruxClient object to perform operations defined in SDK Operation.
cruxClient.getCruxIDState().then((cruxIDState) => {
console.log(cruxIDState);
})
Wallet clients are encouraged to surface the respective ERROR_CODE
of the CruxClientError
to their Users with any custom error messages. This will help in debugging any issues with the functionality.
Refer error-handling.md for more information on Error handling.
Description: Reserves/registers the cruxID for the user. The user can link any blockchain address to his CruxID immediately after registration using putAddressMap.
Params:
Returns: Promise resolving on successful call to the registrar.
const sampleAddressMap: IAddressMapping = {
'BTC': {
addressHash: '1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX'
},
'ETH': {
addressHash: '0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8'
},
}
// Advised to pipe the method putAddressMap to registerCruxID call
await cruxClient.registerCruxID("bob")
.then(() => {
return cruxClient.putAddressMap(sampleAddressMap)
.catch((addressUpdationError) => {
// Handling addressUpdation error
})
})
.catch((registrationError) => {
// Handling registration error
})
getAssetMap()
.npm run-script build
Build the cruxpay-sdk.js package and put all the browser build files into the dist
folder.
npm run-script test
npm run-script wallet_demo
Running the above command will build a demo page, here you can play around with all method that are exposed by the sdk.
Find references to all available methods at https://cruxprotocol.github.io/js-sdk.
See CONTRIBUTING.md file.
Generated using TypeDoc