# Wallet Connector

#### web3.js

```javascript
import Web3 from 'web3';

web3 = new Web3();
const provider = wallet.getProvider();
web3.setProvider(provider);

const walletAddress = await web3.eth.getCoinbase();

// sign
web3.eth.sign("Hello world", walletAddress);

// send transaction
web3.eth.sendTransaction({
    from: walletAddress,
    to: "0x812D3C67d283F3b9d1F1E347DF37F0C7fbD6a0B0",
    value: "1000000000000000000"
});
```

#### web3-react-v8

```javascript
import { initializeConnector, Web3ReactHooks } from '@web3-react/core'
import { Connector } from '@web3-react/types'

// https://github.com/sodiumlabs/demo-dapp-web3-react/blob/main/src/connectors/sodium.ts
import { SodiumConnector } from './sodium'

export enum ConnectionType {
  SODIUM = 'SODIUM',
}

export interface Connection {
  connector: Connector
  hooks: Web3ReactHooks
  type: ConnectionType
}

// @ts-ignore
const [web3Sodium, web3SodiumHooks] = initializeConnector<SodiumConnector>(
  (actions) =>
    new SodiumConnector({
      actions,
      config: {
        defaultNetworkId: 80001,
        walletAppURL: 'https://sodium-two.vercel.app',
        transports: {
          iframeTransport: {
            enabled: true,
          }
        },
      },
    })
)
export const sodiumConnection: Connection = {
  connector: web3Sodium,
  hooks: web3SodiumHooks,
  type: ConnectionType.SODIUM,
}


// connect
sodiumConnection.connector.activate();


// get provider
const provider = sodiumConnection.hooks.useProvider();

// signer
const signer = await provider!.getSigner()

// sign
const sig = await signer.signMessage(message)
console.log('signature:', sig)
```


---

# 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://sodiums.gitbook.io/sodium-documentation/sdk/wallet-connector.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.
