# 7.3 Buy a membership with Cash Coins

Now you have the 25 CCC to buy a Bronze Membership. Let's do that.

# Use cases

Buys the membership with the given membershipType.

# Tools

The Sacco library, our own open source tool to sign and send transactions to any Cosmos SDK based blockchain, including Commercio.network.

The CommercioSDK, our own open source tool to format transactions to Commercio.network.

# Functions and APIs

  • Wallet derive;
  • MembershipHelper buyMembership.

# Step by step sequence

  1. Generate the newUserMnemonic using bip39 and save the value;
  2. Call the wallet derive function using this mnemonic;
  3. Finally, execute the MembershipHelper buyMembership to buy a membership.

# Code Examples

Here's an example of the implemetation in all the available languages.

# Dart

final networkInfo = NetworkInfo(
  bech32Hrp: 'did:com:',
  lcdUrl: 'http://localhost:1317',
);

final newUserMnemonic = ['push', 'grace', 'power', 'desk', 'arrive', 'horror', 'gallery', 'physical', 'kingdom', 'ecology', 'fat', 'firm', 'future', 'service', 'table', 'little', 'live', 'reason', 'maximum', 'short', 'motion', 'planet', 'stage', 'second',];

final newUserWallet = Wallet.derive(newUserMnemonic, networkInfo);

final response = await MembershipHelper.buyMembership(MembershipType.GOLD, newUserWallet);
1
2
3
4
5
6
7
8
9
10

# Kotlin

val networkInfo = NetworkInfo(
  bech32Hrp = "did:com:",
  lcdUrl = "http://localhost:1317"
)

val newUserMnemonic = listOf("push", "grace", "power", "desk", "arrive", "horror", "gallery", "physical", "kingdom", "ecology", "fat", "firm", "future", "service", "table", "little", "live", "reason", "maximum", "short", "motion", "planet", "stage", "second")

val newUserWallet = Wallet.derive(newUserMnemonic, networkInfo)

val response = MembershipHelper.buyMembership(
  membershipType = MembershipType.GOLD,
  wallet = newUserWallet
)
1
2
3
4
5
6
7
8
9
10
11
12
13

# C#

static commercio.sacco.lib.NetworkInfo networkInfo = new commercio.sacco.lib.NetworkInfo(
                bech32Hrp: "did:com:",
                lcdUrl: "http://localhost:1317"
              );

String newUserMnemonicString = "push grace power desk arrive horror gallery physical kingdom ecology fat firm future service table little live reason maximum short motion planet stage second";
List<String> newUserMnemonic = new List<String>(newUserMnemonicString.Split(" ", StringSplitOptions.RemoveEmptyEntries));

var newUserWallet = commercio.sacco.lib.Wallet.derive(newUserMnemonic, networkInfo);

var res = commercio.sdk.MembershipHelper.buyMembership(
 commercio.sdk.MembershipType.GOLD,
 newUserWallet
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14