# 3.4 Request Powerup

# Use cases

Creates a new Did power up request for the given pairwiseDid and of the given amount only after you made a did deposit request.

# Tools

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

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

# Functions and APIs

  • Wallet derive;
  • IdHelper requestDidPowerUp;
  • RSAKeyParser parseKeyFromPem.

# Background

From Bitcoin Wiki:

Bech32 is a segwit address format specified by BIP 0173. This address format is also known as "bc1 addresses".

From Wikipedia:

Segregated Witness, or SegWit, is the name used for an implemented soft fork change in the transaction format of the cryptocurrency bitcoin.

# Step by step sequence

  1. Send tokens to the Tumbler;
  2. Generate the pairwiseMnemonic using bip39 and save the value;
  3. Call the wallet derive function using this mnemonic;
  4. Finally, execute the IdHelper requestDidPowerUp function to request the Powerup.

# Code Examples

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

# Dart

final mnemonic = ['push', 'grace', ..., 'second'];
final wallet = Wallet.derive(mnemonic, networkInfo);
final pairwiseWallet = Wallet.derive(
  mnemonic, networkInfo, lastDerivationPathSegment: '1',
);
final depositAmount = [
  const StdCoin(denom: 'ucommercio', amount: '100')
];
// [privateKey] is the RSA private key associated with
// the public key of type 'signature' set in the DDO.
final privateKey = RSAPrivateKey(
  RSAKeyParser.parseKeyFromPem(
    """
    -----BEGIN PRIVATE KEY-----
    MIIEvQ...
    -----END PRIVATE KEY-----
    """
  ),
);
await IdHelper.requestDidPowerUp(
  wallet,
  pairwiseWallet.bech32Address,
  depositAmount,
  privateKey,
);
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

# Kotlin

val pairwiseMnemonic = 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 pairwiseWallet = Wallet.derive(
  mnemonic = pairwiseMnemonic,
  networkInfo = networkInfo
)

val depositAmount = listOf(StdCoin(denom = "ucommercio", amount = "10"))
val fee = StdFee(gas = "200000", amount = listOf(StdCoin(denom = "ucommercio", amount = "10000")))
IdHelper.requestDidPowerUp(
  pairwiseDid = Did(pairwiseWallet.bech32Address),
  amount = depositAmount,
  wallet = wallet,
  fee = fee
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

# C#

String pairwiseMnemonicString = "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> pairwiseMnemonic = new List<String>(pairwiseMnemonicString.Split(" ", StringSplitOptions.RemoveEmptyEntries));

var pairwiseWallet = commercio.sacco.lib.Wallet.derive(pairwiseMnemonic, networkInfo);
List<commercio.sacco.lib.StdCoin> depositAmount = new List<commercio.sacco.lib.StdCoin>();
depositAmount.Add(new commercio.sacco.lib.StdCoin(denom: "ucommercio", amount: "10"));

var res = commercio.sdk.IdHelper.requestDidPowerUp(
 pairwiseWallet.bech32Address,
 depositAmount,
 wallet
);
1
2
3
4
5
6
7
8
9
10
11
12