# Install via NPM (You can use any wallet selector version you want)npminstall@wpdas/naxios@near-wallet-selector/modal-ui@8.9.13--save
# Install via yarn (You can use any wallet selector version you want)yarnadd@wpdas/naxios@near-wallet-selector/modal-ui@8.9.13
Good to know: @near-wallet-selector/modal-ui need to be installed together because Naxios is integrated with NEAR Wallet Selector.
Preparing it
Import the NEAR Wallet Selector styles. The app needs it to render the Wallet Selector correctly.
import'@near-wallet-selector/modal-ui/styles.css'
Using It
It's super easy to get a Wallet, Contract, and RPC API in place all at once. Take a look:
import naxios from'@wpdas/naxios'/** * NEAR Wallet API */constwalletApi=newnaxios({ rpcNodeUrl:'https://free.rpc.fastnear.com',// optional contractId:CONTRACT_ID, network:'testnet',// or mainnet, localnet}).walletApi()
import naxios from'@wpdas/naxios'/** * NEAR Contract API */constcontractApi=newnaxios({ rpcNodeUrl:'https://free.rpc.fastnear.com',// optional contractId:CONTRACT_ID, network:'testnet',// or mainnet, localnet}).contractApi()
import naxios from'@wpdas/naxios'/** * NEAR RPC API */constcontractApi=newnaxios({ rpcNodeUrl:'https://free.rpc.fastnear.com',// optional contractId:CONTRACT_ID, network:'testnet',// or mainnet, localnet}).rpcApi()
import naxios from'@wpdas/naxios'constnaxiosInstance=newnaxios({ rpcNodeUrl:'https://free.rpc.fastnear.com',// optional contractId:CONTRACT_ID, network:'testnet',// or mainnet, localnet})/** * NEAR Wallet API (Must be a single instance) */exportconstwalletApi=naxiosInstance.walletApi()// Examples of contract API instance usage/** * Contract API * This is going to use default contractId (CONTRACT_ID) */exportconstcontractApi=naxiosInstance.contractApi()/** * Another Contract API */exportconstsocialDBcontractApi=naxiosInstance.contractApi({ contractId:'v1.social08.testnet',})/** * Greeting Contract API */exportconstgreetingContractApi=naxiosInstance.contractApi({ contractId:'dev-1692221685438-15421910364142',})/** * NEAR RPC API */exportconstrpcApi=naxiosInstance.rpcApi()