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

doubleup

v4.5.40

Published

SDK to integrate with doubleup contracts

Downloads

3,381

Readme

DoubleUp SDK

Installation

$ npm install doubleup

Initialization

JS

import { DoubleUpClient } from 'doubleup';

const suiClient = new SuiClient({ url: getFullnodeUrl("mainnet") });

...

const dbClient = new DoubleUpClient({
    coinflipPackageId: "",
    coinflipCorePackageId: "",
    dicePackageId: "",
    diceCorePackageId: "",
    limboPackageId: "",
    limboCorePackageId: "",
    origin=""
    partnerNftListId: "",
    plinkoPackageId: "",
    plinkoCorePackageId: "",
    plinkoVerifierId: "",
    rangeDicePackageId: "",
    rangeDiceCorePackageId: "",
    rpsPackageId: "",
    rpsCorePackageId: "",
    roulettePackageId="",
    rouletteCorePackageId=""
    suiClient
});

React

import { DoubleUpProvider } from 'doubleup';

// or use suiClient from @mysten provider
const suiClient = new SuiClient({ url: getFullnodeUrl("mainnet") });

...

<DoubleUpProvider
    coinflipPackageId=""
    coinflipCorePackageId=""
    dicePackageId=""
    diceCorePackageId=""
    limboPackageId=""
    limboCorePackageId=""
    origin=""
    partnerNftListId=""
    plinkoPackageId=""
    plinkoCorePackageId=""
    plinkoVerifierId=""
    rangeDicePackageId=""
    rangeDiceCorePackageId=""
    rpsPackageId=""
    rpsCorePackageId=""
    roulettePackageId=""
    rouletteCorePackageId=""
    suiClient={suiClient}
>
    <App />
</DoubleUpProvider>

Basic Usage

JS

const { ok: gameOk, err: gameErr, gameSeed, receipt } = dbClient.createCoinflip({
    ...
});

...

const tranactionResult = await signAndExecuteTransactionBlock({ ... });

...

const { ok: resultOk, err: resultErr, results } = await dbClient.getCoinflipResult({
    coinType,
    transactionResult
});

Partner NFTs

The following games are enabled for a reduced house edge for holders of selected NFT projects:

  • Range Dice
  • Rock, Paper, Scissors

When initializing the client, include the partnerNftListId option or prop.

Then, include partnerNftId in the call to the game. For example:

const dbClient = new DoubleUpClient({
    client: suiClient,
    partnerNftListId: "" // <<<<<<<<<<
});
...

const { ok: gameOk, err: gameErr, gameSeed } = createRangeDice({
    betType,
    coin,
    coinType,
    partnerNftId, // <<<<<<<<<<<<
    range,
    transaction: txb
});

If the player does not own the NFT passed in, then the call to the contract will fail.

Games

Coinflip

betType

| Value | Meaning | | ----- | ------- | | 0 | Heads | | 1 | Tails |

pollInterval (optional, default: 3000)

milliseconds

const betType = 0;

const [coin] = txb.splitCoins(
    txb.gas,
    txb.pure.u64(betAmount)
);

const coinType = "0x2::sui::SUI";

const { ok: gameOk, err: gameErr, gameSeed } = createCoinflip({
    betType,
    coin,
    coinType,
    transaction: txb
});

const transactionResult = await signAndExecuteTransactionBlock({ ... });

const { ok: resultOk, err: resultErr, results } = await getCoinflipResult({
    betType,
    coinType,
    gameSeed,
    transactionResult
});

Dice

NOTE: NOT CURRENTLY IMPLEMENTED

betType

| Value | Meaning | | ----- | ---------- | | 0 - 5 | Dice Rolls | | 6 | Odd | | 7 | Even | | 8 | Small | | 9 | Big |

pollInterval (optional, default: 3000)

milliseconds

const betType = 0;

const [coin] = txb.splitCoins(
    txb.gas,
    txb.pure.u64(betAmount)
);

const coinType = "0x2::sui::SUI";

const { ok: gameOk, err: gameErr, gameSeed } = createDice({
    betType,
    coin,
    coinType,
    transaction: txb
});

const transactionResult = await signAndExecuteTransactionBlock({ ... });

const { ok: resultOk, err: resultErr, results } = await getDiceResult({
    ???
});

Limbo

multiplier

1.01 - 100

pollInterval (optional, default: 3000)

milliseconds

const [coin] = txb.splitCoins(
    txb.gas,
    txb.pure.u64(betAmount)
);

const coinType = "0x2::sui::SUI";

const { ok: gameOk, err: gameErr, gameSeed } = createLimbo({
    coin,
    coinType,
    multiplier: 50,
    transaction: txb
});

const transactionResult = await signAndExecuteTransactionBlock({ ... });

const { ok: resultOk, err: resultErr, results } = await getLimboResult({
    coinType,
    gameSeed,
    transactionResult
});

Lottery

Buy Ticket

const address = '0x...';

const [coin] = txb.splitCoins(
    txb.gas,
    txb.pure(lottery.ticket_cost, "u64")
);

