├── .gitignore ├── LICENSE ├── README.md ├── docs ├── .vuepress │ ├── components │ │ ├── ConnectButton.vue │ │ ├── GithubContributor.vue │ │ ├── SendTransaction.vue │ │ ├── UpgradePath.vue │ │ └── svg-container.vue │ ├── config.js │ ├── enhanceApp.js │ ├── images │ │ └── logo.png │ ├── nav │ │ └── en.js │ ├── public │ │ ├── logo.png │ │ └── manifest.json │ └── styles │ │ ├── index.styl │ │ └── palette.styl ├── faq │ └── README.md ├── guide │ ├── README.md │ ├── accessing-accounts.md │ ├── defining-your-icon.md │ ├── getting-started.md │ └── unisat-api.md └── snippets │ └── WatchAssetParams.ts ├── package.json ├── scripts └── build.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | docs/dist -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 UniSat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | 1. Open project in terminal and run `yarn` 4 | 2. Once install is finish run `yarn start` to run locally 5 | 3. Open your browser and it should be hosted on `localhost:8080/` 6 | 7 | To enable Algolia DocSearch locally, run `cp .env-template .env` and populate 8 | the fields with the correct values. 9 | -------------------------------------------------------------------------------- /docs/.vuepress/components/ConnectButton.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 40 | -------------------------------------------------------------------------------- /docs/.vuepress/components/GithubContributor.vue: -------------------------------------------------------------------------------- 1 | 15 | 25 | 26 | 48 | -------------------------------------------------------------------------------- /docs/.vuepress/components/SendTransaction.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 76 | -------------------------------------------------------------------------------- /docs/.vuepress/components/UpgradePath.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 34 | -------------------------------------------------------------------------------- /docs/.vuepress/components/svg-container.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 14 | -------------------------------------------------------------------------------- /docs/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | module.exports = (_ctx) => ({ 2 | sourceDir: "docs", 3 | dest: "docs/dist", 4 | 5 | locales: { 6 | "/": { 7 | lang: "en-US", 8 | title: "UniSat Docs", 9 | description: "Developer documentation for the UniSat", 10 | }, 11 | }, 12 | 13 | head: [ 14 | ["link", { rel: "icon", href: `/logo.png` }], 15 | ["link", { rel: "manifest", href: "/manifest.json" }], 16 | ["meta", { name: "theme-color", content: "#3eaf7c" }], 17 | ["meta", { name: "apple-mobile-web-app-capable", content: "yes" }], 18 | [ 19 | "meta", 20 | { name: "apple-mobile-web-app-status-bar-style", content: "black" }, 21 | ], 22 | [ 23 | "link", 24 | { rel: "apple-touch-icon", href: `/icons/apple-touch-icon-152x152.png` }, 25 | ], 26 | [ 27 | "link", 28 | { 29 | rel: "mask-icon", 30 | href: "/icons/safari-pinned-tab.svg", 31 | color: "#3eaf7c", 32 | }, 33 | ], 34 | [ 35 | "meta", 36 | { 37 | name: "msapplication-TileImage", 38 | content: "/icons/msapplication-icon-144x144.png", 39 | }, 40 | ], 41 | ["meta", { name: "msapplication-TileColor", content: "#000000" }], 42 | ], 43 | 44 | theme: "@vuepress/theme-default", 45 | 46 | themeConfig: { 47 | repo: "", 48 | docsDir: "packages/docs/dist", 49 | editLinks: false, 50 | logo: "/logo.png", 51 | smoothScroll: true, 52 | algolia: { 53 | apiKey: process.env.ALGOLIA_API_KEY, 54 | indexName: process.env.ALGOLIA_INDEX_NAME, 55 | }, 56 | locales: { 57 | "/": { 58 | label: "English", 59 | selectText: "Languages", 60 | editLinkText: "Edit this page on GitHub", 61 | lastUpdated: "Last Updated", 62 | nav: require("./nav/en"), 63 | sidebar: { 64 | "/guide/": getGuideSidebar( 65 | "Guide", 66 | "API Reference", 67 | "Best Practices", 68 | "Mobile", 69 | "Resources" 70 | ), 71 | }, 72 | }, 73 | }, 74 | }, 75 | 76 | plugins: [ 77 | ["@vuepress/back-to-top", true], 78 | [ 79 | "@vuepress/pwa", 80 | { 81 | serviceWorker: true, 82 | updatePopup: true, 83 | }, 84 | ], 85 | ["@vuepress/medium-zoom", true], 86 | [ 87 | "container", 88 | { 89 | type: "vue", 90 | before: '
',
 91 |         after: "
", 92 | }, 93 | ], 94 | [ 95 | "container", 96 | { 97 | type: "upgrade", 98 | before: (info) => ``, 99 | after: "", 100 | }, 101 | ], 102 | [ 103 | "vuepress-plugin-redirect", 104 | { 105 | redirectors: [ 106 | { 107 | base: "/", 108 | alternative: "/guide/", 109 | }, 110 | ], 111 | }, 112 | ], 113 | [ 114 | "tabs", 115 | { 116 | useUrlFragment: false, 117 | }, 118 | ], 119 | ], 120 | 121 | extraWatchFiles: [".vuepress/nav/en.js"], 122 | }); 123 | 124 | function getGuideSidebar(guide, api, bestPractices, mobile, resources) { 125 | return [ 126 | { 127 | title: guide, 128 | collapsable: false, 129 | children: [ 130 | "", 131 | "getting-started", 132 | // 'common-terms', 133 | // 'accessing-accounts', 134 | // 'sending-transactions', 135 | ], 136 | }, 137 | { 138 | title: api, 139 | collapsable: false, 140 | children: ["unisat-api"], 141 | }, 142 | // { 143 | // title: bestPractices, 144 | // collapsable: false, 145 | // children: [ 146 | // 'registering-your-token', 147 | // ] 148 | // }, 149 | ]; 150 | } 151 | -------------------------------------------------------------------------------- /docs/.vuepress/enhanceApp.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import ConnectButton from './components/ConnectButton'; 4 | import SendTransaction from './components/SendTransaction'; 5 | 6 | export default ({ Vue, isServer }) => { 7 | if (!isServer) { 8 | import('vue-toasted' /* webpackChunkName: "notification" */).then((module) => { 9 | Vue.use(module.default) 10 | }) 11 | } 12 | 13 | Vue.component('ConnectButton', ConnectButton); 14 | Vue.component('SendTransaction', SendTransaction); 15 | } 16 | -------------------------------------------------------------------------------- /docs/.vuepress/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unisat-wallet/unisat-docs/ca6837a6e6fa7fa9451f53d1ac00191a10b088bb/docs/.vuepress/images/logo.png -------------------------------------------------------------------------------- /docs/.vuepress/nav/en.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | text: 'Guide', 4 | link: '/guide/', 5 | }, 6 | ] 7 | -------------------------------------------------------------------------------- /docs/.vuepress/public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unisat-wallet/unisat-docs/ca6837a6e6fa7fa9451f53d1ac00191a10b088bb/docs/.vuepress/public/logo.png -------------------------------------------------------------------------------- /docs/.vuepress/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniSat Documentation", 3 | "short_name": "UniSat Docs", 4 | "icons": [ 5 | { 6 | "src": "/logo.png", 7 | "sizes": "72x72 96x96 128x128 256x256 512x512" 8 | } 9 | ], 10 | "start_url": "/index.html", 11 | "display": "standalone", 12 | "background_color": "#fff", 13 | "theme_color": "#f6851b" 14 | } 15 | -------------------------------------------------------------------------------- /docs/.vuepress/styles/index.styl: -------------------------------------------------------------------------------- 1 | //Syles for Vuepress Plugin Tabs 2 | @require '~vuepress-plugin-tabs/dist/themes/default.styl' 3 | 4 | 5 | // placeholder for test, dont't remove it. 6 | 7 | //.content { 8 | // font-size 30px; 9 | //} 10 | 11 | pre.vue-container 12 | border-left-width: .5rem; 13 | border-left-style: solid; 14 | border-color: #42b983; 15 | border-radius: 0px; 16 | & > code 17 | font-size: 14px !important; 18 | & > p 19 | margin: -5px 0 -20px 0; 20 | code 21 | background-color: #42b983 !important; 22 | padding: 3px 5px; 23 | border-radius: 3px; 24 | color #000 25 | em 26 | color #808080 27 | font-weight light 28 | 29 | .btn { 30 | border: none; 31 | color: white; 32 | padding: 15px 32px; 33 | text-align: center; 34 | text-decoration: none; 35 | display: inline-block; 36 | font-size: 16px; 37 | box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.2), 0 4px 5px 0 rgba(0, 0, 0, 0.14), 38 | 0 1px 10px 0 rgba(0, 0, 0, 0.12); 39 | } 40 | 41 | .primaryBtn { 42 | background-color: #037dd6; 43 | } 44 | 45 | .greenBtn { 46 | background-color: #4caf50; 47 | } 48 | 49 | .feedback { 50 | margin: 10px 0px; 51 | padding: 20px; 52 | border-radius: 6px; 53 | background-color: #E7893C; 54 | color: white; 55 | } 56 | 57 | .green-background { 58 | background-color: #79B473; 59 | } 60 | 61 | .fade-enter-active{ 62 | transition: opacity 1.5s; 63 | } 64 | .fade-leave-active { 65 | opacity: 0; 66 | } 67 | .fade-enter, .fade-leave-to { 68 | opacity: 0; 69 | } 70 | -------------------------------------------------------------------------------- /docs/.vuepress/styles/palette.styl: -------------------------------------------------------------------------------- 1 | // placeholder for test, dont't remove it. 2 | 3 | //$accentColor = #f00 4 | $accentColor = #3099f2 5 | $textColor = #2c3e50 6 | $borderColor = #eaecef 7 | $codeBgColor = #282c34 8 | $badgeTip = #3099f2 9 | $badgeWarning = darken(#ffe564, 35%) 10 | $badgeError = #DA596 11 | -------------------------------------------------------------------------------- /docs/faq/README.md: -------------------------------------------------------------------------------- 1 | # FAQ 2 | 3 | For questions or issues visit our [GitHub](https://github.com/unisat) 4 | -------------------------------------------------------------------------------- /docs/guide/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Introduction 3 | 4 | Welcome to UniSat's Developer Documentation. This documentation is for learning to develop applications for UniSat Wallet. 5 | 6 | - You can find the latest version of UniSat Wallet on our [official website](https://unisat.io/). 7 | - To learn how to contribute to the UniSat project itself, visit our [Github Docs](https://github.com/unisat-wallet/extension). 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/guide/accessing-accounts.md: -------------------------------------------------------------------------------- 1 | # Accessing Accounts 2 | 3 | User accounts are used in a variety of contexts in BitcoinSV, including as identifiers and for signing transactions. In order to request a signature from the user or have the user approve a transaction, one must be able to access the user's accounts. The `wallet methods` below involve a signature or transaction approval and all require connect before use. 4 | 5 | - `sendBitcoin` 6 | - `sendInscription` 7 | - `signTx` 8 | - `signMessage` 9 | 10 | Once you've [connected to a user](./getting-started.html), you can always re-check the current account by checking `unisat.connect()`. 11 | -------------------------------------------------------------------------------- /docs/guide/defining-your-icon.md: -------------------------------------------------------------------------------- 1 | # Defining Your App's Icon 2 | 3 | When your site makes a login request to a UniSat user, UniSat may render a modal that display's your site icon. 4 | 5 | We retrieve this icon using the HTML selector ` link[rel="shortcut icon"]`, so to customize this icon for your site, just make sure to follow the [favicon standard](https://en.wikipedia.org/wiki/Favicon), and make sure to have a `link` tag within your site's `head` with `rel = "shortcut icon"`, like this. 6 | 7 | The tag's `href` attribute will be used for assigning the site icon. 8 | 9 | ```html 10 | 11 | 12 | 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/guide/getting-started.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | To develop for UniSat Wallet, install UniSat Wallet on your development machine. [Download here](https://unisat.io/). 4 | 5 | ::: warning A quick note... 6 | This guide assumes intermediate knowledge of HTML, CSS, and JavaScript. 7 | ::: 8 | 9 | Once UniSat Wallet is installed and running, you should find that new browser tabs have a `window.unisat` object available in the developer console. 10 | This is how your website will interact with UniSat Wallet. 11 | 12 | [comment]: <> (## Basic Considerations) 13 | 14 | ### Browser Detection 15 | 16 | To verify if the browser is running UniSat Wallet, copy and paste the code snippet below in the developer console of your web browser: 17 | 18 | ```javascript 19 | if (typeof window.unisat !== 'undefined') { 20 | console.log('UniSat Wallet is installed!'); 21 | } 22 | ``` 23 | 24 | You can review the full API for the `window.unisat` object [here](./unisat-provider.html). 25 | 26 | ### Connecting to UniSat Wallet 27 | 28 | "Connecting" or "logging in" to UniSat Wallet effectively means "to access the user's Bitcoin account(s)". 29 | 30 | You should **only** initiate a connection request in response to direct user action, such as clicking a button. 31 | You should **always** disable the "connect" button while the connection request is pending. 32 | You should **never** initiate a connection request on page load. 33 | 34 | We recommend that you provide a button to allow the user to connect UniSat Wallet to your dapp. 35 | Clicking this button should call the following method: 36 | 37 | ```javascript 38 | unisat.requestAccounts() 39 | ``` 40 | 41 | ### Demo 42 | 43 | - [Online Demo](https://demo.unisat.io) 44 | - [Demo source code](https://github.com/unisat-wallet/unisat-web3-demo) 45 | 46 | -------------------------------------------------------------------------------- /docs/guide/unisat-api.md: -------------------------------------------------------------------------------- 1 | # UniSat Wallet API 2 | 3 | ## Table of Contents 4 | 5 | [[toc]] 6 | 7 | ## Methods 8 | 9 | 10 | ### requestAccounts 11 | 12 | ```typescript 13 | unisat.requestAccounts() 14 | ``` 15 | 16 | Connect the current account. 17 | 18 | #### Parameters 19 | 20 | none 21 | 22 | #### Returns 23 | 24 | `Promise` returns `string[]` : Address of current account. 25 | 26 | #### Example 27 | 28 | ```typescript 29 | try { 30 | let accounts = await window.unisat.requestAccounts(); 31 | console.log('connect success', accounts); 32 | } catch (e) { 33 | console.log('connect failed'); 34 | } 35 | > connect success ['tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz'] 36 | ``` 37 | 38 | 39 | ### getAccounts 40 | 41 | ```typescript 42 | unisat.getAccounts() 43 | ``` 44 | 45 | Get address of current account 46 | 47 | #### Parameters 48 | 49 | none 50 | 51 | #### Returns 52 | 53 | * `Promise` - `string`: address of current account 54 | 55 | #### Example 56 | 57 | ```typescript 58 | try { 59 | let res = await window.unisat.getAccounts(); 60 | console.log(res) 61 | } catch (e) { 62 | console.log(e); 63 | } 64 | > ["tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz"] 65 | ``` 66 | 67 | ### getNetwork 68 | 69 | ```typescript 70 | unisat.getNetwork() 71 | ``` 72 | 73 | get network 74 | 75 | #### Parameters 76 | 77 | none 78 | 79 | #### Returns 80 | 81 | * `Promise` - `string`: the network. `livenet` and `testnet` 82 | 83 | #### Example 84 | 85 | ```typescript 86 | try { 87 | let res = await window.unisat.getNetwork(); 88 | console.log(res) 89 | } catch (e) { 90 | console.log(e); 91 | } 92 | 93 | > 0 94 | ``` 95 | 96 | ### switchNetwork 97 | 98 | ```typescript 99 | unisat.switchNetwork(network) 100 | ``` 101 | 102 | switch network 103 | 104 | #### Parameters 105 | 106 | * `network` - `string`: the network. `livenet` and `testnet` 107 | 108 | #### Returns 109 | 110 | none 111 | 112 | #### Example 113 | 114 | ```typescript 115 | try { 116 | let res = await window.unisat.switchNetwork("livenet"); 117 | console.log(res) 118 | } catch (e) { 119 | console.log(e); 120 | } 121 | 122 | > 0 123 | ``` 124 | 125 | 126 | 127 | 128 | ### getPublicKey 129 | 130 | ```typescript 131 | unisat.getPublicKey() 132 | ``` 133 | 134 | Get publicKey of current account. 135 | 136 | #### Parameters 137 | 138 | none 139 | 140 | #### Returns 141 | 142 | * `Promise` - `string`: publicKey 143 | 144 | #### Example 145 | 146 | ```typescript 147 | try { 148 | let res = await window.unisat.getPublicKey(); 149 | console.log(res) 150 | } catch (e) { 151 | console.log(e); 152 | } 153 | > 03cbaedc26f03fd3ba02fc936f338e980c9e2172c5e23128877ed46827e935296f 154 | ``` 155 | 156 | 157 | 158 | 159 | ### getBalance 160 | 161 | ```typescript 162 | unisat.getBalance() 163 | ``` 164 | 165 | Get BTC balance 166 | 167 | #### Parameters 168 | 169 | none 170 | 171 | #### Returns 172 | 173 | * `Promise` - `Object`: 174 | - ` confirmed ` - ` number ` : the confirmed satoshis 175 | - ` unconfirmed ` - ` number ` : the unconfirmed satoshis 176 | - ` total ` - ` number ` : the total satoshis 177 | 178 | 179 | 180 | #### Example 181 | 182 | ```typescript 183 | try { 184 | let res = await window.unisat.getBalance(); 185 | console.log(res) 186 | } catch (e) { 187 | console.log(e); 188 | } 189 | 190 | > { 191 | "confirmed":0, 192 | "unconfirmed":100000, 193 | "total":100000 194 | } 195 | ``` 196 | 197 | ### getInscriptions 198 | 199 | ```typescript 200 | unisat.getInscriptions(cursor,size) 201 | ``` 202 | 203 | List inscriptions of current account 204 | 205 | #### Parameters 206 | 207 | none 208 | 209 | #### Returns 210 | 211 | * `Promise` - `Object`: 212 | * ` total ` - `number` : the total count 213 | * ` list ` - `Object[]` : 214 | * ` inscriptionId ` - ` string ` : the id of inscription. 215 | * ` inscriptionNumber ` - ` string ` : the number of inscription. 216 | * ` address ` - ` string ` : the address of inscription. 217 | * ` outputValue ` - ` string ` : the output value of inscription. 218 | * ` content ` - ` string ` : the content url of inscription. 219 | * ` contentLength` - ` string ` : the content length of inscription. 220 | * ` contentType ` - ` number ` : the content type of inscription. 221 | * ` preview ` - ` number ` : the preview link 222 | * ` timestamp ` - ` number ` : the blocktime of inscription. 223 | * ` offset ` - ` number ` : the offset of inscription. 224 | * ` genesisTransaction ` - ` string ` : the txid of genesis transaction 225 | * ` location ` - ` string ` : the txid and vout of current location 226 | 227 | #### Example 228 | 229 | ```typescript 230 | try { 231 | let res = await window.unisat.getInscriptions(0,10); 232 | console.log(res) 233 | } catch (e) { 234 | console.log(e); 235 | } 236 | 237 | > { 238 | "total":10, 239 | "list":[ 240 | { 241 | inscriptionId: '6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531i0', 242 | inscriptionNumber: 959941, 243 | address: 'bc1q8h8s4zd9y0lkrx334aqnj4ykqs220ss735a3gh', 244 | outputValue: 546, 245 | preview: 'https://ordinals.com/preview/6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531i0', 246 | content: 'https://ordinals.com/content/6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531i0', 247 | contentLength: 53, 248 | contentType: 'text/plain;charset=utf-8', 249 | timestamp: 1680865285, 250 | genesisTransaction: '6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531', 251 | location: '6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531:0:0', 252 | output: '6037b17df2f48cf87f6b6e6ff89af416f6f21dd3d3bc9f1832fb1ff560037531:0', 253 | offset: 0 254 | } 255 | ] 256 | } 257 | ``` 258 | 259 | 260 | 261 | ### sendBitcoin 262 | 263 | ```typescript 264 | unisat.sendBitcoin(toAddress, satoshis, options) 265 | ``` 266 | 267 | Send BTC 268 | 269 | #### Parameters 270 | 271 | * `toAddress` - `string`: the address to send 272 | * `satoshis` - `number`: the satoshis to send 273 | * `options` - `object`: 274 | - `feeRate` - `number`: the network fee rate 275 | 276 | #### Returns 277 | 278 | * `Promise` - `string`: txid 279 | 280 | #### Example 281 | 282 | ```typescript 283 | try { 284 | let txid = await window.unisat.sendBitcoin("tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz",1000); 285 | console.log(txid) 286 | } catch (e) { 287 | console.log(e); 288 | } 289 | ``` 290 | 291 | ### sendInscription 292 | 293 | ```typescript 294 | unisat.sendInscription(address, inscriptionId, options) 295 | ``` 296 | 297 | Send Inscription 298 | 299 | #### Parameters 300 | 301 | * `options` - `Object`: 302 | - `id` - `string`: the id of Inscription. 303 | - `address` - `string`: the receiver address. 304 | 305 | #### Returns 306 | 307 | * `Promise` - `Object`: 308 | + `txid` - `string` : the txid 309 | 310 | #### Example 311 | 312 | ```typescript 313 | try { 314 | let {txid} = await window.unisat.sendInscription("tb1q8h8s4zd9y0lkrx334aqnj4ykqs220ss7mjxzny","e9b86a063d78cc8a1ed17d291703bcc95bcd521e087ab0c7f1621c9c607def1ai0"); 315 | console.log("send Inscription 204 to tb1q8h8s4zd9y0lkrx334aqnj4ykqs220ss7mjxzny",{txid}) 316 | } catch (e) { 317 | console.log(e); 318 | } 319 | ``` 320 | 321 | ### signMessage 322 | 323 | ```typescript 324 | unisat.signMessage(msg[, address]) 325 | ``` 326 | 327 | sign message 328 | 329 | #### Parameters 330 | 331 | * `msg` - `string`: a string to sign 332 | 333 | #### Returns 334 | 335 | * `Promise` - `string`: the signature. 336 | 337 | #### Example 338 | 339 | ```typescript 340 | try { 341 | let res = await window.unisat.signMessage("abcdefghijk123456789"); 342 | console.log(res) 343 | } catch (e) { 344 | console.log(e); 345 | } 346 | 347 | > IMEo3yzgqJKlmc38IqlP3YjadVOnXmVR6fqeDhtVdiyHUbitYlO2CFUHUgGtM1/cjWsWoGVhTv6pyvj9L/kNT5A= 348 | ``` 349 | 350 | ### pushTx 351 | 352 | ```typescript 353 | unisat.pushTx(options) 354 | ``` 355 | 356 | Push Transaction 357 | 358 | #### Parameters 359 | 360 | * `options` - `Object`: 361 | - `rawtx` - `string`: rawtx to push 362 | 363 | #### Returns 364 | 365 | * `Promise` - `string`: txid 366 | 367 | #### Example 368 | 369 | ```typescript 370 | try { 371 | let txid = await window.unisat.pushTx({ 372 | rawtx:"0200000000010135bd7d..." 373 | }); 374 | console.log(txid) 375 | } catch (e) { 376 | console.log(e); 377 | } 378 | ``` 379 | 380 | 381 | 382 | 383 | ### signPsbt 384 | 385 | ```typescript 386 | unisat.signPsbt(psbtHex) 387 | ``` 388 | 389 | Sign PSBT 390 | 391 | This method will traverse all inputs that match the current address to sign. 392 | 393 | #### Parameters 394 | 395 | * `psbtHex` - `string`: the hex string of psbt to sign 396 | 397 | #### Returns 398 | 399 | * `Promise` - `string`: the hex string of signed psbt 400 | 401 | #### Example 402 | 403 | ```typescript 404 | try { 405 | let res = await window.unisat.signPsbt("70736274ff01007d...."); 406 | console.log(res) 407 | } catch (e) { 408 | console.log(e); 409 | } 410 | ``` 411 | 412 | ### pushPsbt 413 | 414 | ```typescript 415 | unisat.pushPsbt(psbtHex) 416 | ``` 417 | Push transaction 418 | #### Parameters 419 | 420 | * `psbtHex` - `string`: the hex string of psbt to push 421 | 422 | #### Returns 423 | 424 | * `Promise` - `string`: txid 425 | 426 | #### Example 427 | 428 | ```typescript 429 | try { 430 | let res = await window.unisat.pushPsbt("70736274ff01007d...."); 431 | console.log(res) 432 | } catch (e) { 433 | console.log(e); 434 | } 435 | ``` 436 | 437 | ## Events 438 | 439 | 440 | ### accountsChanged 441 | 442 | ```typescript 443 | unisat.on('accountsChanged', handler: (accounts: Array) => void); 444 | unisat.removeListener('accountsChanged', handler: (accounts: Array) => void); 445 | ``` 446 | 447 | The `accountsChanged` will be emitted whenever the user's exposed account address changes. 448 | 449 | 450 | 451 | ### networkChanged 452 | 453 | ```typescript 454 | unisat.on('networkChanged', handler: (network: string) => void); 455 | unisat.removeListener('networkChanged', handler: (network: string) => void); 456 | ``` 457 | 458 | The `networkChanged` will be emitted whenever the user's network changes. 459 | 460 | 461 | -------------------------------------------------------------------------------- /docs/snippets/WatchAssetParams.ts: -------------------------------------------------------------------------------- 1 | interface WatchAssetParams { 2 | type: 'ERC20'; // In the future, other standards will be supported 3 | options: { 4 | address: string; // The address of the token contract 5 | 'symbol': string; // A ticker symbol or shorthand, up to 5 characters 6 | decimals: number; // The number of token decimals 7 | image: string; // A string url of the token logo 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "description": "UniSat documentation.", 4 | "scripts": { 5 | "dev": "yarn start", 6 | "start": "node scripts/build.js dev", 7 | "build": "node scripts/build.js build", 8 | "lint": "prettier docs/guide/*.md docs/snippets/*", 9 | "lint:fix": "yarn lint --write", 10 | "view-info": "vuepress view-info docs", 11 | "show-help": "vuepress --help" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/unisat/unisat-docs/" 16 | }, 17 | "keywords": [ 18 | "documentation", 19 | "vue", 20 | "generator" 21 | ], 22 | "author": "Austin Akers", 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/unisat/unisat-docs/issues" 26 | }, 27 | "homepage": "https://github.com/unisat/unisat-docs", 28 | "devDependencies": { 29 | "@vuepress/plugin-back-to-top": "^1.5.4", 30 | "@vuepress/plugin-medium-zoom": "^1.5.4", 31 | "@vuepress/plugin-pwa": "^1.5.4", 32 | "@vuepress/theme-vue": "^1.5.4", 33 | "dotenv": "^8.2.0", 34 | "prettier": "^2.1.1", 35 | "vue-tabs-component": "^1.5.0", 36 | "vue-toasted": "^1.1.28", 37 | "vuepress": "^1.8.2", 38 | "vuepress-plugin-redirect": "^1.2.4", 39 | "vuepress-plugin-tabs": "^0.3.0" 40 | }, 41 | "dependencies": {} 42 | } 43 | -------------------------------------------------------------------------------- /scripts/build.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config() 2 | 3 | const { dev, build } = require('vuepress') 4 | const config = require('../docs/.vuepress/config')() 5 | 6 | const command = process.argv[2] 7 | 8 | switch (command) { 9 | case 'build': 10 | build(config) 11 | return 12 | 13 | case 'dev': 14 | dev(config) 15 | return 16 | 17 | default: 18 | throw new Error(`Unrecognized command "${command}".`) 19 | } 20 | --------------------------------------------------------------------------------