Send
Trigger the send flow in the wallet, allowing a user to select a token and a destination before executing the transaction.
You can optionally pass in the token and destination.
import { mega } from '@megaeth-labs/wallet-sdk';
const result = await mega.send({});import { useSend } from '@megaeth-labs/wallet-sdk-react';
export default function SendButton() {
const { mutate: send, isPending } = useSend();
return (
<button onClick={() => send({})} disabled={isPending}>
Send
</button>
);
}import type { MegaWalletProvider } from '@megaeth-labs/wallet-wagmi-connector';
import { useAccount } from 'wagmi';
export default function SendButton() {
const { connector } = useAccount();
async function send() {
const provider = (await connector?.getProvider()) as MegaWalletProvider;
await provider.send({});
}
return (
<button onClick={send} disabled={!connector}>
Send
</button>
);
}Runs on testnet with your wallet
ts
interface SendRequest {
token?: `0x${string}` | 'native';
destination?: `0x${string}`;
}
interface TransactionResult {
status: 'approved' | 'cancelled' | 'error';
receipt?: TransactionReceipt;
receipts?: TransactionReceipt[];
error?: string;
}