Accounts & Identity
Some read (non-transaction) methods are
static
and can be accessed without creating an instance of Datum. All blockchain write actions require a Datum instance initialized with a private key. Learn more about initializing the Datum instance here
static
createIdentity //static
Datum.createIdentity();
Creates a base identity
Returns
Object with key pair
Example
createIdentity();
static
getBalance //static
Datum.getBalance("0x6e585cc6047a55a793d1E922afE28BaefaBcd73C");
Returns the actual balance for given address in Datum Blockchain
Parameters
String
- wallet address
Returns
Promise with amount of DAT's in wei
Example
getBalance("0x6e585cc6047a55a793d1E922afE28BaefaBcd73C");
deposit
deposit(10);
Deposit some DAT tokens to the storage space. The costs for storage will be deducted from this balance.
Parameters
Number
- amount of DAT's you wanna deposit
Returns
Promise with transaction result
Example
deposit(10);
static
getDepositBalance //static
Datum.getDepositBalance("0x6e585cc6047a55a793d1E922afE28BaefaBcd73C");
Returns the actual deposited balance for given address in storage contract
Parameters
String
- wallet address
Returns
Promise with amount of DAT's in wei
Example
getDepositBalance("0x6e585cc6047a55a793d1E922afE28BaefaBcd73C");
withdrawal
withdrawal(10);
Withdrawal DAT tokens to the storage space.
Parameters
Number
- amount of DAT's you want to withdraw
Returns
Promise
Example
withdrawal(10);
Identity
new
identity.new("MyPassword",6).then(wallet => {
console.log(wallet);
}). catch(error => {
console.log(error);
});
Creates a new keystore with given password
Parameters
String
- Passwort for the new keystoreNumber
- [Optional] Amount of accounts that should be created , default = 1
Returns
Promise
object with address array and used seed to generate the keystore
//Result
{ addresses:
[ '0xcff691f0881c65821a07f9e17f08c94c3a9e2d6f',
'0xa97aa7d00f4750ee501d09e87148a793f8ad1dfc',
'0x0b4a48407f0471eb483dce3fa882dfed5da6e573',
'0x2e29804e0c31d161d1be2254aa1611aa91329077',
'0xf78fb11f9af67b2d054cf1824c1a6034beea2bd3',
'0x367298df93eff1109eccbd7e689dbf7ff119384e' ],
seed: 'animal bronze network mother cross thrive lift regret situate clean utility public' }
recover
Recover a keystore from given 12 seed words.
let seed = 'animal bronze network mother cross thrive lift regret situate clean utility public';
identity.recover(seed "newPassword", 6).then(wallet => {
console.log(wallet);
}). catch(error => {
console.log(error);
});
Parameters
String
- seed wordsString
- new passwordNumber
- [Optional] Amount of accounts that should be created , default = 1
Returns
Promise
object with address array from keystore
//Result
{ addresses:
[ '0xcff691f0881c65821a07f9e17f08c94c3a9e2d6f',
'0xa97aa7d00f4750ee501d09e87148a793f8ad1dfc',
'0x0b4a48407f0471eb483dce3fa882dfed5da6e573',
'0x2e29804e0c31d161d1be2254aa1611aa91329077',
'0xf78fb11f9af67b2d054cf1824c1a6034beea2bd3',
'0x367298df93eff1109eccbd7e689dbf7ff119384e']
}
storePassword
Store the password for the keystore in the class instance. Otherwise you have to confirm each access to your private keys.
identity.new("newPassword", 6).then(wallet => {
identity.storePassword("newPassword");
console.log(wallet);
}). catch(error => {
console.log(error);
});
Parameters
String
- password to use for all private key accesses
export
//static
export()
Serialize the actual keystore
Returns
object
serialized and encrypted keystore
Example
export();
Example Result
{"encSeed":{"encStr":"9knIh02UCmiT6WSuzf+cBeNzz8PDgwuVSH2l803Y6noUTEPRt6DnodMkF7VG6qJMzRR8jdpfz2CJSSzF2bN+9oyorvHIfuOL2S2DhAxNGHCq549bohjegvWEl0G1D1+3oLcRzGg/ayLgLATlzzFi6/m1YumklJ97d1eEd//uEAa2wRaXXu8QWA==","nonce":"IFOaInTX1ISpM8TCDUYxSZXTPJpOEkIS"},"encHdRootPriv":{"encStr":"qU7GbAVwODfYIiPjZohggFVcPiA0CdHyp8NW1Vu5nmLFUVOJL9CTyryOV/qrilKs2QxslznoiDFEU5fAd+BFCBOKuxQCTRx4ZWGMAhXWGrNFqzzTf2/RwwkiBKC0bdvdPFazmPphR94cKLuDsfXi2t8FCwe9MgfhbwHjWmqDWA==","nonce":"90o9rGauc4mihE1KBF/386dDE4YmVBPJ"},"addresses":["76dcac0bcd42f775bd7d676c0cab6dd5e8584f7d","aa5b4883a5027f944da97df58e287a80b8e892b7"],"encPrivKeys":{"76dcac0bcd42f775bd7d676c0cab6dd5e8584f7d":{"key":"M6p75QXb5RqEto8aV68GER23s+2z9Y52N9OR/Jt/8eLW1vi3nc3n4yzmVkL4Alik","nonce":"QhBsyE+6OhfTJifJtxnrgi1PhdFPTfjf"},"aa5b4883a5027f944da97df58e287a80b8e892b7":{"key":"QayPohF5tbaN7mW2WNyXkQ/aUNAvVVfnbbM7foSttBCo/sqSfRGazVz0XKYZ5Hfg","nonce":"IrhLst9PxIxIqrXKlK2U6atHIQh6TppX"}},"hdPathString":"m/44'/60'/0'/0","salt":"/uxYHccDVI95IjQwi2iIgobkTEfmgkAAvACwQCHJlq8=","hdIndex":2,"version":3}
import
//static
import(JSON.stringify({"encSeed":{"encStr":"9knIh02UCmiT6WSuzf+cBeNzz8PDgwuVSH2l803Y6noUTEPRt6DnodMkF7VG6qJMzRR8jdpfz2CJSSzF2bN+9oyorvHIfuOL2S2DhAxNGHCq549bohjegvWEl0G1D1+3oLcRzGg/ayLgLATlzzFi6/m1YumklJ97d1eEd//uEAa2wRaXXu8QWA==","nonce":"IFOaInTX1ISpM8TCDUYxSZXTPJpOEkIS"},"encHdRootPriv":{"encStr":"qU7GbAVwODfYIiPjZohggFVcPiA0CdHyp8NW1Vu5nmLFUVOJL9CTyryOV/qrilKs2QxslznoiDFEU5fAd+BFCBOKuxQCTRx4ZWGMAhXWGrNFqzzTf2/RwwkiBKC0bdvdPFazmPphR94cKLuDsfXi2t8FCwe9MgfhbwHjWmqDWA==","nonce":"90o9rGauc4mihE1KBF/386dDE4YmVBPJ"},"addresses":["76dcac0bcd42f775bd7d676c0cab6dd5e8584f7d","aa5b4883a5027f944da97df58e287a80b8e892b7"],"encPrivKeys":{"76dcac0bcd42f775bd7d676c0cab6dd5e8584f7d":{"key":"M6p75QXb5RqEto8aV68GER23s+2z9Y52N9OR/Jt/8eLW1vi3nc3n4yzmVkL4Alik","nonce":"QhBsyE+6OhfTJifJtxnrgi1PhdFPTfjf"},"aa5b4883a5027f944da97df58e287a80b8e892b7":{"key":"QayPohF5tbaN7mW2WNyXkQ/aUNAvVVfnbbM7foSttBCo/sqSfRGazVz0XKYZ5Hfg","nonce":"IrhLst9PxIxIqrXKlK2U6atHIQh6TppX"}},"hdPathString":"m/44'/60'/0'/0","salt":"/uxYHccDVI95IjQwi2iIgobkTEfmgkAAvACwQCHJlq8=","hdIndex":2,"version":3}));
Import a serialized keystore
Parameters
String
- serialized keystore as string
Example
import(keystore);
signMsg
Signs a message with the private key from given account in keystore
identity.signMsg("Sample message to sign", "newPassword").then(signed => {
console.log(signed);
}).catch(error => {
console.log(error);
});
Parameters
String
- message to signString
- passwordNumber
- [Optional] Used account to sign the message, default = 0 (main account)
Returns
Promise
object with signature of message (r,s,v);
//Result
{ r: Buffer,
s: Buffer,
v: 27 }
signTx
Signs a transaction with the private key from given account in keystore
identity.signTx(rawTx).then(signed => {
console.log(signed);
}).catch(error => {
console.log(error);
});
Parameters
String
- raw transaction encoded as HEX
Returns
Promise
signed Transaction
//Result
{ r: Buffer,
s: Buffer,
v: 27 }