1
0

Verify.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <main class="p-10">
  3. <h1 class="text-3xl">
  4. Contract Verification
  5. </h1>
  6. <h3 class="text-2xl">
  7. Account: {{account}}
  8. </h3>
  9. <button @click="verify" class="p-3 bg-pink-100 border-2 border-pink-300 rounded-xl">
  10. Start Verifcation
  11. </button>
  12. <select class="mt-5">
  13. <option value="v0.1.1+commit.6ff4cd6">v0.1.1+commit.6ff4cd6</option>
  14. <option value=""></option>
  15. <option value=""></option>
  16. <option value=""></option>
  17. </select>
  18. <div class="mt-5 relative flex items-start">
  19. <div class="flex items-center h-5">
  20. <input id="candidates" aria-describedby="candidates-description" name="candidates" type="checkbox" class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded">
  21. </div>
  22. <div class="ml-3 text-sm">
  23. <label for="candidates" class="font-medium text-gray-700">Optimization</label>
  24. <p id="candidates-description" class="text-gray-500">Enables more efficient gas fees</p>
  25. </div>
  26. </div>
  27. <textarea v-model="source" rows="4" />
  28. </main>
  29. </template>
  30. <script>
  31. /* Import modules. */
  32. import { ethers } from 'ethers'
  33. export default {
  34. data: () => {
  35. return {
  36. compiler: null,
  37. provider: null,
  38. source: null,
  39. contactAddress: null,
  40. optimization: null,
  41. abi: null,
  42. bytecode: null,
  43. account: null,
  44. }
  45. },
  46. methods: {
  47. async verify() {
  48. /* Initialize provider. */
  49. // const provider = new ethers
  50. // .providers
  51. // .Web3Provider(window.ethereum, 'any')
  52. /* Initialize provider. */
  53. this.provider = new ethers
  54. .providers
  55. .JsonRpcProvider('https://smartbch.apecs.dev/testnet')
  56. const contract = new ethers
  57. .Contract(this.contractAddress, this.abi, this.provider)
  58. console.log('CONTRACT', contract)
  59. const retrieve = await contract
  60. .retrieve()
  61. .catch(err => console.error(err))
  62. console.log('RETRIEVE:', retrieve, Number(retrieve))
  63. const bytecode = await this.provider
  64. .getCode(this.contractAddress)
  65. console.log('BYTECODE', bytecode)
  66. // const sample = require('./sample.txt')
  67. // const source = fs.readFileSync('./sample.sol', 'UTF-8')
  68. console.log('SOURCE', this.source)
  69. },
  70. },
  71. created: async function () {
  72. this.compiler = '0.8.7+commit.e28d00a7'
  73. this.contractAddress = '0x68F03cD659289510F88e1F6651b9BC09d12fc8DD'
  74. this.optimization = null
  75. this.abi = [
  76. {
  77. "inputs": [],
  78. "name": "retrieve",
  79. "outputs": [{
  80. "internalType": "uint256",
  81. "name": "",
  82. "type": "uint256"
  83. }],
  84. "stateMutability": "view",
  85. "type": "function"
  86. },
  87. {
  88. "inputs": [{
  89. "internalType": "uint256",
  90. "name": "num",
  91. "type": "uint256"
  92. }],
  93. "name": "store",
  94. "outputs": [],
  95. "stateMutability": "nonpayable",
  96. "type": "function"
  97. }
  98. ]
  99. this.bytecode = '608060405234801561001057600080fd5b50610150806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80632e64cec11461003b5780636057361d14610059575b600080fd5b610043610075565b60405161005091906100d9565b60405180910390f35b610073600480360381019061006e919061009d565b61007e565b005b60008054905090565b8060008190555050565b60008135905061009781610103565b92915050565b6000602082840312156100b3576100b26100fe565b5b60006100c184828501610088565b91505092915050565b6100d3816100f4565b82525050565b60006020820190506100ee60008301846100ca565b92915050565b6000819050919050565b600080fd5b61010c816100f4565b811461011757600080fd5b5056fea2646970667358221220404e37f487a89a932dca5e77faaf6ca2de3b991f93d230604b1b8daaef64766264736f6c63430008070033'
  100. },
  101. mounted: function () {
  102. //
  103. },
  104. }
  105. </script>