Usage
Using the VeChain dApp kit
1. Optional: Wallet Connect Options
import type { WalletConnectOptions } from '@vechain/dapp-kit';
const walletConnectOptions: WalletConnectOptions = {
// Create your project here: https://cloud.walletconnect.com/sign-up
projectId: '<PROJECT_ID>',
metadata: {
name: 'My dApp',
description: 'My dApp description',
// Your app URL
url: window.location.origin,
// Your app Icon
icons: [`${window.location.origin}/images/my-dapp-icon.png`],
},
};2. Initialise the DAppKit instance
DAppKit instanceimport { DAppKit } from '@vechain/dapp-kit';
const {thor, vendor, wallet} = new DAppKit({
// Required - The URL of the node to connect to
nodeUrl: "https://sync-testnet.vechain.org/",
// OPTIONAL: "main" | "test" | Connex.Thor.Block
genesis: "test",
// OPTIONAL: Wallet connect options
walletConnectOptions: walletConnectOptions,
// OPTIONAL: Defaults to false. If true, account and source will be persisted in local storage
usePersistence: true,
// OPTIONAL: Use the first available wallet
useFirstDetectedSource: false,
// OPTIONAL: Log Level - To debug the library
logLevel: "DEBUG",
// OPTIONAL: every wallet has a connection certificate, but wallet connect doesn't connect with a certificate, it uses a session; if required, with this option, we will force the user to sign a certificate after he finishes the connection with wallet connect
requireCertificate=false;
// OPTIONAL: you can optionally provide a certificate to be signed during the login, otherwise a standard one will be used
connectionCertificate={defaultContract}
// OPTIONAL: you can choose which wallets to allow in your application between 'wallet-connect', 'veworld', 'sync2' or 'sync'. Default: all
allowedWallets={[ 'veworld', 'wallet-connect' ]}
});Wallet Manager
Set the wallet source
Connect
State
WalletManagerState:
Subscribe to State
Subscribe to a single value in the state
Last updated
Was this helpful?