# Wallet and Contracts

Verified wallets for users can be created either using a dynamically generated mnemonic or by importing mnemonics for an existing private key for the user on a supported ethereum network.

<pre class="language-javascript"><code class="lang-javascript">//Common Js
<strong>const { VerifiedWallet, Provider } = require('@verified-network/verified-sdk'); 
</strong>//ES Module
import { VerifiedWallet, Provider } from '@verified-network/verified-sdk'

/** Step 1: Create Verified Wallet **/
    //Option 1: Generate new Mnemonics and Wallet
    const investorMnemonics = await VerifiedWallet.generateMnemonics()
    const investorWallet = await VerifiedWallet.importWallet(menmonics)
   
     //Option 2: using existing wallet mnemonics
    const investorMnemonics = 'your wallet mnemonics'
    const investorWallet = await VerifiedWallet.importWallet(investorMnemonics); 
    
/** Step 2: Set Provider for Wallet **/ 
    //Option 1: using Default Providers by ethers.js(for networks like mainnet, sepolia, ropstan, polygon e.t.c)
    const defaultProviderNetwork = 'sepolia' // or any other default provider network of your choice.
    //Network/chain id(number) can be used in place of network name, for example:
<strong>    const defaultProviderNetwork = 11155111 // where number 11155111 is chain id for sepolia. any other chain id of default provider network can be used.    
</strong><strong>    const investorWalletProvider = investorWallet.setProvider(
</strong>        Provider.defaultProvider(defaultProviderNetwork)
    )
    
    //Option 2: using custom providers(infura and alchemy)
    const network = 'sepolia' // or any other network of your choice.
    //Network/chain id(number) can be used in place of network name, for example:
    const network = 11155111 // where number 11155111 is chain id for sepolia, any other chain id can be used.
    
    //For infura; to get api key and enable networks checout: https://www.infura.io/
    const INFURA_API_KEY = 'your infura api key'
    const investorWalletProvider = investorWallet.setProvider(
        Provider.infuraProvider(network, INFURA_API_KEY)
    )
    
    //For alchemy; to get api key and enable networks checout: https://www.alchemy.com/
    const ALCHEMY_API_KEY = 'your alchemy api key'
    const investorWalletProvider = investorWallet.setProvider(
        Provider.alchemyProvider(network, ALCHEMY_API_KEY)
    )
</code></pre>

Above, the investor wallet provider can be used to initialize Verified contracts and interact with them by calling various functions on contracts.&#x20;

<pre class="language-javascript"><code class="lang-javascript">/** Import contract **/

//Common Js
const { Client, contractAddress } = require('@verified-network/verified-sdk'); 
//ES Module
import { Client, contractAddress } from '@verified-network/verified-sdk'

/** get chainId **/
<strong>    const conectedNetwork = await investorWalletProvider.getNetwork();
</strong><strong>    const chainId = conectedNetwork.chainId;
</strong><strong>/** fetch contract address **/
</strong><strong>//All verified contracts addresses can be fetched from contractAddress object
</strong>    const networkContractAddresses = contractAddress[chainId]; //All verified contract addresses on connected network
    const clientContractaddress = networkContractAddresses.Client; //Client contract address
/** Initialize Contract **/
    const clientContract = new Client(investorWalletProvider, clientContractaddress);
/** Interact with contract **/
    const investorAddres = await investorWallet.getAddress() //get user address
    await clientContract.getRole(investorAddres);
</code></pre>

\
Wallets from web brower extensions/wallets of any choice like Metamask, Coinbase wallet e.t.c  can be used with Verified Sdk to interact with Verified Contracts.

<pre class="language-javascript"><code class="lang-javascript"><strong>/** install ethers: npm install --save ethers **/
</strong>
//Common Js
const { ethers } = require('ethers');
//ES Module
import { ethers } from 'ethers';

/** Step 1: Get Proider from browser wallet **/
    //MetaMask injects provider as window.ethereum
    //Any provider by web wallet of choice can be used
    const webWalletProvider = window.ethereum; 
    //convert to ethers.js provider
    const provider = new ethers.providers.Web3Provider(webWalletProvider);
    //other ethers provider methods exists that will work 
    //with any provider of choice checkout: https://docs.ethers.org/v5/getting-started/
    
/** Step 2: Connect and get signer to initialise contracts **/
    // MetaMask requires requesting permission to connect users accounts
    //Any connection method for any web browser of choice can be used;
    const connectedAccounts = await provider.send("eth_requestAccounts", []); 
    const signer = provider.getSigner()
</code></pre>

Above, the signer can be used to initialize Verified contracts and interact with them by calling various functions on contracts.&#x20;

```javascript
/** Import contract **/

//Common Js
const { Client, contractAddress } = require('@verified-network/verified-sdk'); 
//ES Module
import { Client, contractAddress } from '@verified-network/verified-sdk'

/** get chainId **/
    const conectedNetwork = await provider.getNetwork();
    const chainId = conectedNetwork.chainId;
/** fetch contract address **/
//All verified contracts addresses can be fetched from contractAddress object
    const networkContractAddresses = contractAddress[chainId]; //All verified contract addresses on connected network
    const clientContractaddress = networkContractAddresses.Client; //Client contract address
/** Initialize Contract **/
    const clientContract = new Client(signer, clientContractaddress);
/** Interact with contract **/
    const investorAddres = connectedAccounts[0] //get first account connected from web wallet
    await clientContract.getRole(investorAddres);
```

Certain contracts are proxies that indirect calls to concrete implementations. For example, cash tokens representing different currencies all have the same behavior and are produced by a cash token factory. In such cases, the contract needs to be parameterized (in this case, with a currency contract's address) before use.

```javascript
const cashUSDIssuer = new CashContract(issuerWallet, VXUSD);
await cashUSDIssuer.payIn('10', investorWallet.address, 'VXUSD')
```

Optionally, all the contract Calls take in an additional parameter: `options?: { gasPrice: number, gasLimit: number }` You can configure the gasPrice and gasLimit using this parameter as the last parameter to the contractCall function. Example: `contract.function(arg 1, arg2, options)` Where, options = {gasPrice: XXX, gasLimit: YYY}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.verified.network/reference/verified-sdk/wallet-and-contracts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
