|
1 | | -# web4-cpp-header |
2 | | -🛠 A C++ header file containing Spacetime (web4) primitives 🛸 |
| 1 | +# Time and Space Antelope Smart Contract Utilities 🌍⏰ |
3 | 2 |
|
| 3 | +Welcome to the EOSIO Smart Contract Utilities repository! This project provides essential C++ headers for EOSIO / Antelope smart contracts, designed to empower dapps on the WAX blockchain. It includes enumerations for countries, continents, and time spans, all designed for easy integration into your smart contracts. |
4 | 4 |
|
5 | | -All files are in the `include` directory. |
| 5 | +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](https://github.com/TetraGrids), and [cXc's Metadata Standards](https://github.com/currentxchange/WAX-NFT-Metadata-Standards). |
| 6 | + |
| 7 | +*All .hpp files are in the `include` directory.* |
| 8 | + |
| 9 | +## Contents 📁 |
| 10 | +1. [Countries Enumeration (`countries.hpp`)](#countries-enumeration) |
| 11 | +2. [Continents Enumeration (`continents.hpp`)](#continents-enumeration) |
| 12 | +3. [Time Enumeration (`time.hpp`)](#time-enumeration) |
| 13 | +4. [Getting Started](#getting-started) |
| 14 | +5. [Contributing](#contributing) |
| 15 | +6. [License](#license) |
| 16 | + |
| 17 | +### Countries Enumeration (`countries.hpp`) 🌍 |
| 18 | +The `countries.hpp` header provides a comprehensive enumeration of countries (`Countries_ISO3`) using ISO 3166-1 alpha-3 country codes. |
| 19 | + |
| 20 | +#### Key Features: |
| 21 | +- **Cross-Contract Compatibility**: Enum values are explicitly numbered for consistent cross-contract compatibility. |
| 22 | +- **Comprehensive Country List**: Includes a wide range of countries, each represented by their ISO 3166-1 alpha-3 codes. |
| 23 | + |
| 24 | +#### Usage in EOSIO Smart Contract: |
| 25 | +```cpp |
| 26 | +#include "countries.hpp" |
| 27 | + |
| 28 | +// Example: Retrieving a country code |
| 29 | +Countries_ISO3 country_code = Countries_ISO3::USA; // Retrieves the code for USA |
| 30 | + |
| 31 | +// Action demonstrating the use of country code |
| 32 | +[[eosio::action]] |
| 33 | +void showCountryCode() { |
| 34 | + Countries_ISO3 country_code = Countries_ISO3::FRA; // Code for France |
| 35 | + eosio::print("Country Code: ", static_cast<int>(country_code)); |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +### Continents Enumeration (`continents.hpp`) 🌐 |
| 40 | +The `continents.hpp` header includes an enumeration of continents (`Continents`), providing a straightforward way to categorize geographical data. |
| 41 | + |
| 42 | +#### Key Features: |
| 43 | +- **Simple and Efficient**: Easy-to-use enumeration of all the continents. |
| 44 | +- **Versatile Usage**: Suitable for geographic categorization and analysis. |
| 45 | + |
| 46 | +#### Usage in EOSIO Smart Contract: |
| 47 | +```cpp |
| 48 | +#include "continents.hpp" |
| 49 | + |
| 50 | +// Example: Retrieving a continent |
| 51 | +Continents continent = Continents::EUROPE; // Retrieves Europe |
| 52 | + |
| 53 | +// Action demonstrating the use of continent enumeration |
| 54 | +[[eosio::action]] |
| 55 | +void showContinent() { |
| 56 | + Continents continent = Continents::ASIA; // Selects Asia |
| 57 | + eosio::print("Selected Continent: ", static_cast<int>(continent)); |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +### Time Enumeration (`time.hpp`) ⏰ |
| 62 | +The `time.hpp` header includes enumerations for common time spans, making time management in contracts more intuitive. |
| 63 | + |
| 64 | +#### Key Features: |
| 65 | +- **Varied Time Units**: Ranges from seconds to weeks for flexible time calculations. |
| 66 | +- **Simplified Time Handling**: Streamlines time-related operations in contracts. |
| 67 | + |
| 68 | +#### Usage in EOSIO Smart Contract: |
| 69 | +```cpp |
| 70 | +#include "time.hpp" |
| 71 | + |
| 72 | +// Example: Retrieving a time span value |
| 73 | +In time_span = In::Hour; // Retrieves the value for an hour (3600 seconds) |
| 74 | + |
| 75 | +// Action demonstrating the use of time span |
| 76 | +[[eosio::action]] |
| 77 | +void showTimeSpan() { |
| 78 | + In time_span = In::Day; // Value for a day (86400 seconds) |
| 79 | + eosio::print("Time Span in seconds: ", static_cast<int>(time_span)); |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +## Getting Started 🚀 |
| 84 | +To begin, clone this repository and include the necessary headers in your Antelope smart contract. |
| 85 | + |
| 86 | + |
| 87 | +## License 📜 |
| 88 | +This project is under the MIT License - see the [LICENSE](LICENSE.md) file for details. |
| 89 | + |
| 90 | + |
| 91 | +This was created in coordination with [cXc.world](https://cxc.world) and [WAX Labs](https://labs.wax.io/proposals/84) |
0 commit comments