1.0.6 • Published 6 months ago

@uptickjs/uptick-web3-sdk v1.0.6

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

uptick-web3-sdk

Essential Web3 functions rolled into a single package

Uptick Web3 SDK is a core element of these services. It consolidates essential Web3 functions into a single package, enabling developers to efficiently create business-specific applications using Uptick infrastructure. This approach allows developers to focus on business logic without needing to manage general-purpose modules or possess deep blockchain expertise.

Supports Vue Development Framework with React Native SDK coming soon

Uptick Web3 SDK is a JavaScript SDK that currently supports the Vue development framework. React and React Native developers can refer to the contract files and calling methods within the SDK to assemble the signature manually. The React Native version of the SDK will be launched soon. SDKs for other programming languages are also in development, so stay tuned.

What Can Developers Do with the Uptick Web3 SDK?

The Uptick Web3 SDK is a powerful tool for Vue projects, simplifying user connections to decentralized applications (DApps) and streamlining blockchain interactions. It supports both MetaMask and WalletConnect logins, making it ideal for applications that require user authentication and blockchain transactions.

This enables traditional businesses to integrate smoothly with Web3, and combines essential blockchain operations all into one package. The SDK saves time and resources, and empowers developers to build applications that integrate business logic without unnecessary complexity.

The SDK offers a range of NFT and RWA operations, including:

  • Deploying smart contracts
  • Minting NFTs/RWAs
  • Transferring assets
  • Supporting multiple sales modes, such as fixed-price listings, discounted sales, timed auctions, and lazy mints

These features allow developers to create decentralized wallets, launch NFT/RWA trading markets with a wide range of sales models, build membership systems, and engage with the evolving RWA ecosystem.

What's next?

This SDK release marks the first step in making Uptick’s full range of services available to developers.

Next, we’ll deliver Uptick Services via cloud APIs, rolling out the service layer through iterative releases to simplify Web3 business application development for traditional developers.

Installing the SDK

To install with Yarn, run:

yarn add @uptickjs/uptick-web3-sdk

To install with NPM, run:

npm install @uptickjs/uptick-web3-sdk

Initialize SDK

Initialize SDK in the project entry file app.js

import { init as metaMaskInit } from '@uptickjs/uptick-web3-sdk/src/index';

let chainId=process.env.VUE_APP_ADD_NETWORK_CHAIN_ID;

let rpc=process.env.VUE_APP_ADD_NETWORK_CHAIN_UPC_URL;


let wallet=metaMaskInit(rpc,chainId)
Vue.prototype.$wallet = wallet.wallet;

Initialize walletConnect

import { EthereumProvider } from "@walletconnect/ethereum-provider";
import { ethers } from "ethers";

export async function initProvider(){
		 const provider = await EthereumProvider.init({
		   projectId,
		   optionalChains: [chainIdInt], //current chainId
		   metadata: {
		       name: 'UptickNFT',
		       description: 'Build your NFT world on Uptick',
		       url: gethost(), // origin must match your domain & subdomain
		       icons: ['https://uptick.upticknft.com/logo.jpg']
		     },
		   optionalMethods: ["eth_sendTransaction",
		                  "personal_sign",
		                  "eth_estimateGas",
		                  
                            "eth_signTypedData"],
		   showQrModal: true,
		   qrModalOptions: {
		     themeMode: "light",
		   },

           rpcMap: {
            117:uptickUrl,
        
          }
		 });
		 provider.chainId=chainIdInt;
		const WalletProvider = new ethers.providers.Web3Provider(provider)
		  provider.on("display_uri", (uri) => {
		   		    events.$emit('wallet_is_connect',uri)
		  });
		  // chain changed
		  provider.on('chainChanged', (result) => {
		   
		  });
		  // accounts changed
		  provider.on('accountsChanged', (accounts) => {
		    
                
		  });
		  // session established
		  provider.on('connect', (result) => {
		  let walletparams = {
            connected:true
          }
              localStorage.setItem("walletconnect",JSON.stringify(walletparams) );
		   
		  });
		  
		  provider.on('session_event', (result) => {
		    		  });
		  provider.on('disconnect',(result) => {
		  		  });
		
		  window.walletProvider=provider;
		  return provider;
		 
	 }
	 

Method introduction

Get user information, get the currently linked wallet address

getAccountInfo()

Convert Evm address to Uptick address

getUptickAddress()
ParamsParameter typeParameter description
evmAddressStringUser address

Get balance

getTokenBalance()
ParamsParameter typeParameter description
ownerStringUser address

Create a contract

deploy()
ParamsParameter typeRequireParameter description
nftTypeStringtruenft type
nameStringtruecontract name
metadataUrlStringfalsemetadata information
lazySignAddressStringfalsesignature address, used to verify signature when minting assets

Mint NFTs

mintNft()
ParamsParameter typeRequireParameter description
nftTypeStringtruenft type
toAddressStringtruereceiving address
nftIdStringtruenftId
metaDataUrlStringtruemetadata information
royaltyPercentageStringtrueShare ratio
amountValueNumberfalseQuantity

