import React, { useState } from 'react'; import { TomoWalletTgSdkV2 } from '../src'; import './v2.css'; import { btcAddressTypeMaps } from '../src/config/btc'; // new TomoWalletTgSdkV2({ injected: true }); const bitcoin = window.tg_tomo_btc; export default function Index() { const [addr, setAddr] = useState(''); const [contractAddr, setContractAddr] = useState(''); const [toAddr2, setToAddr2] = useState(''); const [toValue2, setToValue2] = useState('0.1'); const [signRes2, setSignRes2] = useState(''); const connectWallet = async () => { if (addr) { bitcoin?.disconnect && bitcoin?.disconnect(); setAddr(''); return; } const res = await bitcoin.connectWallet(); return res; // await walletAddressReq(); }; const signMessage = async () => { const res = await bitcoin.signMessage({ method: 'btc_signMessage', params: [ { addressType: btcAddressTypeMaps[2], message: 'btc sign message', }, ], }); return res; }; const sendTx = async () => { const res = await bitcoin.request({ method: 'btc_sendTx', params: [ { network: 'SIGNET', addressType: btcAddressTypeMaps[2], toAddress: toAddr2, amount: toValue2, }, ], }); console.log('sendTx res', res); }; return (
To Address:
{ const v = e.target.value; setToAddr2(v); setSignRes2(''); }} />Amount:
{ const v = e.target.value; setToValue2(v); setSignRes2(''); }} /> <> {signRes2 ? ( <>Sign Result: