Device & Accounts Info.
Get Device Info
You can get connected device information using getDeviceInfo()
function.
// Get connected device information
var result
try{
result = await DcentWebConnector.getDeviceInfo()
}catch(e){
result = e
}
getDeviceInfo()
returns :
{
"header": {
"version": "1.0",
"response_from": "device",
"status": "success"
},
"body": {
"command": "get_info",
"parameter": {
"device_id": "1234567890123456789012345678901234567890123456789012345678901234",
"fw_version": "1.2.1.7c65",
"ksm_version": "1.0.0.1139",
"state": "secure",
"coin_list": [
{
"name": "BITCOIN"
},
{
"name": "ETHEREUM"
},
{
"name": "ERC20"
},
{
"name": "RSK"
},
{
"name": "RRC20"
},
{
"name": "RIPPLE"
},
{
"name": "MONACOIN"
},
{
"name": "EOS"
},
{
"name": "KLAYTN"
}
],
"fingerprint": {
"max": 2,
"enrolled": 1
},
"label": "My D'CENT"
}
}
}
deviceId : device unique identifier
label : label of the device
fw_Version : firmware version of the device
ksm_Version : KSM(software running on SE) version of the device
coin_List : the list of coin which the device supported. For more information, refer to https://dcentwallet.com/SupportedCoin
Set Device Label
If you want to change the label of device, you can do it using setLabel()
fucntion.
var result
try{
result = await DcentWebConnector.setLabel("IoTrust")
}catch(e){
result = e
}
After execute above code, you can see the modified label on your device when reboot the device.
Add & Sync Account
You can add account using syncAccount()
function. You can create an account by specifying the coin type and key path of the account you want to add. If you want to add token type coin account, you must specify the coin name as the first 14 digits of contract address.
let account_infos = [{
coin_group: DcentWebConnector.coinGroup.ETHEREUM,
coin_name: DcentWebConnector.coinName.ETHEREUM,
label: 'ETHEREUM_1', // account label
balance: '0 ETH', // {String} balance of account. This string will be displayed on device.
address_path: "m/44'/60'/0'/0/0" // key path of the account. This address_path is displayed on the device with the corresponding address and QR code.
}]
var result
try{
// Ethereum account will be created.
result = await DcentWebConnector.syncAccount(account_infos)
}catch(e){
result = e
}
syncAccount()
method can be used also for updating account. If the account of the specified key path is already exist, the syncAccount()
method do not create account just sync the account information. For example, if you want to change the label of account or modify the balance, you can use the syncAccount()
method.
let account_infos = [{
coin_group: DcentWebConnector.coinGroup.ETHEREUM,
coin_name: DcentWebConnector.coinName.ETHEREUM,
label: 'ETH_1', // account label
balance: '1 ETH', // {String} balance of account. This string will be displayed on device.
address_path: "m/44'/60'/0'/0/0" // key path of the account. This address_path is displayed on the device with the corresponding address and QR code.
}]
// This Ethereum account is already created.
// So the Ethereum account label and balance will be just modified.
var result
try{
// Ethereum account will be updated.
result = await DcentWebConnector.syncAccount(account_infos)
}catch(e){
result = e
}
address_path
address_path
follows the BIP44 rules.
m / purpose' / coin_type' / account' / change / address_index
Accounts are distinguished by account
in address_path.
let account_infos = [{
coin_group: DcentWebConnector.coinGroup.ETHEREUM,
coin_name: DcentWebConnector.coinName.ETHEREUM,
label: 'ETH_2', // account label
balance: '0 ETH', // balance of account. This string will be displayed on device.
address_path: "m/44'/60'/1'/0/0" // key path of the account. This address_path is displayed on the device with the corresponding address and QR code.
}]
var result
try{
// A New Ethereum account is created.
result = await DcentWebConnector.syncAccount(account_infos)
}catch(e){
result = e
}
Retrieve Account
You can retrieve account list of connected device using getAccountInfo()
function.
var result
try{
// A New Ethereum account is created.
result = await DcentWebConnector.getAccountInfo()
}catch(e){
result = e
}
Returned account object has:
{
"header": {
"version": "1.0",
"response_from": "coin",
"status": "success"
},
"body": {
"command": "get_account_info",
"parameter": {
"account": [
{
"coin_group": "ETHEREUM",
"coin_name": "ETHEREUM",
"label": "eth_1",
"address_path": "m/44'/60'/0'/0/0"
}
]
}
}
}
label : label of account
coinGroup : coin group name of account
coinName : coin name of account
addressPath : address path of account
Last updated
Was this helpful?