This repository contains the backend code for the IITK Coin which is a reward based psuedo currency of IIT Kanpur.
- Documentation of this repo
- Website
- EndTerm Evaulation Folder
- Midterm Evaluation presentation
- Midterm Documentation
- OS: Ubuntu 20.04.2 LTS x86-64 # https://ubuntu.com/download
- Kernel: Linux 5.8.0-59-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/
.
~go/src/github.com/1-Harshit/iitk-coin
├── auth
│ └── auth.go
├── config
│ ├── config.go
│ ├── email_cred.go
│ ├── otp.go
│ ├── settings.go
│ └── validate.go
├── data.db
├── db
│ ├── db.go
│ ├── otp.go
│ ├── redeem.go
│ └── user.go
├── Dockerfile
├── go.mod
├── go.sum
├── iitk-coin
├── LICENSE
├── main.go
├── Models.png
├── README.md
└── routes
├── redeem.go
├── trnxn.go
├── user.go
└── utility.go
4 directories, 23 files
mkdir $GOPATH/src/github.com/1-Harshit
cd $GOPATH/src/github.com/1-Harshit
git clone https://github.com/1-Harshit/iitk-coin.git
cd iitk-coin
go run main.go
# or build the program and run the executable
go build
./iitk-coin
docker run --rm -p 8080:8080 1harshit/iitk-coin
Expected Output:
2021/07/18 01:03:46 Starting server. Listening on http://localhost:8080
POST requests take place via JSON
requests. A typical usage would look like
curl -H "Content-Type: application/json" [-H "Authorization: Bearer JWT"] --request POST -d '<json-request>' http://localhost:8080/<endpoint>
# or if using get
curl [-H "Authorization: Bearer JWT"] --request GET http://localhost:8080/<endpoint>
/signup/otp
:POST
{ "name": "<name>", "roll": "<rollno>", "email": "<emailid>" }
/signup
:POST
{
"name": "<name>",
"roll": "<rollno>",
"email": "<emailid>",
"password": "<password>",
"otp": "<otp>",
"batch": "<batch>"
}
/login
:POST
{ "roll": "<rollno>", "password": "<password>" }
/secretpage
:GET
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/secretpage
Auth Header needed in all endpoints below this
/user/info
:GET
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/user/info
/user/reward
:GET
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/user/reward
/user/transaction
:GET
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/user/transaction
/user/redeem
:GET
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/user/redeem
/forgotpass/otp
:POST
{ "roll": "<rollno>", "email": "<emailid>" }
/forgotpass
:POST
{ "roll": "<rollno>", "password": "<password>", "otp": "<otp>" }
/reward
:POST
Only GenSec and AH
{ "roll": "<rollno>", "coins": "<coins>" }
/transfer/otp
:GET
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/transfer/otp
/transfer
:POST
{ "roll": "<rollno>", "coins": "<coins>", "otp": "<otp>" }
/store/list
:GET
curl --request GET http://localhost:8080/store/list
/store/add
:POST
Only GenSec and AH
{ "name": "<itemname>", "value": "<itemvalue>" }
/store/remove
:POST
Only GenSec and AH
{ "itemNo": "<itemno>" }
/redeem/request/otp
:GET
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080/redeem/request/otp
/redeem/request
:POST
{ "itemNo": "<itemno>", "otp": "<otp>" }
/redeem/list
:GET
Only GenSec and AH
curl -H "Authorization: Bearer $JWT" --request GET http://localhost:8080//redeem/list
/redeem/approve
:POST
Only GenSec and AH
{ "redeemid": "<redeemid>" }
/redeem/reject
:POST
Only GenSec and AH
{ "redeemid": "<redeemid>" }
- Run the
main.go
file this will Listen and Serve onlocalhost:8080
- Use
curl
to use endpoints as shown above
Some unkown variables are stored there.
- Path of DB
- Max coins one can have
- Minimum Events needed for transfer
- tax
- const IntraBatchTax float64 = 0.02
- const InterBatchTax float64 = 0.33
- const IsStoreOpen bool = true
- Email Credentials for sending OTP
- Username
- Password
I'd like to name it Koins