1.0.2 • Published 5 months ago

@uptickjs/react-native-uptick-web3 v1.0.2

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
5 months ago

uptickChainAppReactNative

The React Native uptick web3 SDK is a web3 interaction tool specifically designed for the React Native programming language. It aims to greatly simplify the process for users to connect to your decentralized application (Dapp) and efficiently perform interaction operations with the blockchain.

With the help of this SDK, developers can easily complete multiple operations on NFTs, including but not limited to publishing contracts, creating assets, and transferring assets. Meanwhile, it also supports various innovative sales models, such as regular listing, preferential listing, and product card release, etc., fully meeting the needs of different business scenarios. Moreover, by using the uptick API service , the development process of Dapps will be further optimized and simplified. This API service provides complete functionality support for the whole process from NFT creation to marketplace sales, offering solid and powerful technical support for developers to build Dapps with rich features and excellent user experience, helping them stand out in the field of blockchain application development and quickly realize business value.

The SDK also integrates convenient third-party login features that support:

Email login: Use email verification code to securely log in Google Sign-in: Support one-click login with Google account Apple Login: Support iOS devices to quickly sign in with Apple ID

Before using the third-party login function, developers need to go to the Web3Auth official website before they can use the third-party login function in the SDK normally.

Installation of the SDK

To install with Yarn, run:

yarn add @uptickjs/react-native-uptick-web3

To install with NPM, run:

npm install @uptickjs/react-native-uptick-web3

Initialization of web3

Execute this before sending transactions using WEB3.

import {utils, getWeb3Instance} from './web3Util';
const web3 = getWeb3Instance();

The method for initializing web3:

const web3 = new Web3('https://json-rpc.uptick.network');

export const getWeb3Instance = () => {
  return web3;
};

export const setProvider = (provider: string) => {
  web3.setProvider(provider);
};

Introduction to Methods

Create a Wallet

import * as bip39 from 'bip39';
import {
  importWallet,
} from '@uptickjs/react-native-uptick-web3/src/web3Util';

  let mnemonic = bip39.generateMnemonic();
  const wallet = importWallet(mnemonic);

Import a Wallet

import * as bip39 from 'bip39';
import {
  validateMnemonic,
  importWallet,
} from '@uptickjs/react-native-uptick-web3/src/web3Util';

// Import wallet with mnemonic
      if (validateMnemonic(mnemonic.trimStart().trimEnd())) {
     const wallet = importWallet(mnemonic);
      }
// Import wallet with privatekey	  
	 const wallet = importWallet(privatekey);  

Third-party login initialization

import {
  initWeb3Auth,
  GoogleLogin,
  EmailLogin,
  AppleLogin,
} from '@uptickjs/react-native-uptick-web3/src/web3Util';

// init web3AuthObj
 let web3AuthObj = initWeb3Auth(
      resolvedRedirectUrl,
      clientId,
      appName,
      logoLight,
      logoDark,
    );
ParamsParameter typeParameter description
resolvedRedirectUrlString配置允许的域名和重定向地址
clientIdString项目clientId
appNameStringApp包名
logoLightStringlight模式项目logo
logoDarkStringdark模式项目logo

Email login

EmailLogin(email)
ParamsParameter typeParameter description
emailString邮箱地址

Returns results Params | Parameter type | Parameter description :---: | :---: | :---: privateKey | String | 钱包地址私钥 userInfo | Object | 用户基础信息

Google login

GoogleLogin()

Returns results Params | Parameter type | Parameter description :---: | :---: | :---: privateKey | String | 钱包地址私钥 userInfo | Object | 用户基础信息

Apple login

AppleLogin()

Returns results Params | Parameter type | Parameter description :---: | :---: | :---: privateKey | String | 钱包地址私钥 userInfo | Object | 用户基础信息

Convert between EVM Address and Uptick Address

uptickAddress2EVM(address)

evmAddress2UptickAddress(address)
ParamsParameter typeParameter description
addressString用户地址

Get Balance

 getBalance = (
  address: string,
  rpcUrl: string,
)
ParamsParameter typeParameter description
addressString用户地址
rpcUrlStringJsonRpcURL

Create a Contract

deploy()
  
ParamsParameter typeRequireParameter description
nftTypeStringtruenft类型
privateKeyStringtrueprivateKey
gasPriceNumbertruegasPrice
nameStringtrue合约名字
metadataUrlStringfalsemetadata信息
lazySignAddressStringfalse签名地址,用于mint资产时验证签名

