Skip to content

larryk85/sample-kv-tables-application

Repository files navigation

Sample KV Tables Application

EOSIO Alpha EOSIO Labs

About EOSIO Labs

EOSIO Labs repositories are experimental. Developers in the community are encouraged to use EOSIO Labs repositories as the basis for code and concepts to incorporate into their applications. Community members are also welcome to contribute and further develop these repositories. Since these repositories are not supported by Block.one, we may not provide responses to issue reports, pull requests, updates to functionality, or other requests from the community, and we encourage the community to take responsibility for these.

Sample KV Tables Application lets developers start using the new kv tables feature with eosio and eosjs in a matter of minutes.

Powered by Gitpod.io and Docker, it provides developers with a personal single-node EOSIO blockchain for development and testing purposes without a need of going through advanced local environment setup. It also includes a simple example application with a concise smart contract and web frontend, connected to the blockchain. Developers can also use EOSIO tools like cleos and eosio.cdt straight out of the box. This project requires zero installation on the user's machine. All code is stored and managed on the developer's personal GitHub account, with the changes saved automatically.

We built this example application with ease of use and simplicity in mind. It can be used by new and advanced developers to try out the new kv tables feature.

We hope you will find this example application insightful and welcome feedback on future improvements.

Setup

  1. Fork this repo to your personal GitHub account so that you can save your work into your personal Github account.

  2. Point your browser to the following URL https://gitpod.io/#https://github.com/your-github-account/sample-kv-tables-application to start the IDE. You will be automatically prompted to create a Gitpod account (all types of Gitpod accounts (including free) will work). You can also choose to provide multiple developers push access to your personal github fork of this repo to collaborate with them (one developer working on the smart contract (C++) while the other working on the front-end decentralized application (EOSJS), etc.). Each such developer sharing access to the forked repo will get their own copy of the EOSIO blockchain components to enable independent development.

You can test drive the system by accessing the IDE at https://gitpod.io/#https://github.com/EOSIO/sample-kv-tables-application (however you will not be able to save your work into the EOSIO/sample-kv-tables-application Github repository)

Instructions

The following instructions assume that the Web IDE was started successfully (see Setup).

Initial State

The example application has the simple smart contract located in contracts. This version is already set on the chain and is available after the chain initializes. Upon launching the IDE, the nodeos and webpack processes will start the chain and webapp respectively and you view and change the todo application that the smart contract manages.

Opening a terminal

To open a terminal, use the Terminal drop-down menu in the IDE user interface.

Building sample contract

The source code for the sample smart contract is in contracts if you would like to change the contract and set a new version to the chain. To compile the contract, run these commands in a new terminal or at the root folder of the workspace in an existing terminal:

eosio-cpp contracts/kv_tables.cpp

This will produce kv_tables.abi and kv_tables.wasm in the directory you ran the command.

Installing the contract

Run this in a terminal from the directory you ran the previous command:

cleos set abi kvtable ./kv_tables.abi -p kvtable@active -p eosio@active
cleos set code kvtable ./kv_tables.wasm -p kvtable@active -p eosio@active

Viewing the front-end decentralized web app (EOSJS):

The source code for the React WebApp is at webapp/src/index.tsx within the IDE. To preview the WebApp run this in a terminal:

gp preview $(gp url 8000)

Resetting the chain

To remove the existing chain and create another:

  • Switch to the terminal running nodeos
  • Press ctrl+c to stop it
  • Run the following
rm -rf ~/eosio/chain
nodeos --config-dir ~/eosio/chain/config --data-dir ~/eosio/chain/data -e -p eosio --plugin eosio::chain_api_plugin

Contributing

Contributing Guide

Code of Conduct

License

MIT

Important

See LICENSE for copyright and license terms.

All repositories and other materials are provided subject to the terms of this IMPORTANT notice and you must familiarize yourself with its terms. The notice contains important information, limitations and restrictions relating to our software, publications, trademarks, third-party resources, and forward-looking statements. By accessing any of our repositories and other materials, you accept and agree to the terms of the notice.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published