Modules
Vue
A collection of composable functions for implementing Web3 Onboard into a Vue project; compatible both with Vue 2 + composition-api and Vue 3
Install
- Yarn
- Npm
Quickstart
Functions
init
The init
function initializes web3-onboard
and makes it available to the useOnboard()
composable. For references check out the
initialization docs for @web3-onboard/core
Example usage
useOnboard
useOnboard
must be used after the init
function has been called - it will return an object that can be destructured to obtain the following reactive variables and functions:
Example usage
connectWallet
Function to open the Web3 Onboard modal and connect to a wallet provider. For reference check out the
connecting a wallet for @web3-onboard/core
Example usage
connectedChain
Computed property that contains the current chain to which connectedWallet
is connected
Example usage
connectedWallet
Computed property that contains the latest connected wallet
Example usage
connectingWallet
Readonly boolean ref that tracks the state of the wallet connection status
Example usage
disconnectWallet
Function to disconnect a specific wallet
Example usage
disconnectConnectedWallet
Function to disconnect the connectedWallet
Example usage
getChain
Function that returns the current chain a wallet is connected to
Example usage
setChain
Function to set the chain of a wallet
Example usage
settingChain
Read-only boolean ref that tracks the status of setting the chain
Example usage
wallets
Read-only ref that contains every wallet that has been connected
Example usage
alreadyConnectedWallets
Read-only ref that contains every wallet that user connected to in the past; useful to reconnect wallets automatically after a reload
Example usage
lastConnectedTimestamp
Read-only ref that contains the last time that the user connected a wallet in milliseconds
Example usage
Build Environments
Many of the wallet modules require dependencies that are not normally included in browser builds (namely the node builtin modules such as crypto
, buffer
, util
etc). If you are having build issues you can try the following bundler configs to resolve these dependency issues:
Webpack 4
Node built-ins are automatically bundled in v4 so that portion is handled automatically.
web3auth and torus will require a Babel to compile from es6 if not already supported. See config for Babel and Webpack4 as follows:
npm i --save-dev @babel/cli @babel/core @babel/node @babel/plugin-proposal-nullish-coalescing-operator @babel/plugin-proposal-optional-chaining @babel/plugin-syntax-bigint @babel/register
AND
npm i babel-loader
babel.config.js
webpack.config.js
Webpack 5
You'll need to add some dev dependencies with the following command:
npm i --save-dev assert buffer crypto-browserify stream-http https-browserify os-browserify process stream-browserify util path-browserify browserify-zlib
Then add the following to your webpack.config.js
file:
Vite
Add the following dev dependencies:
npm i --save-dev rollup-plugin-polyfill-node crypto-browserify stream-browserify assert
Then add the following to your vite.config.js
file:
Nuxt.js
Add the following to your nuxt.config.js
: