Skip to content

TetraGrids/web4-cpp-header

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Time and Space Antelope Smart Contract Utilities 🌍⏰

This allows you to write contracts using common names instead of country codes, and ensures compatibilities when interacting with ISO 3166 (Alpha-2 and Alpha-3 [two and three lette codes]) nations and third-party contracts who also use this convention, like Tetra, and cXc's Metadata Standards.

The intention behind this release is to share a useful component in creting global grids of connection.

You could use the space data to validate the name of a country code, and the time data to create a gamified cosmomimetic rewards system.

This was created on-route to the upcoming RA system by tetra.earth

All .hpp files are in the include directory.

Contents πŸ“

  1. Countries Enumeration (countries.hpp)
  2. Continents Enumeration (continents.hpp)
  3. Time Enumeration (time.hpp)
  4. Reward Series (reward_series.hpp)

Countries Enumeration (countries.hpp) 🌍

The countries.hpp header provides a comprehensive enumeration of countries (Countries_ISO3) using ISO 3166-1 alpha-3 country codes.

Key Features:

  • Cross-Contract Compatibility: Enum values are explicitly numbered for consistent cross-contract compatibility.
  • Comprehensive Country List: Includes a wide range of countries, each represented by their ISO 3166-1 alpha-3 codes.

Usage in EOSIO Smart Contract:

#include "countries.hpp"

// Example: Retrieving a country code
Countries_ISO3 country_code = Countries_ISO3::USA; // Retrieves the code for USA

// Action demonstrating the use of country code
[[eosio::action]]
void showCountryCode() {
    Countries_ISO3 country_code = Countries_ISO3::FRA; // Code for France
    eosio::print("Country Code: ", static_cast<int>(country_code));
}

Continents Enumeration (continents.hpp) 🌐

The continents.hpp header includes an enumeration of continents (Continents), providing a straightforward way to categorize geographical data.

Key Features:

  • Simple and Efficient: Easy-to-use enumeration of all the continents.
  • Versatile Usage: Suitable for geographic categorization and analysis.

Usage in EOSIO Smart Contract:

#include "continents.hpp"

// Example: Retrieving a continent
Continents continent = Continents::EUROPE; // Retrieves Europe

// Action demonstrating the use of continent enumeration
[[eosio::action]]
void showContinent() {
    Continents continent = Continents::ASIA; // Selects Asia
    eosio::print("Selected Continent: ", static_cast<int>(continent));
}

Time Enumeration (time.hpp) ⏰

The time.hpp header includes enumerations for common time spans, making time management in contracts more intuitive.

It also includes celestial cycles for the solar system to use in biomimetic tokenomics.

Key Features:

  • Varied Time Units: Ranges from seconds to years for flexible time calculations.
  • Simplified Time Handling: Streamlines time-related operations in contracts.

Usage in EOSIO Smart Contract:

#include "time.hpp"

// Example: Retrieving a time span value
In time_span = In::Hour; // Retrieves the value for an hour (3600 seconds)

// Action demonstrating the use of time span
[[eosio::action]]
void showTimeSpan() {
    In time_span = In::Day; // Value for a day (86400 seconds)
    eosio::print("Time Span in seconds: ", static_cast<int>(time_span));
}

Reward Series (reward_series.hpp) πŸ’°

The reward_series.hpp header includes a series of reward structures for use in tokenomics.

Key Features:

  • Flexible Reward Structures: Provides a range of reward seriec for leveled tokenomics.
  • Simple and Efficient: Easy-to-use, with common series.
  • Extendable: Add new reward series, and extend the ones here if needed (they are cirrently 24 levels per series).

Usage in EOSIO Smart Contract:

#include "reward_series.hpp"

// --- Get reward series --- //
vector<uint64_t> reward_series_referral = getSeries(string("SILVER"));

// --- Get User's level using the series --- //

    uint32_t series_size_referral = reward_series_referral.size();

    for (size_t i = 0; i < series_size_referral; ++i) {
        if (refscore < reward_series_referral[i]) {
            refscore_lvl = i + 1; // Update the refscore level based on the series
            break;
        }
    }

Getting Started πŸš€

To begin, clone this repository and include the necessary headers in your Antelope smart contract.

License πŸ“œ

This project is under the MIT License - see the LICENSE file for details.

This was created in coordination with cXc.world and WAX Labs

About

πŸ›  A C++ header file containing Spacetime (web4) primitives πŸ›Έ

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages