# Membership helper

Membership helper allows to easily perform all the operations related to the commercio.network membership module.

# Provided operations

  1. Sends a new transaction in order to invite the given userDid
static Future<TransactionResult> inviteUser(
  String userDid,
  Wallet wallet,
) async
1
2
3
4
  1. Buys the membership with the given membershipType
static Future<TransactionResult> buyMembership(
  MembershipType membershipType,
  Wallet wallet,
) async
1
2
3
4

# Usage examples

You can reach the examples code here

import 'package:commerciosdk/export.dart';
import 'commons.dart';

void main() async {
  final info = NetworkInfo(
    bech32Hrp: "did:com:",
    lcdUrl: "http://localhost:1317",
  );

  final userMnemonic = [
    "will",
    "hard",
    "topic",
    "spray",
    "beyond",
    "ostrich",
    "moral",
    "morning",
    "gas",
    "loyal",
    "couch",
    "horn",
    "boss",
    "across",
    "age",
    "post",
    "october",
    "blur",
    "piece",
    "wheel",
    "film",
    "notable",
    "word",
    "man"
  ];
  final userWallet = Wallet.derive(userMnemonic, info);

  final newUserMnemonic = [
    "often",
    "emerge",
    "table",
    "boat",
    "add",
    "crowd",
    "obtain",
    "creek",
    "skill",
    "flat",
    "master",
    "gift",
    "provide",
    "peasant",
    "famous",
    "blur",
    "flight",
    "lady",
    "elephant",
    "twenty",
    "join",
    "depth",
    "laptop",
    "arrest"
  ];
  final newUserWallet = Wallet.derive(newUserMnemonic, info);

  // --- Invite user
  final response = await MembershipHelper.inviteUser(
                          newUserWallet.bech32Address, 
                          userWallet
  );
  checkResponse(response);
  // --- Buy a membership
  final response = await MembershipHelper.buyMembership(
                           type: MembershipType.GOLD, 
                           wallet: newUserWallet
  );
  checkResponse(response);
}
1
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78