This is the REST API of Random ,a platform where users can take place in the traditional baba ijebu lottery game on chain(Algorand)
This project is made up of 3 main folders
- contracts
- scripts
- test
The contracts folder contains the pyTeal code used to write the smart contracts.It is compiled to TEAL bytecode and can be deployed to mainnet or testnet.
To compile the pyteal
- Run the python file
lotto.py
. This also generates the app.teal bytecode and abi contract.json
This folder contains all the scripts written to interact with the smart contract in typescript.The code to deploy the contract is in deploy.ts
.You are to input your account credentials in config.ts
.The atomic transaction composer used to call ABI methods from the contract is in call.ts
.
To deploy the contract,run
npx ts-node scripts/deploy.ts
Clone the repository
git clone https://github.com/Jaybee020/
Cd into backend folder
cd backend
Install node dependencies
npm install
To start the express server
npm start
Open your local browser and verify the server is running with http://localhost:6060/
GET "/lottoGame/profile/:addr"
All parameters are to be in URL
Parameter | Type | Description |
---|---|---|
addr |
string |
Required. address of account we want to get game profile for. |
response.body
{ status:true,
data:userLottoInteraction[]
GET "/lottoGame/playerCalls/:addr/:lottoId"
All parameters are to be in URL
Parameter | Type | Description |
---|---|---|
addr |
string |
Required. account address to get lotto contract calls fot |
lottoId |
string |
Required. lottoId to get filter by |
response.body
{
status:true,
data:userLottoInteraction[]
}
}
GET "/lottoGame/allLottoIdHistory"
response.body
{ status:true,
data:allLottos
}
GET "/lottoGame/lottoHistory/:lottoId"
All parameters are to be in URL
Parameter | Type | Description |
---|---|---|
lottoId |
string |
Required. lottoId to get details of |
response.body
{ status:true,
data: {
lottoPayTxn: lottoPayTxn,
lottoCallTxn: lottoCallTxn,
lottoHistoryDetails: lottoHistoryDetails,
},
GET "/lottoGame/lottoPayTXnHistory"
response.body
{ status:true,
data:lottoPayTxn,
},
GET "/lottoGame/currentGameParams"
response.body
{
status: true,
data: GameParams {
ticketingStart: number;
ticketingDuration: number;
withdrawalStart: number;
ticketFee: number;
luckyNumber: number;
winMultiplier: number;
maxPlayersAllowed: number;
maxGuessNumber: number;
gameMaster: string;
playersTicketBought: number;
playersTicketChecked: number;
totalGamePlayed: number;
}
}
POST "/lottoGame/enterCurrentGame"
All parameters are to be in req.body.
Parameter | Type | Description |
---|---|---|
playerAddr |
string |
Required. address of player |
guessNumber |
string |
Required. player guess number |
This returns an array of transactions to be signed by the client
response.body
{ status:true,
data:Transaction[]
}
POST "/lottoGame/endCurrentAndCreateNewGame"
All parameters are to be in req.body.
Parameter | Type | Description |
---|---|---|
ticketingStart |
number |
Optional. time when ticket sales should begin |
ticketingDuration |
number |
Optional. how long ticket sales should last for |
withdrawalStart |
number |
Optional. time when winners can withdraw |
ticketFee |
number |
Optional. how many algos a ticket should cost |
winMultiplier |
number |
Optional. ticketFee multiple winners should get |
maxPlayersAllowed |
number |
Optional. maximum players allowed to participate in the round |
maxGuessNumber |
number |
Optional. maximum value for guess and lucky number |
gameMasterAddr |
string |
Required. address that wants to fund this game round. |
This returns an array of transactions to be signed by the client
response.body
{
status:true,
data:Transaction[]
}
POST "/lottoGame/changePlayerGuessNumber"
All parameters are to be in req.body.
Parameter | Type | Description |
---|---|---|
playerAddr |
string |
Required. address of player |
newGuessNumber |
string |
Required. new player guess number |
This returns an array of transactions to be signed by the client
response.body
{ status:true,
data:Transaction[]
}
GET "/lottoGame/getPlayerGuessNumber/:addr"
All parameters are to be in URL
Parameter | Type | Description |
---|---|---|
addr |
string |
Required. playerAddress to get by |
response.body
{
status: true,
data: Number
}
GET "/lottoGame/getGeneratedRandomNumber"
response.body
{
status: true,
data: Number
}
POST "/lottoGame/generateLuckyNumber"
response.body
{
status: true,
}
POST "/lottoGame/checkUserWin"
All parameters are to be in req.body.
Parameter | Type | Description |
---|---|---|
playerAddr |
string |
Required. address of player |
response.body
{
status: true,
data:Boolean
}