Accounts
Dartez init
The function init the sodium libs used in mnemonic and private key functions
await Dartez().init();
Get Balance
This function returns the balance of tezos account on a particular tezos network.
String balance = await Dartez.getBalance('tz1c....ozGGs', 'your rpc server');
Generate Mnemonics
This function will return a new set of mnemonic phrases as a space separated words, which is used for generating key pairs for tezos account.
The mnemonic must encode entropy in a multiple of 32 bits. With more entropy security is improved but the sentence length increases. We refer to the initial entropy length as strength. The allowed size of strength is 128-256 bits. (The default value of strength is 256)
The generateMnemonic function follows implementations of BIP-0039.
String mnemonic = Dartez.generateMnemonic();
// mnemonic = sustain laugh capital ..... hundred same brave
String mnemonic = Dartez.generateMnemonic(strength: 128);
// mnemonic = sustain laugh capital ….. hundred same brave
Generate Keys From Mnemonics
This function will generate a new set of keys using mnemonic & passphrase, which can be used for interacting with tezos blockchain.
KeyStoreModel keys = Dartez.getKeysFromMnemonic(mnemonic: "Your Mnemonic");
KeyStoreModel identityWithMnemonic = Dartez.getKeysFromMnemonic(
mnemonic: "your mnemonic",
passphrase: "pa$\$w0rd",
);
Reveal An Account
This function reveal an account's publicKey, which is required before performing any transaction on tezos blockchain.
var server = '';
var keyStore = KeyStoreModel(
publicKeyHash: 'tz1U.....W5MHgi',
secretKey: 'edskRp......bL2B6g',
publicKey: 'edpktt.....U1gYJu2',
);
var signer = await Dartez.createSigner(
Dartez.writeKeyWithHint(keyStore.secretKey, 'edsk'));
var result =
await Dartez.sendKeyRevealOperation(server, signer, keyStore);
print('${result['operationGroupID']}');
Unlock Fundraiser Identity
This function will generate a new set of keys using mnemonic, email & passphrase, which can be used for interacting with tezos blockchain.
KeyStoreModel identityFundraiser = await Dartez.unlockFundraiserIdentity(
mnemonic: "your mnemonic",
email: "[email protected]",
passphrase: "5tj...imq");
Restore Identity From Derivation Path
This function will recovers a set of keys using mnemonic & derivation path, which can be used for interacting with tezos blockchain.
var derivationPath = 'your derivation path';
var mnemonic = 'your mnemonic';
KeyStoreModel keyStore = await Dartez.restoreIdentityFromDerivationPath(derivationPath, mnemonic);
Get Keys From Secret Key
This function will recovers a set of keys using secret key, which can be used for interacting with tezos blockchain.
KeyStoreModel keys = Dartez.getKeysFromSecretKey("edsk.....vdC");
Delegate An Account
This function delegate the account to the baker account address, This is a means for non-"baker" (non-validator) accounts to participate in the on-chain governance process and receive staking rewards.
var server = '';
var keyStore = KeyStoreModel(
publicKey: 'edpk.....rrj',
secretKey: 'edsk.....yHH',
publicKeyHash: 'tz1.....hxy',
);
var signer = await Dartez.createSigner(
Dartez.writeKeyWithHint(keyStore.secretKey, 'edsk'));
var result = await Dartez.sendDelegationOperation(
server,
signer,
keyStore,
'tz1.....Lnc',
10000,
);
print("Applied operation ===> $result['appliedOp']");
print("Operation groupID ===> $result['operationGroupID']");
Transfer Balance
This function used for transfer of value between two accounts, In this example we have the account: tz1.....hxy
and some random testnet address to test with: tz1.....Lnc
. Note all amounts are in µtz, as in micro-tez, hence 0.5tz is represented as 500000
. The fee of 1500
was chosen arbitrarily, but some operations have minimum fee requirements.
var server = '';
var keyStore = KeyStoreModel(
publicKey: 'edpk.....rrj',
secretKey: 'edsk.....yHH',
publicKeyHash: 'tz1.....hxy',
);
var signer = await Dartez.createSigner(
Dartez.writeKeyWithHint(keyStore.secretKey, 'edsk'));
var result = await Dartez.sendTransactionOperation(
server,
signer,
keyStore,
'tz1.....Lnc',
500000,
1500,
);
print("Applied operation ===> $result['appliedOp']");
print("Operation groupID ===> $result['operationGroupID']");
Last updated