const tickets = [{
    numbers: [27, 15, 30, 7, 11],
    specialNumber: 2
}];

 const { ok, err } = buyLotteryTickets({
    address,
    coin,
    tickets,
    transaction: txb
});

Get Lottery

const { ok, err, result } = await getLottery();

Get Lottery History

const { ok, err, results } = await getLotteryHistory();

Get Lottery Result

const { ok, err, result } = await getLotteryDrawingResult({
    round: 8679412
});

Get Lottery Tickets

const { ok, err, results } = await getLotteryTickets({
    address: '0x...'
});

Redeem Lottery Tickets

const ticketIds = [
    '0x...',
    '0x...'
];

const { ok, err, results } = await redeemLotteryTickets({
    ticketIds
});

Plinko

numberOfDiscs

1 - 100

plinkoType

| Value | Meaning | | ----- | ------- | | 0 | 6 Rows | | 1 | 9 Rows | | 2 | 12 Rows |

pollInterval (optional, default: 3000)

milliseconds

const [coin] = txb.splitCoins(
    txb.gas,
    txb.pure(betAmount * numberOfDiscs, "u64")
);

const coinType = "0x2::sui::SUI";

const { ok: gameOk, err: gameErr, gameSeed } = createPlinko({
    betAmount,
    coin,
    coinType,
    numberOfDiscs: 50,
    plinkoType: 1,
    transaction: txb
});

const transactionResult = await signAndExecuteTransactionBlock({ ... });

const { ok: resultOk, err: resultErr, results } = await getPlinkoResult({
    coinType,
    gameSeed,
    transactionResult
});

Range Dice

** If over/under, range must be a number. ** ** If inside/outside, range must be an array of two numbers. **

range

1 - 100

OR

[1 - 100, 1 - 100]

betType

| Value | Meaning | | ----- | ------- | | 0 | Over | | 1 | Under | | 2 | Inside | | 3 | Outside |

pollInterval (optional, default: 3000)

milliseconds

const [coin] = txb.splitCoins(
    txb.gas,
    txb.pure(betAmount * numberOfDiscs, "u64")
);

const coinType = "0x2::sui::SUI";

// EXAMPLE: over
const betType = 0;
const range = 25;

// EXAMPLE: inside
const betType = 2;
const range = [25, 50];

const { ok: gameOk, err: gameErr, gameSeed } = createRangeDice({
    betType,
    coin,
    coinType,
    range,
    transaction: txb
});

const transactionResult = await signAndExecuteTransactionBlock({ ... });

const { ok: resultOk, err: resultErr, results } = await getRangeDiceResult({
    betType,
    coinType,
    gameSeed,
    transactionResult
});

Roulette

Create Table

const coinType = "0x2::sui::SUI";

const { ok, err } = createRouletteTable({
    coinType,
    transaction: txb
});

Table Existence

const address = "0x...";
const coinType = "0x2::sui::SUI";

const { ok, err, tableExists } = await doesRouletteTableExist({
    address,
    coinType
});

Add Bet to Table

betType

| Value | Meaning | | ----- | ---------------------- | | 0 | Red | | 1 | Black | | 2 | Number | | 3 | Even | | 4 | Odd | | 5 | 1st 12 (1 - 12) | | 6 | 2nd 12 (13 - 24) | | 7 | 3rd 12 (25 - 36) | | 8 | 1st 18 (1 - 18) | | 9 | 2nd 18 (19 - 36) | | 10 | 1st Row (1, 4, 7, ...) | | 11 | 2nd Row (2, 5, 8, ...) | | 12 | 3rd Row (3, 6, 9, ...) |

const coinType = "0x2::sui::SUI";
const tableOwner = "0x...";

const [coin] = txb.splitCoins(
    txb.gas,
    txb.pure.u64(betAmount)
);

// red
const betType = 0;

const { ok, err, betId } = addRouletteBet({
    address: tableOwner,
    betType,
    coin,
    coinType,
    transaction: txb
});

// bet on 15
const betType = 2;
const betNumber = 15;

const { ok, err, betId } = addRouletteBet({
    address: tableOwner,
    betNumber,
    betType,
    coin,
    coinType,
    transaction: txb
});

Remove Bet from Table

const coinType = "0x2::sui::SUI";

const self = "0x...";
const tableOwner = "0x...";

const { ok, err, results } = await removeRouletteBet({
    betId,
    coinType,
    player: self,
    tableOwner,
    transaction
});

Start Roll on your Table

const coinType = "0x2::sui::SUI";

const { ok: startOk, err: startErr, gameSeed } = startRoulette({
    coinType,
    transaction: txb
});

const transactionResult = await signAndExecuteTransactionBlock({ ... });

// Get the current round number of the object
const { roundNumber } = await doesRouletteTableExist({
    address,
    coinType: SUI_COIN_TYPE
});

const { ok: resultOk, err: resultErr, results } = await getRouletteResult({
    coinType,
    gameSeed,
    transactionResult,
    roundNumber
});