Integrate Comet's Instant Wallet and Minting functionality into your React app in 1 line of code.
Note: This is a very early release of Comet's React library and APIs are subject to change.
npm install --save @comet-labs/react
yarn add @comet-labs/react
import React from 'react';
import { CometButton } from '@comet-labs/react';
export default function MyApp(props) {
// Login handler
const loginHandler = (result) => {
alert(`Logged in as @${result.username}! Address: ${result.address.address}`);
}
return (
...
<CometButton
action="login"
onLoginthis ={loginHandler}
/>
...
);
}import React from 'react';
import { CometButton } from '@comet-labs/react';
export default function MyApp(props) {
return (
...
<CometButton
action="gallery"
/>
...
);
}Contact us to launch a new NFT and get its collectionId. Supports free mints
and paid mints using Stripe as an onramp.
import React from 'react';
import { CometButton } from '@comet-labs/react';
export default function MyApp(props) {
return (
...
<CometButton
action="mint"
collectionId="<collectionId>"
/>
...
);
}CometButton accepts the following props:
| Prop | Required | Description |
|---|---|---|
action |
✔️ | The action that occurs when the button is clicked. Currently the only accepted action is login. |
onLogin |
✔️ | Handler function after the login is done. Contains fields for the user's id, username, and data about their address. |
chainType, chainId |
Specify chainType and chainId to specify which blockchain to login with. The currently available chainTypes and chainIds are listed below. |
By default, Comet generates a wallet on Solana mainnet. To generate wallets on other chains, supply the chainType and chainId props to CometButton. The supported chains are listed below:
| Blockchain | chainType |
chainId |
|---|---|---|
| Solana mainnet | solana |
101 |
| Solana devnet | solana |
103 |