# eos-new-table

> Generate EOS C++ smart contract to create a table.

Latest version **1.0.8** (published 2018-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install eos-new-table
pnpm add eos-new-table
yarn add eos-new-table
bun add eos-new-table
```

Provides the command `eos-new-table`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2018-08-07 |
| First published | 2018-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Consensus Clubs |
| Maintainers | notsag-dev |

## Links

- npm: https://www.npmjs.com/package/eos-new-table
- Repository: https://github.com/rflxvty/eos-new-table
- Homepage: https://github.com/rflxvty/eos-new-table#readme
- Issues: https://github.com/rflxvty/eos-new-table/issues
- npm.io page: https://npm.io/package/eos-new-table

## Dependencies (2)

- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [underscore](https://npm.io/package/underscore.md) ^1.9.1

## Recent versions

- 1.0.8 (latest) — 2018-08-07
- 1.0.7 — 2018-08-07
- 1.0.6 — 2018-07-27
- 1.0.5 — 2018-07-27
- 1.0.4 — 2018-07-26
- 1.0.3 — 2018-07-26
- 1.0.2 — 2018-07-26
- 1.0.1 — 2018-07-26
- 1.0.0 — 2018-07-26

## README

# eos-new-table
Generate EOS C++ smart contract to create a table on the blockchain.

## Install
Install it globally with:

```bash
npm i -g eos-new-table
```

## Usage
### Options
```bash
$ eos-new-table

Generate EOS C++ smart contract to create a table on the blockchain.
  Options:
  --name          Name of the element to be represented. e.g. user
  --attributes    Semicolon separated list of attributes of the element with their types.
                  e.g. 'std::string name; uint64_t token_amount'
  --table-name    Name of the table to be created. If not defined the name parameter will be used.
  --help          Show this help message.
  
 ```
 ### Example
 ```bash
 $ eos-new-table --name user --table-name users --attributes 'std::string name; uint64_t tokens_amount'
 ```
 
 #### user.cpp
 ```c++
#include <eosiolib/eosio.hpp>

using namespace eosio;

class user_management : public eosio::contract {
  public:
    using contract::contract;

    user_management(account_name self):
      contract(self),
      users(_self, _self) {}

    /// @abi action
    void insert(std::string name, uint64_t tokens_amount) {
      users.emplace(_self, [&](auto& new_user) {
        new_user.id = users.available_primary_key();
        new_user.name = name;
        new_user.tokens_amount = tokens_amount;
      });
    }

  private:
    // @abi table users i64
    struct user {
      uint64_t id;
      std::string name;
      uint64_t tokens_amount;

      uint64_t primary_key() const { return id; };
      EOSLIB_SERIALIZE(user, (id)(name)(tokens_amount))
    };

    eosio::multi_index<N(users), user> users;
};

EOSIO_ABI(user_management, (insert))
 ```

---
_Source: https://npm.io/package/eos-new-table · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
