{"id":15365568,"url":"https://github.com/tunnckocore/bitcoin-connect","last_synced_at":"2025-04-14T07:08:07.583Z","repository":{"id":150514668,"uuid":"623226005","full_name":"tunnckoCore/bitcoin-connect","owner":"tunnckoCore","description":"Derive Bitcoin Taproot address, from an Ethereum signature. For example, a signature generated by your Injected Web3 wallet through the `personal_sign` RPC call. Useful for Bitcoin Ordinals.","archived":false,"fork":false,"pushed_at":"2023-06-09T13:50:51.000Z","size":37,"stargazers_count":9,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T07:08:02.634Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","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/tunnckoCore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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},"funding":{"ko_fi":"tunnckoCore","patreon":"tunnckoCore","github":["tunnckoCore"],"custom":["https://gum.co/tunnckoCoreRecurringDonation","https://gum.co/tunnckocorePatronLicense"]}},"created_at":"2023-04-04T00:24:29.000Z","updated_at":"2024-07-24T19:38:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"a94fd4a2-baea-478d-88b2-ee87cecca717","html_url":"https://github.com/tunnckoCore/bitcoin-connect","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fbitcoin-connect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fbitcoin-connect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fbitcoin-connect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fbitcoin-connect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tunnckoCore","download_url":"https://codeload.github.com/tunnckoCore/bitcoin-connect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837280,"owners_count":21169374,"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":[],"created_at":"2024-10-01T13:15:08.089Z","updated_at":"2025-04-14T07:08:07.572Z","avatar_url":"https://github.com/tunnckoCore.png","language":"HTML","funding_links":["https://ko-fi.com/tunnckoCore","https://patreon.com/tunnckoCore","https://github.com/sponsors/tunnckoCore","https://gum.co/tunnckoCoreRecurringDonation","https://gum.co/tunnckocorePatronLicense"],"categories":[],"sub_categories":[],"readme":"# bitcoin-connect\n\n\u003e Derive Bitcoin Taproot address, from an Ethereum signature. For example, a signature generated by your Injected Web3 wallet through the `personal_sign` RPC call. Useful for Bitcoin Ordinals.\n\nFor demo check out the hosted API and UI on https://bitcoin-connect.deno.dev.\n\nTweets about it:\n\n- https://twitter.com/wgw_eth/status/1644576875845496833\n- https://twitter.com/wgw_eth/status/1644557972889018369\n\n## Install\n\n```\nnpm install bitcoin-connect\n```\n\nFor Deno, use the `npm` protocol, eg. `npm:bitcoin-connect`.\n\n**It's recommended though**, to use the `https://esm.sh/bitcoin-connect` because some of the bitcoin libraries that are used my not be resolved properly. I'll definitely make smaller ESM-only alternatives in the future.\n\n## Table of Contents\n\n- [As Library](#as-a-library)\n- [API Usage](#api-usage)\n- [Use as a user](#ui-usage)\n\n![image](https://user-images.githubusercontent.com/5038030/230706652-cbc02d1a-a7f2-4c76-ac0b-cde27650ac74.png)\n\n### As a library\n\nCheck the `test.js` for an example.\nMore better test suite and docs - soon.\n\nBasically, there are few steps:\n\n1. Trigger a sign request to some Injected web browser wallet, like Metamask\n2. Pass that signature string to the exported method.\n3. It returns the `bip32` root, taproot child, the signature, and a taproot address.\n4. Show the `taproot` address to your user. It can be used for Bitcoin Ordinals.\n\nBasic \"server-side\" example\n\n```js\nimport { generateTaprootAddressFromSignature } from \"bitcoin-connect\";\n\nconst result = generateTaprootAddressFromSignature(\"0xSignature here\");\n\nconsole.log(result);\nconsole.log(result.taprootAddress);\n```\n\nThis is also useful as a Serverless function, which I'll deploy soon.\n\nIt's also useful if you want to generate the same wallet address as the one that Generative.xyz's website is generating for your Ethereum Address.\n\nI follow how they are doing it, but externalized it so there's no UI or React things.\nIf you can generate Ethereum signature in some other way, we include their message for convenience on `TAPROOT_MESSAGE` export.\n\nFor example,\n\n```js\nimport {\n  TAPROOT_MESSAGE,\n  generateTaprootAddressFromSignature,\n} from \"bitcoin-connect\";\n\nconst signature = requestEthereumPersonalSign(TAPROOT_MESSAGE);\nconst { taprootAddress } = generateTaprootAddressFromSignature(signature);\n\n// you should get the same address as the one when you connect your wallet\n// to the generative.xyz site by clicking Wallet there.\nconsole.log(taprootAddress);\n```\n\n### API Usage\n\nThe API generates you a bitcoin taproot address, given an Ethereum/Web3 signature.\n\nIt accepts both POST and GET requests to the root domain, e.g. `/`.\n\nTry this https://bitcoin-connect.deno.dev/?signature=0x849cdb2c6ab66269d95e219ab99d12762c6caad49f6b0fa569289935c21179242747640b69be801f8660b17cba85bb37e8897be01830c6442b95fd6bc69038991b\n\nThat's my actual Bitcoin taproot wallet (that can be used on https://generative.xyz), generated from my Ethereum address (0xA20c...5002 / wgw.eth). You can verify that at https://etherscan.io/verifySig/16514\n\nYou can also pass the `signature` to a POST request body\n\n```js\n// generate this signature somehow,\n// eg. using `personal_sign` of Metamask, or another (Injected browser) wallet\nconst sig = `0x849cdb2c6ab66269d95e219ab99d12762c6caad49f6b0fa569289935c21179242747640b69be801f8660b17cba85bb37e8897be01830c6442b95fd6bc69038991b`;\n\nconst res = await fetch(\"https://bitcoin-connect.deno.dev\", {\n  method: \"POST\",\n  headers: { \"content-type\": \"application/json\" },\n  body: JSON.stringify({ signature: sig }),\n});\n\nconst { error, data } = await res.json();\nconst { address, signature, message } = data;\n\nconstole.log({ error, address, signature, message });\n```\n\nor a `GET` request example\n\n```js\nconst sig = `0x849cdb2c6ab66269d95e219ab99d12762c6caad49f6b0fa569289935c21179242747640b69be801f8660b17cba85bb37e8897be01830c6442b95fd6bc69038991b`;\n\nconst res = await fetch(\"https://bitcoin-connect.deno.dev/?signature\" + sig);\nconst { error, data } = await res.json();\nconst { address, signature, message } = data;\n\nconstole.log({ error, address, signature, message });\n```\n\n_(for more check the source code in `api/index.ts`)_\n\nFor development\n\n```\nyarn dev\n\n# or from the `api` folder\n# deno run -A --watch index.ts\n```\n\nFor production\n\n```\nyarn deploy\n\n# or from the `api` folder\n# deployctl deploy --project=bitcoin-connect index.ts\n```\n\n### UI usage\n\nTODO: More docs on the site, explaining everything and the API\n\nAs an example, you can check the `api/index.html` to see how Metamask/web3 wallet signing is implemented in 30 lines of code. No need for libraries, no need for MEGABYTES of stuff _on the client side_. Ethereum Web3 is so awful it's mind-blowing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fbitcoin-connect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftunnckocore%2Fbitcoin-connect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fbitcoin-connect/lists"}