@sodahq/solana-connect
v0.1.2
Published
```javascript interface SolanaConnectProps extends PropsWithChildren { connectionEndpoint?: string; // if not set will use devnet endpoint cluster?: Cluster; // same will use devnet appUrl?: string; // your dapp url } ```
Downloads
192
Readme
Context Provider
interface SolanaConnectProps extends PropsWithChildren {
connectionEndpoint?: string; // if not set will use devnet endpoint
cluster?: Cluster; // same will use devnet
appUrl?: string; // your dapp url
}
'use client'; // for NextJS
import { SolanaConnect } from '@polyton/solana-connect';
import { FC, PropsWithChildren } from 'react';
export const SolanaConnectProvider: FC<PropsWithChildren> = ({ children }) => (
<SolanaConnect>
{children}
</SolanaConnect>
);
Using wallet
interface UseWalletInterface {
wallet: null | {
address: string;
walletName: string;
};
connection: null | Connection;
connect: (() => Promise<void>) | null;
sendTransaction: SendTransactionFunction | null;
signTransaction: SignTransactionFunction | null;
signAllTransactions: SignAllTransactionsFunction | null;
signMessage: ((message: Uint8Array) => Promise<Uint8Array>) | null;
signer: {
publicKey: PublicKey;
signTransaction: SignTransactionFunction;
signAllTransactions: SignAllTransactionsFunction;
} | null;
disconnect: (() => void) | null;
}
const { wallet, sendTransaction } = useWallet();
await sendTransaction(new Transaction());