Teenpatti is an Indian origin card game. The objective of this game is to make the best 3 card hand as per the hand ranking and to maximize the pot (prize pool) before the showdown for you to win. A standard 52-card pack (without the jokers) is used in this game.
Online card games like Rummy,TeenPatti are huge in India,attracting numerous masses and involving real money. But there are many problems in this sector namely :-
Businesses in the gaming industry offer crypto casino customers who use cryptocurrencies as an alternative to fiat money or a solid solution as their principal payment method. Players actively wagering on the platform can do so without providing identifying documentation. Additionally, there aren’t many restrictions on new participants entering the market with cryptocurrency. As a result, new players in the lottery system are exempted from the regulations that apply to traditional lotteries.
By utilizing the transparency feature built into blockchain technology, participants of the DeFi lottery platforms can access open records and examine all the historical information of trades. If any cyber attack occurs, participants can use the transparency function of a DeFi lottery platform to track and analyze it.
Participants can use their cryptos to subscribe for the use of the Defi lottery systems. Players on the DeFi lottery platform won’t have to be confined to their national borders thanks to the crypto payment system, which enables them to participate in events regulated outside their own countries. Since cryptocurrencies make payments and redemptions cheaper, utilizing DeFi lottery sites is significantly less expensive than conventional lottery platforms
- Trail (three of a kind) : 3 cards of the same rank. AAA is the best hand in the game.
- Pure Sequence (Straight Flush): Three consecutive cards of the same suit.
- Sequence (Straight): Three consecutive cards not all in the same suit.
- Color (Flush): A flush of 3 cards in the same suit, with the highest card winning in the case of a draw.
- Pair (two of a kind): A pair of 2 cards of the same rank. In case of a draw, the highest-ranking 3rd card will denote the winner.
- High Card: When neither the dealer nor player has a pair, then the hand with the highest card wins.
For more detailed rules refer Deltin.
To get it up and running up for your machine :
- Set up the prerequisites
- Create a NEAR account on the testnet or the mainnet network .
- Best practice is to create a sub account for eg. game.teenpatti.testnet and deploy your smart contract to that by using the deploy script.
- Clone the project and cd into the folder.
Everywhere replace,
<accountId>
by your NEAR testnet account
<contract-account>
by the NEAR sub-account created where the game is deployed.
To start the game, run the following command, after successful compilation of the files it will start by asking for player details and once the details are filled all the details will be pushed on the NEAR blockchain.
cargo run --bin init
Now to further play game follow the actions given below.
To to find information about
- All registered players
- Total staked tokens in the game by all players (i.e the pot)
- Currently folded players
- Players currently in the game
Run
near view <contract-account> game_state
Output
View call: gaming.teen_patti2.testnet.game_state()
{
players: [
{
account_id: 'samay200.testnet',
hand: {
cards: [
{ card_type: 'J', suit: 'Heart', value: 11 },
{ card_type: '9', suit: 'Spade', value: 9 },
{ card_type: 'J', suit: 'Diamond', value: 11 }
]
},
name: 'Samay',
betting_amount: 80,
is_folded: false,
play_blind: false,
balance_amount: 420
},
{
account_id: 'harshrathi2511.testnet',
hand: {
cards: [
{ card_type: '8', suit: 'Spade', value: 8 },
{ card_type: 'Q', suit: 'Diamond', value: 12 },
{ card_type: '10', suit: 'Heart', value: 10 }
]
},
name: 'Harsh',
betting_amount: 0,
is_folded: true,
play_blind: false,
balance_amount: 500
},
{
account_id: 'teen_patti2.testnet',
hand: {
cards: [
{ card_type: '7', suit: 'Club', value: 7 },
{ card_type: '9', suit: 'Club', value: 9 },
{ card_type: '3', suit: 'Club', value: 3 }
]
},
name: 'TeenPatti',
betting_amount: 60,
is_folded: false,
play_blind: false,
balance_amount: 580
}
],
folded_players: [
{
account_id: 'harshrathi2511.testnet',
hand: {
cards: [
{ card_type: '8', suit: 'Spade', value: 8 },
{ card_type: 'Q', suit: 'Diamond', value: 12 },
{ card_type: '10', suit: 'Heart', value: 10 }
]
},
name: 'Harsh',
betting_amount: 0,
is_folded: true,
play_blind: false,
balance_amount: 500
}
],
tokens_staked: 140,
unfolded_players: [
{
account_id: 'samay200.testnet',
hand: {
cards: [
{ card_type: 'J', suit: 'Heart', value: 11 },
{ card_type: '9', suit: 'Spade', value: 9 },
{ card_type: 'J', suit: 'Diamond', value: 11 }
]
},
name: 'Samay',
betting_amount: 80,
is_folded: false,
play_blind: false,
balance_amount: 420
},
{
account_id: 'teen_patti2.testnet',
hand: {
cards: [
{ card_type: '7', suit: 'Club', value: 7 },
{ card_type: '9', suit: 'Club', value: 9 },
{ card_type: '3', suit: 'Club', value: 3 }
]
},
name: 'TeenPatti',
betting_amount: 60,
is_folded: false,
play_blind: false,
balance_amount: 580
}
]
}
There are 3 actions that a TeenPatti registered player can be done using the NEAR CLI, namely:
- RAISE - specify the raise amount,which should not be greater than the number of chips you have(i.e balance amount) in an argument provided to action to raise in the game
near call <contract-account> play
'{
"action": "Raise{"amount": 45.0}",
"account_id": <accountId>
}'
--accountId <accountId>
- FOLD - when your cards are not good enough ,its better of to fold them using the following command .
near call <contract-account> play
'{
"action": "Fold",
"account_id": <accountId>
}'
--accountId <accountId>
- SHOW - can only be called when 2 players are left in the game who have not yet folded their cards . After show the winner script runs and the winner is announced .
near call <contract-account> play
'{
"action": "Show",
"account_id": <accountId>
}'
--accountId <accountId>
Whenever the winner of game is found it is declared in the logs when either one of the 2 actions are performed :-
- Only one player is left with unfolded cards and rest of the players jave folded theirs
- When only 2 players remain with unfolded cards and a player calls "show" , then the winner is decided upon the hierarchy of their cards
All the tokens staked in the game is then transferred to the winner instantly !(under development)
Made with 💖 by Web3 enthusiasts, Samay Gandhi and Harsh Rathi