1
0

index.vue 29 KB

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