index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <script setup lang="ts">
  2. import { storeToRefs } from 'pinia'
  3. import { useCounterStore } from '@/stores/counter'
  4. /* Configure meta tags. */
  5. useHead({
  6. title: 'Bitcoin Cash — APECS Dev',
  7. meta: [
  8. { name: 'description', content: 'Bitcoin Cash toolkit.' }
  9. ],
  10. })
  11. const store = useCounterStore()
  12. const {
  13. count: myCount,
  14. doubleCount: nextCounter
  15. } = storeToRefs(store)
  16. const tryCounter = () => {
  17. store.increment()
  18. }
  19. </script>
  20. <template>
  21. <!-- <main class="relative min-h-screen bg-gray-100"> -->
  22. <main class="py-8 overflow-x-hidden overflow-y-hidden bg-green-400">
  23. <div class="max-w-3xl mx-auto px-4 sm:px-6 lg:max-w-7xl lg:px-8">
  24. <h1 class="sr-only">Profile</h1>
  25. <!-- Main 3 column grid -->
  26. <div class="grid grid-cols-1 gap-4 items-start lg:grid-cols-3 lg:gap-8">
  27. <!-- Left column -->
  28. <div class="grid grid-cols-1 gap-4 lg:col-span-2">
  29. <!-- Welcome panel -->
  30. <section aria-labelledby="profile-overview-title">
  31. <div class="rounded-lg bg-white overflow-hidden shadow">
  32. <h2 class="sr-only" id="profile-overview-title">Profile Overview</h2>
  33. <div class="bg-white p-6">
  34. <div class="sm:flex sm:items-center sm:justify-between">
  35. <div class="sm:flex sm:space-x-5">
  36. <div class="flex-shrink-0">
  37. <img
  38. class="mx-auto h-20 w-20 rounded-full"
  39. src="~/assets/img/logos/BCH.png"
  40. alt=""
  41. />
  42. </div>
  43. <div class="mt-4 text-center sm:mt-0 sm:pt-1 sm:text-left">
  44. <p class="text-sm font-medium text-gray-600">
  45. Connected to Mainnet
  46. </p>
  47. <p class="text-xl font-bold text-gray-900 sm:text-2xl">
  48. Bitcoin Cash
  49. </p>
  50. <p class="text-sm font-medium text-gray-600">
  51. {{account}}
  52. </p>
  53. </div>
  54. </div>
  55. <div class="mt-5 flex justify-center sm:mt-0">
  56. <a @click="testMetaMask" href="javascript://" class="flex justify-center items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
  57. Test MetaMask
  58. </a>
  59. <a @click="tryCounter" href="javascript://" class="flex justify-center items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
  60. Try Counter
  61. </a>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="border-t border-gray-200 bg-gray-50 grid grid-cols-1 divide-y divide-gray-200 sm:grid-cols-3 sm:divide-y-0 sm:divide-x">
  66. <div class="px-6 py-5 text-sm font-medium text-center">
  67. <span class="block text-gray-600">Latest Block Height</span>
  68. <span class="block text-gray-900">{{displayBlockHeight}}</span>
  69. </div>
  70. <div class="px-6 py-5 text-sm font-medium text-center">
  71. <span class="block text-gray-600">Last Block Validator</span>
  72. <span class="block text-gray-900">{{myCount}}</span>
  73. </div>
  74. <div class="px-6 py-5 text-sm font-medium text-center">
  75. <span class="block text-gray-600">Next Difficulty Adjustment</span>
  76. <span class="block text-gray-900">{{nextCounter}}</span>
  77. </div>
  78. </div>
  79. </div>
  80. </section>
  81. <!-- Actions panel -->
  82. <section aria-labelledby="quick-links-title">
  83. <div class="rounded-lg bg-gray-200 overflow-hidden shadow divide-y divide-gray-200 sm:divide-y-0 sm:grid sm:grid-cols-2 sm:gap-px">
  84. <h2 class="sr-only" id="quick-links-title">Quick links</h2>
  85. <div class="rounded-tl-lg rounded-tr-lg sm:rounded-tr-none relative group bg-white p-6 focus-within:ring-2 focus-within:ring-inset focus-within:ring-cyan-500">
  86. <div>
  87. <span class="rounded-lg inline-flex p-3 bg-teal-50 text-teal-700 ring-4 ring-white">
  88. <!-- Heroicon name: outline/clock -->
  89. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
  90. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
  91. </svg>
  92. </span>
  93. </div>
  94. <div class="mt-8">
  95. <h3 class="text-lg font-medium">
  96. <a href="javascript://" class="focus:outline-none">
  97. <!-- Extend touch target to entire panel -->
  98. <span class="absolute inset-0" aria-hidden="true"></span>
  99. Getting Started
  100. </a>
  101. </h3>
  102. <p class="mt-2 text-sm text-gray-500">
  103. Doloribus dolores nostrum quia qui natus officia quod et dolorem. Sit repellendus qui ut at blanditiis et quo et molestiae.
  104. </p>
  105. </div>
  106. <span class="pointer-events-none absolute top-6 right-6 text-gray-300 group-hover:text-gray-400" aria-hidden="true">
  107. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
  108. <path
  109. d="M20 4h1a1 1 0 00-1-1v1zm-1 12a1 1 0 102 0h-2zM8 3a1 1 0 000 2V3zM3.293 19.293a1 1 0 101.414 1.414l-1.414-1.414zM19 4v12h2V4h-2zm1-1H8v2h12V3zm-.707.293l-16 16 1.414 1.414 16-16-1.414-1.414z"
  110. />
  111. </svg>
  112. </span>
  113. </div>
  114. <div class="sm:rounded-tr-lg relative group bg-white p-6 focus-within:ring-2 focus-within:ring-inset focus-within:ring-cyan-500">
  115. <div>
  116. <span class="rounded-lg inline-flex p-3 bg-purple-50 text-purple-700 ring-4 ring-white">
  117. <!-- Heroicon name: outline/badge-check -->
  118. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
  119. <path
  120. stroke-linecap="round"
  121. stroke-linejoin="round"
  122. stroke-width="2"
  123. d="M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z"
  124. />
  125. </svg>
  126. </span>
  127. </div>
  128. <div class="mt-8">
  129. <h3 class="text-lg font-medium">
  130. <NuxtLink to="/smartbch/contracts" class="focus:outline-none">
  131. <!-- Extend touch target to entire panel -->
  132. <span class="absolute inset-0" aria-hidden="true"></span>
  133. Notable Contracts
  134. </NuxtLink>
  135. </h3>
  136. <p class="mt-2 text-sm text-gray-500">
  137. Doloribus dolores nostrum quia qui natus officia quod et dolorem. Sit repellendus qui ut at blanditiis et quo et molestiae.
  138. </p>
  139. </div>
  140. <span class="pointer-events-none absolute top-6 right-6 text-gray-300 group-hover:text-gray-400" aria-hidden="true">
  141. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
  142. <path
  143. d="M20 4h1a1 1 0 00-1-1v1zm-1 12a1 1 0 102 0h-2zM8 3a1 1 0 000 2V3zM3.293 19.293a1 1 0 101.414 1.414l-1.414-1.414zM19 4v12h2V4h-2zm1-1H8v2h12V3zm-.707.293l-16 16 1.414 1.414 16-16-1.414-1.414z"
  144. />
  145. </svg>
  146. </span>
  147. </div>
  148. <div class="relative group bg-white p-6 focus-within:ring-2 focus-within:ring-inset focus-within:ring-cyan-500">
  149. <div>
  150. <span class="rounded-lg inline-flex p-3 bg-sky-50 text-sky-700 ring-4 ring-white">
  151. <!-- Heroicon name: outline/users -->
  152. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
  153. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
  154. </svg>
  155. </span>
  156. </div>
  157. <div class="mt-8">
  158. <h3 class="text-lg font-medium">
  159. <NuxtLink to="/snippets/sol" class="focus:outline-none">
  160. <!-- Extend touch target to entire panel -->
  161. <span class="absolute inset-0" aria-hidden="true"></span>
  162. Solidity Code Snippets
  163. </NuxtLink>
  164. </h3>
  165. <p class="mt-2 text-sm text-gray-500">
  166. Doloribus dolores nostrum quia qui natus officia quod et dolorem. Sit repellendus qui ut at blanditiis et quo et molestiae.
  167. </p>
  168. </div>
  169. <span class="pointer-events-none absolute top-6 right-6 text-gray-300 group-hover:text-gray-400" aria-hidden="true">
  170. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
  171. <path
  172. d="M20 4h1a1 1 0 00-1-1v1zm-1 12a1 1 0 102 0h-2zM8 3a1 1 0 000 2V3zM3.293 19.293a1 1 0 101.414 1.414l-1.414-1.414zM19 4v12h2V4h-2zm1-1H8v2h12V3zm-.707.293l-16 16 1.414 1.414 16-16-1.414-1.414z"
  173. />
  174. </svg>
  175. </span>
  176. </div>
  177. <div class="relative group bg-white p-6 focus-within:ring-2 focus-within:ring-inset focus-within:ring-cyan-500">
  178. <div>
  179. <span class="rounded-lg inline-flex p-3 bg-yellow-50 text-yellow-700 ring-4 ring-white">
  180. <!-- Heroicon name: outline/cash -->
  181. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
  182. <path
  183. stroke-linecap="round"
  184. stroke-linejoin="round"
  185. stroke-width="2"
  186. d="M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z"
  187. />
  188. </svg>
  189. </span>
  190. </div>
  191. <div class="mt-8">
  192. <h3 class="text-lg font-medium">
  193. <NuxtLink to="/smartbch/exchange" class="focus:outline-none">
  194. <!-- Extend touch target to entire panel -->
  195. <span class="absolute inset-0" aria-hidden="true"></span>
  196. Exchange
  197. </NuxtLink>
  198. </h3>
  199. <p class="mt-2 text-sm text-gray-500">
  200. Doloribus dolores nostrum quia qui natus officia quod et dolorem. Sit repellendus qui ut at blanditiis et quo et molestiae.
  201. </p>
  202. </div>
  203. <span class="pointer-events-none absolute top-6 right-6 text-gray-300 group-hover:text-gray-400" aria-hidden="true">
  204. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
  205. <path
  206. d="M20 4h1a1 1 0 00-1-1v1zm-1 12a1 1 0 102 0h-2zM8 3a1 1 0 000 2V3zM3.293 19.293a1 1 0 101.414 1.414l-1.414-1.414zM19 4v12h2V4h-2zm1-1H8v2h12V3zm-.707.293l-16 16 1.414 1.414 16-16-1.414-1.414z"
  207. />
  208. </svg>
  209. </span>
  210. </div>
  211. <div class="sm:rounded-bl-lg relative group bg-white p-6 focus-within:ring-2 focus-within:ring-inset focus-within:ring-cyan-500">
  212. <div>
  213. <span class="rounded-lg inline-flex p-3 bg-rose-50 text-rose-700 ring-4 ring-white">
  214. <!-- Heroicon name: outline/receipt-refund -->
  215. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
  216. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 15v-1a4 4 0 00-4-4H8m0 0l3 3m-3-3l3-3m9 14V5a2 2 0 00-2-2H6a2 2 0 00-2 2v16l4-2 4 2 4-2 4 2z" />
  217. </svg>
  218. </span>
  219. </div>
  220. <div class="mt-8">
  221. <h3 class="text-lg font-medium">
  222. <NuxtLink to="/smartbch/verify" class="focus:outline-none">
  223. <!-- Extend touch target to entire panel -->
  224. <span class="absolute inset-0" aria-hidden="true"></span>
  225. Contract Verification
  226. </NuxtLink>
  227. </h3>
  228. <p class="mt-2 text-sm text-gray-500">
  229. Quickly and easily verify your smart contracts are deployed with the proper bytecode.
  230. </p>
  231. </div>
  232. <span class="pointer-events-none absolute top-6 right-6 text-gray-300 group-hover:text-gray-400" aria-hidden="true">
  233. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
  234. <path
  235. d="M20 4h1a1 1 0 00-1-1v1zm-1 12a1 1 0 102 0h-2zM8 3a1 1 0 000 2V3zM3.293 19.293a1 1 0 101.414 1.414l-1.414-1.414zM19 4v12h2V4h-2zm1-1H8v2h12V3zm-.707.293l-16 16 1.414 1.414 16-16-1.414-1.414z"
  236. />
  237. </svg>
  238. </span>
  239. </div>
  240. <div class="rounded-bl-lg rounded-br-lg sm:rounded-bl-none relative group bg-white p-6 focus-within:ring-2 focus-within:ring-inset focus-within:ring-cyan-500">
  241. <div>
  242. <span class="rounded-lg inline-flex p-3 bg-indigo-50 text-indigo-700 ring-4 ring-white">
  243. <!-- Heroicon name: outline/academic-cap -->
  244. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
  245. <path d="M12 14l9-5-9-5-9 5 9 5z" />
  246. <path d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z" />
  247. <path
  248. stroke-linecap="round"
  249. stroke-linejoin="round"
  250. stroke-width="2"
  251. d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222"
  252. />
  253. </svg>
  254. </span>
  255. </div>
  256. <div class="mt-8">
  257. <h3 class="text-lg font-medium">
  258. <a href="javascript://" class="focus:outline-none">
  259. <!-- Extend touch target to entire panel -->
  260. <span class="absolute inset-0" aria-hidden="true"></span>
  261. Hire A Developer
  262. </a>
  263. </h3>
  264. <p class="mt-2 text-sm text-gray-500">
  265. Doloribus dolores nostrum quia qui natus officia quod et dolorem. Sit repellendus qui ut at blanditiis et quo et molestiae.
  266. </p>
  267. </div>
  268. <span class="pointer-events-none absolute top-6 right-6 text-gray-300 group-hover:text-gray-400" aria-hidden="true">
  269. <svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
  270. <path
  271. d="M20 4h1a1 1 0 00-1-1v1zm-1 12a1 1 0 102 0h-2zM8 3a1 1 0 000 2V3zM3.293 19.293a1 1 0 101.414 1.414l-1.414-1.414zM19 4v12h2V4h-2zm1-1H8v2h12V3zm-.707.293l-16 16 1.414 1.414 16-16-1.414-1.414z"
  272. />
  273. </svg>
  274. </span>
  275. </div>
  276. </div>
  277. </section>
  278. </div>
  279. <!-- Right column -->
  280. <div class="grid grid-cols-1 gap-4">
  281. <Blocks :blockHeight="blockHeight" />
  282. <Txs />
  283. </div>
  284. </div>
  285. </div>
  286. </main>
  287. </template>
  288. <script lang="ts">
  289. /* Import modules. */
  290. import { ethers } from 'ethers'
  291. import numeral from 'numeral'
  292. /* Import components. */
  293. import Blocks from './Blocks'
  294. import Txs from './Txs'
  295. export default {
  296. components: {
  297. Blocks,
  298. Txs,
  299. },
  300. head: () => ({
  301. title: 'Bitcoin Cash — APECS Dev',
  302. meta: [
  303. {
  304. hid: 'description', // `vmid` for it as it will not work
  305. name: 'description',
  306. content: `Bitcoin Cash`
  307. }
  308. ]
  309. }),
  310. data: () => {
  311. return {
  312. account: null,
  313. blockHeight: null,
  314. blocks: null,
  315. }
  316. },
  317. computed: {
  318. displayBlockHeight() {
  319. if (!this.blockHeight) {
  320. return 0
  321. }
  322. return numeral(Number(this.blockHeight)).format('0,0')
  323. }
  324. },
  325. methods: {
  326. async init() {
  327. setInterval(() => {
  328. this.refresh()
  329. }, 1000)
  330. },
  331. async testMetaMask() {
  332. console.log('STARTING METAMASK TEST..')
  333. /* Validate embedded Web3 objects. */
  334. if (!window.ethereum && !window.bitcoin) {
  335. /* Validate embedded ethereum object. */
  336. if (window.bitcoin) {
  337. console.info('Found Bitcoin provider.')
  338. } else if (window.ethereum) {
  339. console.info('Found Ethereum provider.')
  340. } else {
  341. return console.error('No Web3 provider found.')
  342. }
  343. }
  344. /* Initialize provider. */
  345. const provider = new ethers
  346. .providers
  347. .Web3Provider(window.ethereum, 'any')
  348. /* Prompt user for account connections. */
  349. await provider
  350. .send('eth_requestAccounts', [])
  351. .catch(err => console.error(err))
  352. // await provider.send('wallet_watchAsset', {
  353. // type: 'ERC20',
  354. // options: {
  355. // address: '0x0',
  356. // symbol: 'NAME',
  357. // decimals: 18,
  358. // image: 'https://url.here',
  359. // },
  360. // })
  361. // .catch(err => console.error(err))
  362. /* Set signer. */
  363. const signer = provider.getSigner()
  364. /* Request account. */
  365. this.account = await signer.getAddress()
  366. console.log('Account:', this.account)
  367. // const encryptedMessage = '0x94dac27aa0a733b6561bcf39ca05299595f3eba5f47c93b733c0b4f4674d022f3de31d024c0d427cac86465a565929f340cde5693547ad560000845787ba86be1b'
  368. const encryptedMessage = '0x8996f12a91473c48f0c1df0534d7319def26f0fe756428ec2af08794125477ba6703242c211d858241c47a3c7ba1925dbb2baf9fdb42c71f08cd738139a86f211b'
  369. const msg = await provider
  370. .send('eth_decrypt', [ encryptedMessage, this.account ])
  371. .catch(err => console.error(err))
  372. console.log('DECRYPTED MESSAGE', msg)
  373. // const encryptionKey = await provider
  374. // .send('eth_getEncryptionPublicKey', [ this.account ])
  375. // .catch(err => console.error(err))
  376. // console.log('ENCRYPTION KEY', encryptionKey)
  377. },
  378. async testSigning() {
  379. console.log('STARTING SIGNING TEST..')
  380. /* Validate embedded Web3 objects. */
  381. if (!window.ethereum && !window.bitcoin) {
  382. /* Validate embedded ethereum object. */
  383. if (window.bitcoin) {
  384. console.info('Found Bitcoin provider.')
  385. } else if (window.ethereum) {
  386. console.info('Found Ethereum provider.')
  387. } else {
  388. return console.error('No Web3 provider found.')
  389. }
  390. }
  391. /* Initialize provider. */
  392. const provider = new ethers
  393. .providers
  394. .Web3Provider(window.ethereum, 'any')
  395. /* Set signer. */
  396. const signer = provider.getSigner()
  397. /* Request account. */
  398. this.account = await signer.getAddress()
  399. console.log('Account:', this.account)
  400. // All properties on a domain are optional
  401. // const domain = {
  402. // name: 'APECS',
  403. // version: '1',
  404. // chainId: 0x2711,
  405. // // verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
  406. // }
  407. // The named list of all type definitions
  408. // const types = {
  409. // Person: [
  410. // { name: 'name', type: 'string' },
  411. // { name: 'wallet', type: 'address' }
  412. // ],
  413. // Mail: [
  414. // { name: 'from', type: 'Person' },
  415. // { name: 'to', type: 'Person' },
  416. // { name: 'contents', type: 'string' }
  417. // ],
  418. // }
  419. // The data to sign
  420. // const value = {
  421. // from: {
  422. // name: 'Cow',
  423. // wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826'
  424. // },
  425. // to: {
  426. // name: 'Bob',
  427. // wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'
  428. // },
  429. // contents: 'Hello, Bob!'
  430. // }
  431. // const signature = await signer
  432. // ._signTypedData(domain, types, value)
  433. // .catch(err => console.error(err))
  434. // console.log('SIGNATURE', signature)
  435. const plaintext = 'hi there everyone!'
  436. const signature = await signer
  437. .signMessage(plaintext)
  438. .catch(err => console.error(err))
  439. console.log('SIGNATURE', signature)
  440. },
  441. smartBCHProvider: function () {
  442. return {
  443. chainId: "0x2710",
  444. rpcUrls: [
  445. "https://smartbch.greyh.at",
  446. "https://smartbch.fountainhead.cash/mainnet",
  447. ],
  448. chainName: "smartBCH",
  449. nativeCurrency: {
  450. name: "Bitcoin Cash",
  451. symbol: "BCH",
  452. decimals: 18,
  453. },
  454. blockExplorerUrls: ["https://smartscan.cash"],
  455. iconUrls: ["https://smartmask.cash/img/smartbch_logo.png"],
  456. }
  457. },
  458. attemptMetaMaskProviderRegistration: async function () {
  459. try {
  460. await window.ethereum.request({
  461. method: "wallet_switchEthereumChain",
  462. params: [{ chainId: "0x2710" }],
  463. })
  464. return true
  465. } catch (switchError) {
  466. // This error code indicates that the chain has not been added to MetaMask.
  467. if (switchError.code === 4902) {
  468. try {
  469. await window.ethereum.request({
  470. method: "wallet_addEthereumChain",
  471. params: [this.smartBCHProvider()],
  472. });
  473. return true;
  474. } catch (addError) {
  475. return false;
  476. }
  477. }
  478. return false
  479. }
  480. },
  481. async refresh() {
  482. //
  483. },
  484. },
  485. created: async function () {
  486. /* Initialize block height. */
  487. // NOTE: Use hex format.
  488. this.blockHeight = '0x0'
  489. /* Initialize (connected) account. */
  490. this.account = 'no account connected'
  491. /* Start initialization. */
  492. // this.init()
  493. },
  494. mounted: function () {
  495. //
  496. },
  497. }
  498. </script>