4.8.4 • Published 5 months ago

doubleup v4.8.4

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

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

ValueMeaning
0Heads
1Tails

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

ValueMeaning
0 - 5Dice Rolls
6Odd
7Even
8Small
9Big

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

ValueMeaning
06 Rows
19 Rows
212 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

ValueMeaning
0Over
1Under
2Inside
3Outside

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

ValueMeaning
0Red
1Black
2Number
3Even
4Odd
51st 12 (1 - 12)
62nd 12 (13 - 24)
73rd 12 (25 - 36)
81st 18 (1 - 18)
92nd 18 (19 - 36)
101st Row (1, 4, 7, ...)
112nd Row (2, 5, 8, ...)
123rd 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
});
4.8.4

5 months ago

4.8.3

5 months ago

4.8.2

5 months ago

4.8.1

5 months ago

4.8.0

5 months ago

4.7.4

5 months ago

4.7.3

6 months ago

4.7.2

6 months ago

4.7.1

6 months ago

4.6.5

6 months ago

4.6.4

6 months ago

4.6.1

6 months ago

4.6.3

6 months ago

4.6.2

6 months ago

4.5.50

7 months ago

4.5.51

7 months ago

4.5.47

7 months ago

4.5.48

7 months ago

4.5.45

7 months ago

4.5.46

7 months ago

4.5.49

7 months ago

4.5.36

7 months ago

4.5.37

7 months ago

4.5.35

7 months ago

4.5.38

7 months ago

4.5.39

7 months ago

4.5.40

7 months ago

4.5.43

7 months ago

4.5.44

7 months ago

4.5.41

7 months ago

4.5.42

7 months ago

4.5.10

7 months ago

4.5.11

7 months ago

4.5.15

7 months ago

4.5.12

7 months ago

4.5.13

7 months ago

4.5.18

7 months ago

4.5.19

7 months ago

4.5.16

7 months ago

4.5.17

7 months ago

4.5.32

7 months ago

4.5.33

7 months ago

4.5.30

7 months ago

4.5.31

7 months ago

4.5.34

7 months ago

4.5.21

7 months ago

4.5.20

7 months ago

4.5.25

7 months ago

4.5.26

7 months ago

4.5.24

7 months ago

4.5.29

7 months ago

4.5.27

7 months ago

4.5.28

7 months ago

4.4.10

8 months ago

4.4.14

8 months ago

4.4.13

8 months ago

4.4.12

8 months ago

4.4.11

8 months ago

4.4.16

8 months ago

4.4.15

8 months ago

4.4.9

8 months ago

4.4.8

8 months ago

4.4.5

8 months ago

4.4.7

8 months ago

4.4.6

8 months ago

4.4.41

8 months ago

4.4.1

8 months ago

4.4.0

8 months ago

4.4.3

8 months ago

4.4.2

8 months ago

4.4.4

8 months ago

4.3.24

8 months ago

4.3.25

8 months ago

4.3.23

9 months ago

4.3.22

9 months ago

4.3.21

9 months ago

4.3.17

9 months ago

4.3.19

9 months ago

4.3.18

9 months ago

4.3.20

9 months ago

4.3.16

9 months ago

4.3.9

9 months ago

4.3.6

9 months ago

4.3.5

9 months ago

4.3.8

9 months ago

4.3.7

9 months ago

2.0.5

11 months ago

2.0.4

11 months ago

4.3.13

9 months ago

2.0.7

11 months ago

4.3.12

9 months ago

2.0.6

11 months ago

4.3.11

9 months ago

2.0.9

11 months ago

4.3.10

9 months ago

2.0.8

11 months ago

4.3.15

9 months ago

4.3.14

9 months ago

3.0.12

10 months ago

3.0.4

10 months ago

3.0.13

10 months ago

3.0.3

10 months ago

3.0.10

10 months ago

3.0.2

10 months ago

3.0.11

10 months ago

3.0.1

10 months ago

3.0.8

10 months ago

3.0.7

10 months ago

3.0.14

10 months ago

3.0.6

10 months ago

3.0.15

10 months ago

3.0.5

10 months ago

4.2.3

10 months ago

4.2.2

10 months ago

4.2.5

10 months ago

4.2.4

10 months ago

4.0.1

10 months ago

4.2.1

10 months ago

4.0.3

10 months ago

4.2.0

10 months ago

4.0.2

10 months ago

4.2.7

10 months ago

4.2.6

10 months ago

4.2.9

10 months ago

4.2.8

10 months ago

2.0.13

10 months ago

2.0.11

11 months ago

2.0.12

10 months ago

2.0.10

11 months ago

3.0.9

10 months ago

4.3.2

9 months ago

4.1.4

10 months ago

4.3.1

9 months ago

4.2.10

10 months ago

4.1.3

10 months ago

4.3.4

9 months ago

4.2.11

10 months ago

4.3.3

9 months ago

4.1.0

10 months ago

4.3.0

10 months ago

4.1.2

10 months ago

4.1.1

10 months ago

2.0.3

11 months ago

2.0.1

11 months ago

3.0.0

11 months ago

2.0.0

11 months ago

1.2.1

12 months ago

1.2.0

12 months ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.1

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago