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

@webfans/supercell

v0.1.22

Published

# @webfans/supercell

Downloads

18

Readme

clientsdk

@webfans/supercell

安装与引入

npm install @nomiclabs/hardhat-ethers 或者yarn add @nomiclabs/hardhat-ethers
npm install @webfans/supercell 或者 yarn add @webfans/supercell
import SDK,{conNames,fromWei,toWei} from '@webfans/supercell'
import SDK,{conNames,fromWei,toWei} from 'SuperCell.es.js'

使用说明 1 初始化 Web3Provider

import { ethers,providers } from 'ethers'
let lib = new providers.Web3Provider(window.ethereum as any)
let chainID = 31337

1.1 非网页环境,但是有私钥

根据私钥生成钱包,然后用钱包创建sdk
let Wallet = new  ethers.Wallet("38*****私钥"
 ,new ethers.providers.JsonRpcProvider("https://data-seed-prebsc-1-s3.binance.org:8545"))
let sdk = new SDK(Wallet,chainID)

2 初始化sdk 设置账户和合约地址

let accounts = await window.ethereum.enable();
    console.log(accounts)
    account=accounts[0]
  let sdk = new SDK(lib,chainID)
  sdk.setAccount(account)
  //可选 用于合约地址更新
  sdk.setAddressConfig({"Cell": "0x70e0bA845a1A0F2DA3359C97E0285013525FFC49",
                      "SCT": "0x4826533B4897376654Bb4d4AD88B7faFD0C98528",
                      "USDT": "0x99bbA657f2BbC93c02D617f8bA121cB8Fc104Acf",
                      "BUSD": "0x0E801D84Fa97b50751Dbf25036d067dCf18858bF",
                      "ETH": "0x8f86403A4DE0BB5791fa46B8e795C547942fE4Cf",
                      "Oracle": "0x9d4454B023096f34B160D6B654540c56A1F81688",
                      "Nucleus": "0x5eb3Bc0a489C5A8288765d2336659EbCA68FCd00"})

3 一些常用方法

   //读区usdt 余额
   let num = await sdk.getUSDTContract().getBalance()
   console.log(num)
   //检查usdt 是否给合约授权
   let haveAllonce = await sdk.getUSDTContract().allowanceNucleus()
   if(haveAllonce==false){
       //使用usdt给合约授权
    let tx = await sdk.getUSDTContract().approveNucleus()
   }
   //获取购买token 需要的usdt数量
   let sctneedusdt = await sdk.getNucleusContract().getBuySctNeedUsdt(conNames.USDT,"100")
   console.log('sctneedusdt',sctneedusdt.toString())
   if(num.gte(sctneedusdt)){

   }
   //购买token
   let data = await sdk.getNucleusContract().claim(conNames.USDT,"1")

4 数字转化常用的方法

console.log(fromWei('1'))
console.log(toWei('1'))

5 铸造nft 相关的

使用cst 铸造 nft 需要进行授权检测
let haveallowanceProxy = await sdk.getSCTContract().allowanceProxy()

if(haveallowanceProxy==false){
     //使用CST token 对Proxy 进行授权
     await sdk.getSCTContract().approveProxy()
   }
//铸造的版本号
const STAGE1 = "1";
//铸造nft
let res = await sdk.getProxyContract().mint(STAGE1)

读区nft 相关

// 读区铸造nft 需要消耗的等价值的 cst 的usdt的数量
let needusdt = await sdk.getProxyContract().getStagePrices(STAGE1)
/////读区铸造nft 需要消耗的usdt的数量 将usdt数量转换为cst数量
let cstnum = await sdk.getMintUseCst(STAGE1)
console.log(' 换算后铸造需要消耗的cst',fromWei(cstnum.toString()))

// 读区账户上nft 的数量
let nftNum = await sdk.getCellContract().blanceOf()
// 获取账户 nft 的tokenid 的列表
let nftList = await sdk.getCellContract().listNft()
// 获取一个tokenid 的对应的token 的详细信息
let res2= await sdk.getCellContract().getTokenInfo(nftList[0].toString())
//读区账户 sct 的余额
let cst = await sdk.getSCTContract().getBlance()
//读区账户usdt 的余额
let myusdt = await sdk.getUSDTContract().getBlance()

只读模式

// 1创建 jsonrpc 接口
let readlib= new providers.JsonRpcProvider("https://data-seed-prebsc-1-s3.binance.org:8545")
//2 初始化sdk
let sdk = new SDK(readlib,chainID)
// 不要设置默认账户
// 生命力调用时候要传入的地址 
let account="***"
const STAGE1 = "1";
  //铸造1个nft 需要的usdt
  let needUsdt = await sdk.getProxyContract().getStagePrices(STAGE1)
  console.log('铸造1个nft 需要的usdt',fromWei(needUsdt.toString()))

   let num = await sdk.getUSDTContract().getBalance(account)
   console.log(num)
   let native = await sdk.getNativeTokenBalance(account)
   console.log('native',native)
   let nftNum = await sdk.getCellContract().blanceOf(account)
   console.log('nftNum',nftNum)
   let nftList = await sdk.getCellContract().listNft(account)
   console.log('nftList',nftList)
   let res2= await sdk.getCellContract().getTokenInfo(nftList[0].toString())
   console.log('token info',res2)
   let pointRecords = await sdk.getCellContract().getpointRecords(account)
   console.log('pointRecords',pointRecords)
   let cstnum = await sdk.getSCTContract().getBalance(account)
   console.log('cstnum',cstnum)
//预约
sdk.getCellContract().lock(tokenId,orderId)
//取消预约
sdk.getCellContract().unLock(tokenId)
//使用 一个nft
let ussnft = await sdk.getCellContract().use(tokenId)

Recommended IDE Setup

VSCode + Volar (and disable Vetur).

TypeScript

Customize configuration

See Vite Configuration Reference.

Project Setup

npm install

Compile and Hot-Reload for Development

npm run dev

Type-Check, Compile and Minify for Production

npm run build