Lazy mint NFTs

lazyNftMint()
ParamsParameter typeRequireParameter description
toAddressStringtrueReceiving address
nftIdStringtruenftId
metaDataUrlStringtrueMetadata information
payAddressStringtruePayment address of token contract
payAmountNumbertruePayment amount
creatorFeeNumbertruePayment fee
signatureStringtrueSignature information

Set the contract address

setContractAddress()
ParamsParameter typeParameter description
nftTypeStringnft type
platformAddressStringtransaction contract address

NFT Transfer

transferFrom()
ParamsParameter typeParameter description
nftTypeStringnft type
toAddressStringreceiving address
nftIdStringnftId
amountValueNumbertransfer amount

NFT Listing

onSale()
ParamsParameter typeParameter description
nftTypeStringnft type
nftAddressStringnft contract address
nftidStringnftid
valueStringListing price
feeNumberHandling fee
amountNumberListing quantity
payAddressStringThe token contract address for selling your NFT

NFT Listing in Batches

onSaleBatch()
ParamsParameter typeParameter description
nftTypeStringnft type
nftAddressStringnft contract address
nftidsArraynftid
valueArrayListing price
feeNumberHandling fee
amountsArrayListing quantity
payAddressArrayThe token contract address for selling your NFT

Discounted Sales

couponOnSale()
ParamsParameter typeParameter description
nftTypeStringnft type
nftAddressStringnft contract address
nftidStringnftid
valueStringListing price
couponCodeStringDiscount code
reducedPriceNumberDiscount price
feeNumberHandling fee
amountNumberListing quantity
payAddressStringThe token contract address for selling your NFT

Timed-auction

auction_onsale()
ParamsParameter typeParameter description
nftTypeStringnft type
nftAddressStringnft contract address
nftidStringnftid
startTimeStampStringauction start time
endTimeStampStringauction end time
startBidStringstarting price
fixPriceStringfixed price
ReserveBidStringreserve price
feeNumberhandling fee
amountNumberlisting quantity
payAddressStringThe token contract address for selling your NFT

Place a bid in auction

auction_placeBid()
ParamsParameter typeParameter description
nftTypeStringnft type
nftAddressStringnft contract address
nftidStringnftid
fixPriceNumberBidding price
payAddressStringThe token contract address for bidding
ownerStringBidder address

NFT Delisting

offSale()
ParamsParameter typeParameter description
nftTypeStringnft type
nftAddressStringnft contract address
nftidStringnftid

NFT Delisting in Batches

offSaleBatch()
ParamsParameter typeParameter description
nftTypeStringnft type
nftAddressStringnft contract address
nftidsArraynftid

Withdraw an auction

auction_end()
ParamsParameter typeParameter description
nftTypeStringnft type
nftAddressStringnft contract address
nftidStringnftid
ownerStringERC1155 type, requires the address of the owner

NFT Purchasing

placeOrder()
ParamsParameter typeParameter description
nftTypeStringnft type
nftAddressStringnft contract address
nftidStringnftid
toAddressStringbuyer address
priceNumberpurchase price
marketTypeStringpurchase type
couponCodeStringcoupon code, fill in ‘0’ if none
couponLinkStringcouponLink, fill in ‘0’ if none
payAddressStringThe token contract address for purchasing

Place an Offer

createOffer()
ParamsParameter typeParameter description
nftTypeStringnft type
offerNumberStringOffer number (random number)
nftAddressStringnft contract address
nftidStringnftid
payAddressStringThe token contract address for offer
payAmountNumberOffer amount
expiryStringOffer validity period
feeNumberHandling fee

Withdraw an Offer

cancelOffer()
ParamsParameter typeParameter description
nftTypeStringnft type
offerNumberStringOffer number (random number)

Accept an Offer

acceptOffer()
ParamsParameter typeParameter description
nftTypeStringnft type
offerNumberStringoffer number (random number)
nftAddressStringnft contract address
nftidStringnftid
offerPlatformAddressStringoffer contract address

Authorize cross-chain contracts

setBridgeApproval()
ParamsParameter typeParameter description
nftTypeStringnft type

Query cross-chain transfer fees

getFeeByChainID()
ParamsParameter typeParameter description
tokenIdsArraytokenid
chainIdNumberchainid

Support NFT cross-chain transfer, between Uptick with Polygon\Arbitrum\BSC

uptickCrossToEVM()
ParamsParameter typeParameter description
srcChainNameStringSource chain name
destinationChainIdNumberTarget chain chainid
toAddressStringReceiving address
metadateStringMetadate information
offerPlatformAddressStringOffer contract address

Problem Reporting

https://github.com/UptickNetwork/uptick-web3-sdk/issues

1.0.6

6 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.2

7 months ago

1.0.1

9 months ago

1.0.3

7 months ago

1.0.0

9 months ago