Skip to content

This repository contains the code for the IITKCoin, a vision of a pseudo-currency for use in the IITK Campus.

License

Notifications You must be signed in to change notification settings

sparshs413/iitk-coin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IITK Coin

SnT Project 2021, Programming Club

This repository contains the code for the IITKCoin, a vision of a pseudo-currency for use in the IITK Campus.

Relevant Links

Table Of Content

Development Environment

- OS:           Ubuntu 20.04.2 LTS x86-64    # https://ubuntu.com/download
- Kernel:       Linux 5.4.0-80-generic       # https://kernel.ubuntu.com/
- go version:   go1.16.6 linux/amd64         # https://golang.org/dl/
- text editor:  VSCode    	                  # https://code.visualstudio.com/download
- terminal:     Zsh                          # https://ohmyz.sh/

Directory Structure

.

├── auth
│   └── auth.go
├── controllers
│   └── controller.go
├── database
│   └── database.go
├── db
    ├── transactionHistory.db
│   └── users.db
├── go.mod
├── go.sum
├── main.go
├── models
│   └── models.go
├── README.md

5 directories, 10 files

Usage

Use this repo

cd $GOPATH/src/github.com/<username>
git clone https://github.com/sparshs413/iitk-coin.git
cd repo
go run main.go
#, or build the program and run the executable
go build
./iitk-coin

Output should look like

2021/07/26 22:24:25 User Database opened and table created (if not existed) successfully!
2021/07/26 22:24:25 Wallet Database opened and table created (if not existed) successfully!
2021/07/26 22:24:25 Transaction Database opened and table created (if not existed) successfully!
2021/07/26 22:24:25 Starting server, Listening on http://localhost:8080

Use Docker Image

docker run --rm -p 8080:8080 sparshs413/iitk-coin

Endpoints

POST requests take place via JSON requests. A typical usage would look like

curl -d '<json-request>' -H 'Content-Type: application/json' http://localhost:8080/<endpoint>
  • /signup : POST
{ "username": "<username>", "name": "<name>", "rollno": "<rollno>", "password": "<password>" }

PS: Roll Nos, only valid in range of [170001, 210000).

  • /login : POST
{ "rollno": "<rollno>", "password": "<password>" }
  • /balance : POST
{ "rollno": "<rollno>" }
  • /giveCoins : POST
{ "rollno": "<rollno>", "coins": "<coins>" }
  • /transferCoins : POST
{ "senderRollno": "<senderRollno>", "receiverRollno": "<receiverRollno>", "transferCoins": "<transferCoins>" }

GET requests:

  • /secretpage : GET
curl http://localhost:8080/secretPage

About

This repository contains the code for the IITKCoin, a vision of a pseudo-currency for use in the IITK Campus.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published