diff --git a/constants/wallet.ts b/constants/wallet.ts new file mode 100644 index 0000000000..d255fc79a7 --- /dev/null +++ b/constants/wallet.ts @@ -0,0 +1,6 @@ +export const WALLET_SIGN_MESSAGE_REQUEST = `Welcome to The Exit! + +Please click to verify your wallet ownership and to sign into The Exit. + +This request will not trigger a blockchain transaction or cost any gas fees. +` diff --git a/src/components/Header/Header/Header.tsx b/src/components/Header/Header/Header.tsx index cc71b36b01..bed1620e74 100644 --- a/src/components/Header/Header/Header.tsx +++ b/src/components/Header/Header/Header.tsx @@ -4,6 +4,8 @@ import { truncateString } from '@/utils/general.utils' import styled from '@emotion/styled' import Link from 'next/link' import React, { useState } from 'react' +import { api } from '../../../../common/api' +import { WALLET_SIGN_MESSAGE_REQUEST } from '../../../../constants/wallet' import { Navbar } from '../Navbar' declare global { @@ -27,7 +29,21 @@ const Header: React.FC = () => { // DOCS: https://www.okx.com/web3/build/docs/sdks/chains/bitcoin/provider#connect if (window.okxwallet) { const result = await window.okxwallet.bitcoin.connect() - setWalletAddress(result.address) + const address = result.address + + setWalletAddress(address) + + const signature = await window.okxwallet.bitcoin.signMessage( + WALLET_SIGN_MESSAGE_REQUEST, + 'bip322-simple', + ) + + const response = await api.post('/token/pair', { + address, + signature, + }) + + console.log('Token pair response:', response) } else { alert('No Bitcoin wallet found. Please install OKX Wallet.') }