# 2.7 Request free Tokens from a Faucet

To do anything on a blockchain you need tokens. If you are operating on mainnet.commercio.network you need to purchase them from someone, since they are real money. If you are operating on testnet.commercio.network you can have them for free, since they are like play money

We have a API service called Faucet.commercio.network that provides Commecio tokens for free to developers like you.

  • Free of charge
  • no string attached
  • No biggie... they are just Monopoly™ money

# Use cases

Recharge an account with free tokens.

# Tools

Faucet, software that exposes some APIs on the Web.

# Functions and APIs

# /give

  • Method: GET
  • Parameters:
    • addr: destination address
    • amount: amount of tokens to be sent from Faucet to addr, expressed in ucommercio
  • Return value:
    • 200 if request is successful, along with a "/give response" JSON response
    • 403 if the request wasn't successful because of user error, along with an "Error" response
    • 500 if the request wasn't successful because of server error, along with an "Error" response

# Step by step sequence

  1. Call the give API using all the query parameters; 100.000.000 ucommercio is the max amount available.
  2. Get an hash if the transaction was succesfull.

# Code Examples

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

# Dart

const String authority = 'faucet-testnet.commercio.network';
const String path = '/give';
final query = {
  'addr': address,
  'amount': '100000000',
};
final uri = Uri.https(authority, path, query);

try {
  final response = await http.get(uri);
  final data = json.decode(response.body);
} catch (error) {
  throw error;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14