nftstarsdk
v1.0.5
Published
nftstarsdk
Downloads
8
Maintainers
Readme
NftStarSdk
nftstarsdk
使用方法
- Install nftstarsdk NPM package
npm install --save nftstarsdk
# OR
yarn add nftstarsdk
- Then you can add nftstarsdk to your Dapp as follows
import NftStarSdk from "nftstarsdk";
/**
*
* @param {option} SdkOption
*
*/
const option = {site:''}
const sdk = new NftStarSdk(option);
/**
* @description 监听链接状态
* @param {connect:string,callback:(status:string)=>void}
*/
sdk.on('connect',(status:string)=>{
switch (status) {
case 'connect':
console.log('已链接')
break;
case 'disconnect':
console.log('断开链接')
break;
default:
break;
}
})
/**
* @description 移出监听链接状态
* @param {connect:string,callback:()=>void}
*/
sdk.off('connect',()=>{})
/**
* @description 链接钱包
* @memberof NftStarSdk
* @returns {Promise<ConnectResult>}
*/
const result = await sdk.connectWallet()
/**
* @description 断开钱包
* @memberof NftStarSdk
*/
const result = await sdk.resetApp()
/**
* @param {(data:ResultData)=>void} callback 轮询结果回调 code 为0 成功,否则失败
* @param {number} total startCoin
* @memberof NftStarSdk
* @member {number} buyStartCoin
* @returns {Promise<TransactionResponse>}
*
*/
// 提交到链上初始状态
const tx = await sdk.buyStartCoin(1000,(data)=>{})
// 等待链上结果
const receipt = await tx.wait()