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 🙏

© 2025 – Pkg Stats / Ryan Hefner

crazydice-sdk

v1.0.5

Published

## Intro

Readme

CrazyDice Gaming SDK

Intro

CrazyDice Gaming SDK is toolkit provided by Crazy Dice Metaverse.

Install

npm install crazydice-sdk

Usage

  • Demo

  • 中文使用文档

    错误处理:code 码目前仅 0400, 0代表正常,400代表错误,错误信息会通过message返回

    • Step 1: 安装并导入SDK
    • Step 2: 登录,确保用户已经连接钱包并选择网络,可以通过getAccount获取账户信息,如果isConnected == true 则已连接,否则需要调用openLogin让用户连接钱包
    • Step 3: 选择角色,调用getGameCharacter会弹出窗口让用户选择角色,用户选择角色后会返回角色信息,否则返回code==400 需要重新让用户选择角色
    • Step 4: 获取到角色信息后,将角色ID作为唯一标识绑定游戏数据,并且将角色的基础属性附加到游戏中,注意:百分比加成是最终百分比加成,固定加成是直接加在角色属性上
    • Step 5: 广告需要调用openAD,需要传参数:广告类型,目前仅支持reward(激励广告),会有用户操作相应返回值
    • Step 6: 支付功能,调用buyProduct,传入支付金额即可,会调起钱包支付,成功将会返回一个交易hash,代表付款成功
  • English Usage Document

    Error Handling: The current code values are only 0 and 400. 0 represents normal operation, and 400 represents an error. Error messages will be returned via message.

    • Step 1: Install and import the SDK
    • Step 2: Log in. Ensure the user has connected their wallet and selected a network. You can get account information via getAccount. If isConnected == true, the user is connected. Otherwise, you need to call openLogin to prompt the user to connect their wallet.
    • Step 3: Select a character. Calling getGameCharacter will display a window for the user to select a character. If a character is selected, the character information will be returned; otherwise, code == 400 will be returned, and the user will need to select a character again.
    • Step 4: After obtaining the character information, bind the game data using the character ID as a unique identifier and add the character’s basic attributes to the game. Note: Percentage bonuses are final percentage bonuses, while fixed bonuses are directly added to the character's attributes.
    • Step 5: For advertisements, call openAD and pass in the parameter: ad type. Currently, only reward ads (incentive ads) are supported. There will be corresponding return values based on user actions.
    • Step 6: For the payment function, call buyProduct and pass in the payment amount. This will trigger wallet payment. A transaction hash will be returned upon successful payment, indicating the payment was successful.

Init

import { CrazyDiceSDKConfig, CrazyDiceSDK } from 'crazydice-sdk'

const config: CrazyDiceSDKConfig = {
    appId: BigInt(1000000),
    name: 'GameName',
    logo: '',
    gameLink: 'https://game.domain',
    version: '1.0.0',
    env: 'sandbox', // 'sandbox' | 'production'
  }

  const sdk = new CrazyDiceSDK(config)

