{"id":24408242,"url":"https://github.com/icehugh/btc-connect","last_synced_at":"2025-04-12T01:44:02.060Z","repository":{"id":229289433,"uuid":"776342420","full_name":"IceHugh/btc-connect","owner":"IceHugh","description":"Btc connect for unisat okx","archived":false,"fork":false,"pushed_at":"2024-11-12T09:34:28.000Z","size":1132,"stargazers_count":15,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T23:07:49.453Z","etag":null,"topics":["btc","btc-wallet","connect","dapp","okx","unisat","web3"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IceHugh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-23T08:37:22.000Z","updated_at":"2025-02-08T13:13:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"9ce62e5d-b063-40dc-bc42-70f6416ace3b","html_url":"https://github.com/IceHugh/btc-connect","commit_stats":null,"previous_names":["icehugh/btc-connect"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IceHugh%2Fbtc-connect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IceHugh%2Fbtc-connect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IceHugh%2Fbtc-connect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IceHugh%2Fbtc-connect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IceHugh","download_url":"https://codeload.github.com/IceHugh/btc-connect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505931,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["btc","btc-wallet","connect","dapp","okx","unisat","web3"],"created_at":"2025-01-20T05:45:39.691Z","updated_at":"2025-04-12T01:44:02.021Z","avatar_url":"https://github.com/IceHugh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/IceHugh/btc-connect/blob/main/README_ZH.md\"\u003e中文\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://github.com/IceHugh/btc-connect/blob/main/doc.md\"\u003eDocument\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://stackblitz.com/edit/btc-connect-example?file=src%2FApp.tsx\"\u003eExample\u003c/a\u003e\n  \u003cbr /\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/IceHugh/btc-connect/blob/main/images/example_black.png\" width=\"300\"\u003e\n  \u003cimg src=\"https://github.com/IceHugh/btc-connect/blob/main/images/example_white.png\" width=\"300\"\u003e\n  \u003cbr /\u003e\n\u003c/div\u003e\n\n# BTC Connect\n\nBTC Connect is a library that allows you to easily integrate Bitcoin wallets (Unisat and OKX) into your web application. With this library, you can enable your users to manage their Bitcoin addresses, send and receive transactions, and interact with Bitcoin wallets directly from your web app.\n\n## Features\n\n- Connect to popular Bitcoin wallets (Unisat and OKX)\n- Manage Bitcoin addresses and check balances\n- Send and receive Bitcoin transactions\n- Sign messages and PSBTs\n- Push transactions and PSBTs to the network\n- Switch between different connectors and networks\n- Customizable UI theme (light and dark)\n- Typescript support\n- Support for React components\n- Support for pure JavaScript usage (compatible with Vue, vanilla JS, etc.)\n\n## Installation\n\nYou can install the package via npm, yarn, pnpm or bun:\n\n### npm\n```bash\nnpm install btc-connect-core\n```\n\n### Yarn\n```bash\nyarn add btc-connect-core\n```\n\n### pnpm\n```bash\npnpm add btc-connect-core\n```\n\n### bun\n```bash\nbun add btc-connect-core\n```\n\n## Requirements\n\nFor React:\n- react (\u003e=16.8.0)\n- react-dom (\u003e=16.8.0)\n\nThe library also uses the `zustand` state management library for React hooks.\n\n## Usage\n\n### React\n\nImport the `WalletConnectReact` component and wrap your application with it:\n\n```jsx\nimport React from 'react';\nimport { WalletConnectReact } from 'btc-connect/dist/react';\nimport \"btc-connect/dist/style/index.css\";\n\nconst App = () =\u003e {\n  const config = {\n    network: 'livenet', // or 'testnet'\n    defaultConnectorId: 'unisat', // or 'okx'\n  };\n\n  return (\n    \u003cWalletConnectReact\n      config={config}\n      onConnectSuccess={(btcWallet) =\u003e {\n        // Handle successful connection\n      }}\n      theme=\"dark\"\n      onConnectError={(error) =\u003e {\n        // Handle connection error\n      }}\n      onDisconnectSuccess={() =\u003e {\n        // Handle successful disconnection\n      }}\n      onDisconnectError={(error) =\u003e {\n        // Handle disconnection error\n      }}\n    \u003e\n      {/* Your app components */}\n    \u003c/WalletConnectReact\u003e\n  );\n};\n\nexport default App;\n```\n\nYou can also use the `useReactWalletStore` hook to access the wallet store and perform various actions:\n\n```jsx\nimport React from 'react';\nimport { useReactWalletStore } from 'btc-connect/dist/react';\n\nconst MyComponent = () =\u003e {\n  const walletStore = useReactWalletStore();\n\n  const connect = () =\u003e {\n    walletStore.connect();\n  };\n\n  const disconnect = () =\u003e {\n    walletStore.disconnect();\n  };\n\n  const sendBitcoin = async () =\u003e {\n    const toAddress = '...';\n    const amount = 1000;\n    const txid = await walletStore.btcWallet?.sendToAddress(toAddress, amount);\n    console.log('Transaction ID:', txid);\n  };\n\n  return (\n    \u003cdiv\u003e\n      \u003cbutton onClick={connect}\u003eConnect\u003c/button\u003e\n      \u003cbutton onClick={disconnect}\u003eDisconnect\u003c/button\u003e\n      \u003cbutton onClick={sendBitcoin}\u003eSend Bitcoin\u003c/button\u003e\n    \u003c/div\u003e\n  );\n};\n\nexport default MyComponent;\n```\n\n### Pure JavaScript\n\nYou can use the `BtcWalletConnect` class directly in your JavaScript code:\n\n```javascript\nimport BtcWalletConnect from 'btc-connect-core';\n\nconst config = {\n  network: 'livenet',\n};\n\nconst btcWallet = new BtcWalletConnect(config);\n\n// Connect to the wallet\nbtcWallet.connect()\n  .then(() =\u003e {\n    // Handle successful connection\n  })\n  .catch((error) =\u003e {\n    // Handle connection error\n  });\n\n// Send Bitcoin\nconst toAddress = '...';\nconst amount = 1000;\nbtcWallet.sendToAddress(toAddress, amount)\n  .then((txid) =\u003e {\n    console.log('Transaction ID:', txid);\n  })\n  .catch((error) =\u003e {\n    // Handle error\n  });\n\n// Disconnect from the wallet\nbtcWallet.disconnect()\n  .then(() =\u003e {\n    // Handle successful disconnection\n  })\n  .catch((error) =\u003e {\n    // Handle disconnection error\n  });\n```\n\nThis pure JavaScript usage makes it compatible with Vue, vanilla JavaScript, and other frameworks or libraries.\n\nFor more detailed information and examples, please refer to the [Doc](https://github.com/IceHugh/btc-connect/doc.md).\n\n## TODO\n\n- Support for Vue components\n\n## Contributing\n\nContributions are welcome! Please read the [contributing guidelines](https://github.com/IceHugh/btc-connect/blob/main/CONTRIBUTING.md) for more information.\n\n\n\n## License\n\nBTC Connect is licensed under the [MIT License](https://github.com/IceHugh/btc-connect/blob/main/LICENSE).\n\n## Support and Donation\n\nIf you find this project helpful and you would like to support its continued development, feel free to make a donation through one of the following methods. Your support is a tremendous encouragement for us!\n\n\u003c!-- ### PayPal\n\nYou can donate via PayPal: [Donate via PayPal](Your_PayPal_Link)\n\n### Patreon\n\nAlternatively, you can become our patron on Patreon: [Become a Patron](Your_Patreon_Link)\n\n### WeChat/Alipay QR Codes\n\nYou can also donate by scanning the following QR codes in WeChat or Alipay:\n\n![WeChat QR Code](Your_WeChat_QR_Code_Image_Link) ![Alipay QR Code](Your_Alipay_QR_Code_Image_Link) --\u003e\n\n## Cryptocurrency\n\nYou can also donate using the following cryptocurrency addresses:\n\n- BTC: bc1pnacumj3jhn28x8lwj5fqfwzxcq0kfhyrtzadd4unlg4cu57mp3wghp0j73\n\u003cimg src=\"https://github.com/IceHugh/btc-connect/blob/main/images/btc_qrcode.jpg\" width=\"300\" \u003e\nThank you to every supporter for your contributions!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficehugh%2Fbtc-connect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficehugh%2Fbtc-connect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficehugh%2Fbtc-connect/lists"}