# IdHelper
IdHelper allows to easily perform all the operations related to the commercio.network id module.
# Provided operations
getDidDocument, returns theDidDocumentassociated with the givendidandwallet, ornullif noDidDocumentwas found.static Future<DidDocument?> getDidDocument( String did, Wallet wallet, { http.Client? client, })1
2
3
4
5setDidDocument, performs a transaction setting the specifieddidDocumentas being associated with the address present inside the specifiedwallet. Optionallyfeeand broadcastingmodeparameters can be specified.static Future<TransactionResult> setDidDocument( DidDocument didDocument, Wallet wallet, { StdFee? fee, BroadcastingMode? mode, http.Client? client, })1
2
3
4
5
6
7setDidDocumentsList, performs a transaction setting thedidDocumentslist as being associated with the address present inside the specifiedwallet. Optionallyfeeand broadcastingmodeparameters can be specified.static Future<TransactionResult> setDidDocumentsList( List<DidDocument> didDocuments, Wallet wallet, { StdFee? fee, BroadcastingMode? mode, http.Client? client, })1
2
3
4
5
6
7requestDidPowerUp, creates a new transaction to request a Did PowerUp of the givenamountfrom thesenderWalletwallet for the givenpairwiseDidaddress. Signs everything that needs to be signed with the private key contained inside the given wallet and theprivateKey. Optionallyfeeand broadcastingmodeparameters can be specified.static Future<TransactionResult> requestDidPowerUp( Wallet senderWallet, String pairwiseDid, List<StdCoin> amount, CommercioRSAPrivateKey privateKey, { StdFee? fee, BroadcastingMode? mode, })1
2
3
4
5
6
7
8requestDidPowerUpsList, creates a new transaction from the senderwalletto request a list of Did PowerUprequestDidPowerUpsList. Optionallyfeeand broadcastingmodeparameters can be specified.static Future<TransactionResult> requestDidPowerUpsList( List<RequestDidPowerUp> requestDidPowerUpsList, Wallet wallet, { StdFee? fee, BroadcastingMode? mode, })1
2
3
4
5
6
# Usage examples
final networkInfo = NetworkInfo(
bech32Hrp: 'did:com:',
lcdUrl: 'http://localhost:1317',
);
final mnemonic = ['will', 'hard', ..., 'man'];
final wallet = Wallet.derive(mnemonic, networkInfo);
final pubKeys = [rsaVerificationPubKey, rsaSignaturePubKey];
final didDocument = DidDocumentHelper.fromWallet(
wallet: wallet,
pubKeys: pubKeys,
);
try {
// Set the Did Document
await IdHelper.setDidDocument(didDocument, wallet);
// Send the PowerUp amount to the Tumbler
final amount = [
StdCoin(
denom: 'uccc',
amount: '10',
)
];
await TxHelper.createSignAndSendTx(
[
MsgSend(
fromAddress: wallet.bech32Address,
toAddress: tumblerAddress,
amount: amount,
),
],
wallet,
);
// Generate a pairwise wallet
final pairwaiseWallet = Wallet.derive(
mnemonic,
networkInfo,
lastDerivationPathSegment: '1',
);
// Generate a PowerUp request
final requestDidPowerUp = await RequestDidPowerUpHelper.fromWallet(
wallet: wallet,
pairwiseDid: pairwaiseWallet.bech32Address,
amount: amount,
privateKey: rsaSignaturePriKey
);
// Send the PowerUp request
await IdHelper.requestDidPowerUpsList(
[requestDidPowerUp],
wallet,
);
} catch (error) {
throw error;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53