API

  • openLogin

    Open the wallet connection

    const resp = await sdk.openLogin()
    // -----------------------------------------------
    // Refuse to buy Resp Example:
    // 
    // {
    //     "id": "452363267331981312_GetAccount",
    //     "payload": {
    //         "code": 400,
    //         "msg": "reason",
    //     }
    // }
  • getAccount

    Get Account info

    const resp = await sdk.getAccount()
    // No wallet connected Resp Example:
    // 
    // {
    //     "id": "452367020219039744_GetAccount",
    //     "payload": {
    //         "code": 0,
    //         "msg": "ok",
    //         "data": {
    //             "isConnected": false,
    //             "isConnecting": false,
    //             "isDisconnected": true,
    //             "isReconnecting": false,
    //             "status": "disconnected"
    //         }
    //     }
    // }
    // -------------------------------------------------
    // Connected wallet Resp Example:
    // 
    // {
    //     "id": "452363267331981312_GetAccount",
    //     "payload": {
    //         "code": 0,
    //         "msg": "ok",
    //         "data": {
    //             "address": "0xd0f4C437bAb98404e911Cf5042800DCb157fb53f", // user wallet address
    //             "addresses": [
    //                 "0xd0f4C437bAb98404e911Cf5042800DCb157fb53f"
    //             ],
    //             "chain": {
    //                 "id": 57000,
    //                 "name": "Rollux Testnet",
    //                 "nativeCurrency": {
    //                     "decimals": 18,
    //                     "name": "Syscoin",
    //                     "symbol": "SYS"
    //                 },
    //                 "rpcUrls": {
    //                     "default": {
    //                         "http": [
    //                             "https://rpc-tanenbaum.rollux.com/"
    //                         ],
    //                         "webSocket": [
    //                             "wss://rpc-tanenbaum.rollux.com/wss"
    //                         ]
    //                     }
    //                 },
    //                 "blockExplorers": {
    //                     "default": {
    //                         "name": "RolluxTestnetExplorer",
    //                         "url": "https://rollux.tanenbaum.io",
    //                         "apiUrl": "https://rollux.tanenbaum.io/api"
    //                     }
    //                 },
    //                 "contracts": {
    //                     "multicall3": {
    //                         "address": "0xcA11bde05977b3631167028862bE2a173976CA11",
    //                         "blockCreated": 1813675
    //                     }
    //                 }
    //             },
    //             "chainId": 57000,
    //             "connector": {
    //                 "name": "MetaMask",
    //                 "id": "io.metamask",
    //                 "type": "injected",
    //                 "uid": "d1381ea8b19"
    //             },
    //             "isConnected": true,
    //             "isConnecting": false,
    //             "isDisconnected": false,
    //             "isReconnecting": true,
    //             "status": "reconnecting"
    //         }
    //     }
    // }
  • getBalance

    Get Balance

    const resp = await sdk.getBalance()
    // Get Balance Resp Example:
    // 
    // {
    //     "id": "452363267331981312_GetAccount",
    //     "payload": {
    //         "code": 0,
    //         "msg": "ok",
    //         "data": {
    //              decimals: 18
    //              formatted: "1.022196946825351073"
    //              symbol: "SYS" 
    //              value: 1022196946825351073n
    //          }
    //     }
    // }
  • openAD

    Get AD

    const resp = await sdk.openAD('reward') // 'preroll' | 'start' | 'pause' | 'next' | 'browse' | 'reward'
    // Currently only supports rewarded ads
  • openCrazyDice

    Open Crazy Dice Window

    const resp = await sdk.openCrazyDice("{charaterTokenId}")
    // Open CrazyDice window
  • buyProduct

    Buy Product Payment

    const resp = await sdk.buyProduct('0.01')
    // Buy Success Resp Example:
    // 
    // {
    //     "id": "452363267331981312_GetAccount",
    //     "payload": {
    //         "code": 0,
    //         "msg": "ok",
    //         "data": {
    //              hash: "0x....."
    //          }
    //     }
    // }
  • getGameCharacter

    get game character info

    const resp = await sdk.getGameCharacter()
    // Get Game Character Resp Example:
    // 
    // {
    //     "id": "456045418183262208_GetGameCharacter",
    //     "payload": {
    //         "code": 0,
    //         "msg": "ok",
    //         "data": {
    //             "charcaterId": "57000_0x5401224da27a98133862f653b6ee804d61cf8596_1", // Unique ID for each character
    //             "attrs": [ // Different slots have different attribute bonuses. Please refer to the slot attribute comparison table.
    //                 {
    //                     "slotId": "10003",
    //                     "isPercent": false,
    //                     "name": "HP HEAL",
    //                     "value": "7"
    //                 },
    //                 {
    //                     "slotId": "10004",
    //                     "isPercent": true,
    //                     "name": "SPD",
    //                     "value": "1"
    //                 },
    //                 {
    //                     "slotId": "10006",
    //                     "isPercent": true,
    //                     "name": "C.DMG",
    //                     "value": "1"
    //                 },
    //                 {
    //                     "slotId": "100000",
    //                     "isPercent": true,
    //                     "name": "ATK",
    //                     "value": "0.01"
    //                 },
    //                 {
    //                     "slotId": "10001",
    //                     "isPercent": false,
    //                     "name": "ATK",
    //                     "value": "10"
    //                 },
    //                 {
    //                     "slotId": "10002",
    //                     "isPercent": false,
    //                     "name": "HP",
    //                     "value": "100"
    //                 }
    //             ],
    //             "slotToImage": {  // Pictures showing different slot positions
    //                 "10": "1",
    //                 "20": "1",
    //                 "30": "1",
    //                 "40": "1",
    //                 "50": "1",
    //                 "60": "1"
    //             }
    //         }
    //     }
    // }

Data comparison table

Slot Attributes

  • HeartOfTheBrave

    | SlotId | Attribute | | ---------- | ------------- | | 100000 | HP HEAL | | 200000 | HP | | 300000 | SPD | | 400000 | ATK | | 500000 | C.DMG | | 600000 | CRIT | | 10001 | HP | | 10002 | HP HEAL | | 10003 | SPD | | 10004 | ATK | | 10005 | C.DMG | | 10006 | CRIT | | 10 | LeftLeg | | 20 | RightLeg | | 30 | LeftHand | | 40 | Body | | 50 | RightHand | | 60 | Head |