npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pandoragames

v1.0.8

Published

Provably fair games by Pandora games

Downloads

18

Readme

Installing

Using npm:

$ npm install pandoragames

Integration data provided by Game Aggregator

  1. Merchant ID
  2. Merchant Key
  3. Base API URL

Please, contact on mailto:[email protected]

Integrator's transaction structure

transaction = {
	action, //(string) ex: "bet", "win", "refund"
	amount, //(number) ex: 34.12345678
	currency, //(string) ex: "btc", "eth"...
	game_uuid, //(string) ex: "dice", "plinko"...
	player_id, //(string)
	session_id, //(string) ex: "eb20dd0a-de8e-42cf-98da-f3ddaa409502"
	transaction_id, //(string) pandora's provided transaction id, ex: "5f5757d79a5173055449d5dc"
	left_balance, //(number) ex 43.12345678
	bet_transaction_id, //(string) sent only when action is "win" or "refund", ex: "5f5757d79a5173055449d5dc"
};

Example

const pg = require("pandoragames");

/*
	pandoragames module setup
*/
pg.setup(/*merchant_id*/, /*merchant_key*/, /*aggregator_url*/);

/*
	create route listener on "/gamesApi"
*/
YOUR_ROUTER.post("/gamesApi", pg.onRemoteCall);

/*
	Start game
*/
pg.gameStart(
	"your_unique_id" /*session_id*/,
	"dice" /*game_uuid*/,
	"player123" /*player_id*/,
	"player123" /*player_name*/,
	"btc" /*currency*/,
	"en" /*language*/,
	false /*demo*/,
	false /*validate*/
).then((result)=>{
	//navigate to result.url to open requested game
});

/*
	Get player's balance
*/
pg.setOnBalanceGet(async (player_id, currency, session_id) => {
	const balance = ...//get balance...

	if (/*error happened while checking balance*/) return { error: true };

	return { balance };
});


/*
	Change balance by provided delta (can also be negative or zero) and store transaction into your database
*/
pg.setOnCreateTransaction(async (action, amount, currency, game_uuid, player_id, session_id, transaction_id, bet_transaction_id, delta) => {
	const balance = ...; //get balance...

	if (/*error happened while checking balance*/) return { error: true };

	const left_balance = balance + delta; //left balance after applying delta

	if (action === "bet" && left_balance < 0 /*not enough funds*/) return { balance_changed: false }

	//change balance, store transaction (you must also store "left_balance" inside transaction!)

	if (/*error happened while changing or storing (reverted all operations)*/) return { error: true }

	return {
		balance_changed: true,
		left_balance,
		transaction_id /*your system generated unique id while storing transaction*/,
	};
});

/*
	Search transaction in your database by querying with the provided selector
	selector format while "bet"/"win": {transaction_id: "5f575aec5e9bb04170304e77"}
	selector format while "refund": {bet_transaction_id: "5f575aec5e9bb04170304e77"}
*/
pg.setOnGetTransactionData(async (selector) => {
	/*make search transaction...*/

	if (/*encountered error while searching*/) return { error: true };

	if (/*transaction does not exist*/) return { transaction_id: null };

	return {
		left_balance /*post balance stored inside transaction*/,
		transaction_id /*your system generated unique id while storing transaction*/,
		amount /*amount stored inside transaction*/
	};
});

/*
	Contest finished event
*/
pg.setOnStoreContest(async (contest_id, winners, percentages, amount) => {
	/*
		contest_id: "5e8c65951c96592ff1b5a89e"
		winners: [
			{
				position: 1,
				player_id: "user234"
				vendor: "client1",
				wager: 12.00000271,
				bet_count: 1854,
				won_amount: 500.00000000
			},
			...
		]
		percentages: [50,25,25]
		amount: 1000.00000000
	*/
	//logic on awarding winners...
	if (/*encountered error while processing contest results*/) return { error: true };
	return { error: false };
});


/*
	Get list of games
*/
pg.getGames().then(array => {
	/*
		[
			{
				name: "sicbo",
				active: true,
				image: "https://res.cloudinary.com/dez0s9s32/image/upload/v1576414996/pandora/games/sicbo/sicbo_320x240.png",
				release_date: 1594152000000,
				is_mobile: true,
				is_desktop: true,
				game_type: "board",
			},
			...
		]
	*/
});

/*
	Get contest's leader board. Leader board is cached on the aggregator's side and is updated every 1 minute.
*/
pg.getLeaderboard(contest_id).then(array =>{
	/*
		[
			{
				position: 1,
				player_id: "user234",
				shared: false,
				wager: 123.12345678,
				bet_count: 3027
			},
			...
		]
	*/
});

/*
	Get player's position in specified leader board
*/
pg.getLeaderboardPosition(player_id, contest_id).then(data => {
	/*
		{
			position: 1,
			player_id: "user234",
			wager: 123.12345678,
			bet_count: 3027
		}
	*/
});

/*
	Get the list of the contests
*/
pg.getContests().then(data => {
	/*
		{
			server_time: 1600676640839,
			expired: [
				contest_id: "5e8c65951c96592ff1b5a89e",
				name: "New Year BTC, ETH Contest",
				description: "Play and win",
				image0: "https://...",
				image1: null,
				image2: null,
				url: "https://...",
				amount: 5000,
				currencies: ["btc", "eth"],
				time_from: 1600670000000,
				time_to: 1600670100000,
				games: ["sicbo", "dice"],
				percentages: [ 12.50, 11.67, 10.83, 10.00, 9.17, 8.33, 7.50, 6.67, 5.83, 5.00, 4.17, 3.33, 2.50, 1.67, 0.83 ],
				t: 1600676640839,
				winners: [
					{
						position: 1,
						player_id: "user234",
						shared: false,
						wager: 98.12345678,
						bet_count: 348,
						won_amount: 625
					}
					...
				]
			],
			active: [
				...
			],
			pending: [
				...
			]
		}
	*/
});