index.vue 29 KB

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