Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

feature: cometh connect doc #963

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions docs/onboarding/12 Wallet/4 Wallets/ComethConnect.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
slug: /wallet/cometh
title: Cometh Connect
sidebar_position: 11
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import CodeBlock from "@theme/CodeBlock";

Prompt users to connect to your app with [Cometh Connect](https://docs.cometh.io/connect/cometh-connect/what-is-connect).

## Usage

To be able to interact with Cometh Connect, you need to create an account and get an apiKey from [cometh dashboard](https://app.cometh.io/dashboard)

You also need to indicate the chain that you are working on. For now, Cometh Connect supports these [networks](https://docs.cometh.io/connect/cometh-connect/supported-networks)

```javascript
import { Polygon } from "@thirdweb-dev/chains";
import { ComethConnect } from "@thirdweb-dev/wallets";

const options = {
apiKey: API_KEY,
chain: Polygon,
};
const wallet = new ComethConnect(options);

wallet.connect();
```

## Configuration

Optionally, provide a configuration object when instantiating the `ComethConnect` class.

<details>
<summary>clientId (recommended) </summary>
<div>

Provide `clientId` to use the thirdweb RPCs for given `chains`

You can create a client ID for your application from [thirdweb dashboard](https://thirdweb.com/create-api-key).

```javascript
import { Polygon } from "@thirdweb-dev/chains";
import { ComethConnect } from "@thirdweb-dev/wallets";

const options = {
apiKey: API_KEY,
chain: Polygon,
};
const wallet = new ComethConnect(
{
clientId: "YOUR_CLIENT_ID",
},
options,
);
```

</div>
</details>

<details>
<summary>walletAddress</summary>
<div>

Connect to an existing Cometh Connect smart wallet

This parameter allow you to connect to a user that already created a Cometh Connect smart wallet, see our [`docs`](https://docs.cometh.io/connect/cometh-connect/create-a-wallet#connect-to-an-existing-wallet) for more info.

```javascript
import { Polygon } from "@thirdweb-dev/chains";
import { ComethConnect } from "@thirdweb-dev/wallets";

const options = {
apiKey: API_KEY,
chain: Polygon,
walletAddress: walletAddress,
};
const wallet = new ComethConnect(options);
```

</div>
</details>

## Tutorial

[wallet creation](https://docs.cometh.io/connect/cometh-connect/create-a-wallet)

[send transactions](https://docs.cometh.io/connect/cometh-connect/send-transactions)

You can go to our [docs](https://docs.cometh.io/connect/cometh-connect) to get more info regarding advanced features (gasless transactions, recovery, multi device)

## Methods

Inherits all the public methods from the [`AbstractClientWallet`](interfaces/abstract-client-wallet) class.
1 change: 1 addition & 0 deletions docs/react/Connecting Wallets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ There are two ways you connect user's wallet to your application using thirdweb'
| Blocto Wallet | [`bloctoWallet`](/react/react.blocto) |
| Frame Wallet | [`frameWallet`](/react/react.frame) |
| Phantom | [`phantomWallet`](/react/react.phantom) |
| Cometh Connect | [`comethConnect`](/react/react.cometh) |

<br />

Expand Down
44 changes: 44 additions & 0 deletions docs/react/hooks/wallet/usecomethconnect.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: useComethConnect
slug: /react.usecomethconnect
displayed_sidebar: react
sidebar_position: 17
---

Hook that prompts users to connect their [Cometh Connect](/wallet/cometh) wallet to your app.

```jsx
import { useComethConnect } from "@thirdweb-dev/react";
```

The wallet also needs to be added in [ThirdwebProvider's supportedWallets](/react/react.thirdwebprovider#supportedwallets-optional) if you want the wallet to auto-connect on next page load.

To be able to interact with Cometh Connect, you need to create an account and get an apiKey from [cometh dashboard](https://app.cometh.io/dashboard)

You also need to indicate the chain that you are working on. For now, Cometh Connect supports these [networks](https://docs.cometh.io/connect/cometh-connect/supported-networks)

## Usage

```jsx
import { Polygon } from "@thirdweb-dev/chains";
import { useComethConnect } from "@thirdweb-dev/react";


function App() {
const connectWithCometh = useComethConnect();

const options = {
// Place your Cometh Connect API key here.
apiKey: "API_KEY",
chain: Polygon,
//this parameter is optionnal (allows reconnection)
walletAddress:"WALLET_ADDRESS"
},

return (
<button onClick={() => connectWithCometh(options)}>
Connect
</button>
);
}
```
130 changes: 130 additions & 0 deletions docs/react/wallets/comethConnect.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
title: comethConnect
slug: /react.cometh
displayed_sidebar: react
sidebar_position: 11
---

A wallet configurator for [MetaMask](/wallet/metamask) which allows integrating the wallet with React

To be able to interact with Cometh Connect, you need to create an account and get an apiKey from [cometh dashboard](https://app.cometh.io/dashboard)

You also need to indicate the chain that you are working on. For now, Cometh Connect supports these [networks](https://docs.cometh.io/connect/cometh-connect/supported-networks)

```tsx
import { Polygon } from "@thirdweb-dev/chains";
import { ComethConnect } from "@thirdweb-dev/wallets";

const options = {
apiKey: API_KEY,
chain: Polygon,
};
const wallet = new ComethConnect(options);

wallet.connect();
```

<CustomizeWalletConfigurator
config="bloctoWalletConfig"
configurator="bloctoWallet"
connectUI="BloctoWalletConnectUI"
selectUI="BloctoWalletSelectUI"
isInstalled="isBloctoWalletInstalled"
/>

### options

<details>
<summary>clientId (recommended) </summary>
<div>

Provide `clientId` to use the thirdweb RPCs for given `chains`

You can create a client ID for your application from [thirdweb dashboard](https://thirdweb.com/create-api-key).

```javascript
import { Polygon } from "@thirdweb-dev/chains";
import { ComethConnect } from "@thirdweb-dev/wallets";

const options = {
apiKey: API_KEY,
chain: Polygon,
};
const wallet = new ComethConnect(
{
clientId: "YOUR_CLIENT_ID",
},
options,
);
```

</div>
</details>

<details>
<summary>walletAddress</summary>
<div>

Connect to an existing Cometh Connect smart wallet

This parameter allow you to connect to a user that already created a Cometh Connect smart wallet, see our [`docs`](https://docs.cometh.io/connect/cometh-connect/create-a-wallet#connect-to-an-existing-wallet) for more info.

```javascript
import { Polygon } from "@thirdweb-dev/chains";
import { ComethConnect } from "@thirdweb-dev/wallets";

const options = {
apiKey: API_KEY,
chain: Polygon,
walletAddress: walletAddress,
};
const wallet = new ComethConnect(options);
```

</div>
</details>

## Usage with `Cometh Connect`

To allow users to connect to this wallet using the [ConnectWallet](/react/react.connectwallet) component, you can add it to [ThirdwebProvider's supportedWallets](/react/react.thirdwebprovider#supportedwallets-optional) prop.

Wallet Address is optionnal in the option config.

```tsx
const options = {
apiKey: "bef322c7-2612-4f91-ab1d-65c99c88c758",
chain: Gnosis,
walletAddress: walletAddress,
};

<ThirdwebProvider
supportedWallets={[comethConnect(options)]}
clientId="your-client-id"
>
<YourApp />
</ThirdwebProvider>;
```

## Usage with `useConnect`

you can use the `useConnect` hook to programmatically connect to the wallet without using the [ConnectWallet](/react/react.connectwallet) component.

The wallet also needs to be added in [ThirdwebProvider's supportedWallets](/react/react.thirdwebprovider#supportedwallets-optional) if you want the wallet to auto-connect on next page load.

```tsx
const options = {
apiKey: API_KEY,
chain: Polygon,
walletAddress: walletAddress,
};

function App() {
const connect = useConnect();

const handleConnect = async () => {
await connect(comethConnect(options));
};

return <div> ... </div>;
}
```