> For the complete documentation index, see [llms.txt](https://docs.altura.com/altura-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.altura.com/altura-documentation/js-sdk-reference/connect-to-web3-wallet.md).

# Connect to Web3 Wallet

## Import Metamask

```javascript
import { MetamaskConnector } from "@altura/altura-js/lib/connector";

const wallet = new MetamaskConnector(window.ethereum);

wallet.connect(); // connect to the wallet
```

## Import WalletConnect

First install WalletConnect web3-provider :

```shell
npm i @walletconnect/web3-provider
```

Now import WalletConnect web3-provider and WalletConnectConnector from Altura:

```javascript
import { WalletConnectConnector } from "@altura/altura-js/lib/connector";
import WalletConnectProvider from "@walletconnect/web3-provider";
```

Now, instantiate your WalletConnect web3-provider using the following options: Infura or Custom RPC mapping

{% tabs %}
{% tab title="Infura" %}

```javascript
import WalletConnectProvider from "@walletconnect/web3-provider";

//  Create WalletConnect Provider
const provider = new WalletConnectProvider({
  infuraId: "27e484dcd9e3efcfd25a83a78777cdf1",
});

//  Enable session (triggers QR Code modal)
await provider.enable();
```

{% endtab %}

{% tab title="Custom RPC" %}

```javascript
import WalletConnectProvider from "@walletconnect/web3-provider";

//  Create WalletConnect Provider
const provider = new WalletConnectProvider({
  rpc: {
    1: "https://mainnet.mycustomnode.com",
    3: "https://ropsten.mycustomnode.com",
    100: "https://dai.poa.network",
    // ...
  },
});

//  Enable session (triggers QR Code modal)
await provider.enable();
```

{% endtab %}
{% endtabs %}

Now integrate it with WalletConnectConnector:

```javascript
const wallet = new WalletConnectConnector(provider);
```

### Get Wallet Address

```javascript
const walletAddress = await wallet.address();
console.log(walletAddress);
```

### Get Wallet Balance

```javascript
const walletAddress = await wallet.address();
console.log(walletAddress);
```

### Sign Message

```javascript
try {
    await wallet.sign("Hi Altura!");
} catch (error) {
    console.log("Denied the sign", error);
}
```

### Send Transaction

```javascript
try {
    const tx = {
        to: "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",
        // `function addr(namehash("ricmoo.eth")) view returns (address)`
        data: "0x3b3b57debf074faa138b72c65adbdcfb329847e4f2c04bde7f7dd7fcad5a52d2f395a558",
    };
    await wallet.sendTransaction(tx);
} catch (error) {
    console.log("Error on sending transaction", error);
}
```

### Get Network information

```javascript
const getNetworkData = await wallet.getNetwork();
console.log(getNetworkData);
```

### Get Gas Price

```javascript
const getGasPrice = await wallet.getGasPrice();
console.log(getGasPrice);
```

### Get Fee Data

```javascript
const getFeeData = await wallet.getFeeData();
console.log(getFeeData);
```

### Get Block Number

```javascript
const getBlockNumber = await wallet.getBlockNumber();
console.log(getBlockNumber);
```