Create Assets

mintNft()
ParamsParameter typeRequireParameter description
nftTypeStringtruenft类型
toAddressStringtrue接收地址
nftAddressStringnft合约地址
nftIdStringtruenftId
metaDataUrlStringtruemetadata信息
royaltyPercentageStringtrue分成比例
amountValueNumberfalse数量

Transfer Assets

NftTransfer()
ParamsParameter typeParameter description
fromString转出类型
toString接收地址
nftIdStringnftId
nftAddressStringnft合约地址
nftTypeStringnft类型
amountNumber转送数量

Regular Sales Listing of Assets

nftOnsale()
ParamsParameter typeParameter description
nftAddressStringnft合约地址
nftidStringnftid
priceArray上架价格
tokenAddressArray上架币种合约地址
amountstring上架数量
plateFromAddressstring销售合约地址
nftTypeStringnft类型
nftTokenIdsString多个NFTid

Preferential Sales Listing of Assets

couponOnSale()
ParamsParameter typeParameter description
nftAddressStringnft合约地址
nftidStringnftid
priceString上架价格
tokenAddressString上架币种合约地址
amountNumber上架数量
plateFromAddressstring销售合约地址
nftTypeStringnft类型
couponCodeString优惠码
reducedPriceNumber优惠价格

Auction Listing of Assets

createAuction()
ParamsParameter typeParameter description
nftTypeStringnft类型
nftAddressStringnft合约地址
nftidStringnftid
startTimeStampString拍卖开始时间
endTimeStampString拍卖结束时间
startBidString起拍价
fixPriceString一口价
ReserveBidString保底价
feeNumber手续费
amountNumber上架数量
payAddressString上架币种合约地址

Auction Bidding

auction_placeBid()
ParamsParameter typeParameter description
nftTypeStringnft类型
nftAddressStringnft合约地址
nftidStringnftid
fixPriceNumber竞拍价格
payAddressString支付币种合约地址
ownerString售卖者地址
fromAddressString竞拍者地址
marketAddressString销售合约地址

Remove Assets from Listing

offSale()
ParamsParameter typeParameter description
nftAddressStringnft合约地址
nftidStringnftid
sellerStringseller
plateFromAddressStringplateFromAddress
nftTypeStringnft类型
nftTokenIdsStringnftId列表

Withdraw from Auction

auction_end()
ParamsParameter typeParameter description
nftTypeStringnft类型
nftAddressStringnft合约地址
nftidStringnftid
ownerStringERC1155类型,需要上架者地址

Purchase Assets

NftPayOrder()
ParamsParameter typeParameter description
nftTypeStringnft类型
nftAddressStringnft合约地址
nftidStringnftid
toAddressString购买者地址
priceNumber购买价格
marketTypeString购买类型
couponCodeString优惠码,没有就填‘0’
couponLinkStringcouponLink,没有就填‘0’
payAddressString支付币种合约地址

Place an Offer

createOffer()
ParamsParameter typeParameter description
plateFromAddressStringplateFromAddress
nftTypeStringnft类型
offerNumberString出价号码(随机数)
nftAddressStringnft合约地址
nftidStringnftid
payAddressString支付币种合约地址
payAmountNumber出价金额
expiryString出价有效期

Cancel an Offer

cancelOffer()
ParamsParameter typeParameter description
plateFromAddressStringplateFromAddress
nftTypeStringnft类型
offerNumberString出价号码(随机数)

Accept an Offer

acceptOffer()
ParamsParameter typeParameter description
plateFromAddressString出价合约地址
nftTypeStringnft类型
offerNumberString出价号码(随机数)
nftAddressStringnft合约地址
nftidStringnftid

Query Cross-Chain Handling Fees

getFeeByChainID()
ParamsParameter typeParameter description
tokenIdsArraytokenid
chainIdNumber链chainid

Cross-Chain Transfer of Assets (supporting Uptick, Polygon, Arbitrum, BSC)

uptickToEVM()
ParamsParameter typeParameter description
tochainIdNumber目标链chainid
toAddressString接受地址
metadateStringmetadate信息
plateFromAddressString跨链合约地址

Problem Reporting

https://github.com/UptickNetwork/react-native-uptick-web3/issues