Compare commits

..

No commits in common. "10051776b831a8ecf0baa5f1c909a7f98501e901" and "bce3825c4837e8d507ce086e929e36e00003bc8e" have entirely different histories.

3 changed files with 9 additions and 59 deletions

View File

@ -1,13 +1,14 @@
# Faucet Webpage # web
A simple webpage for Goerli Testnet's faucet. This template should help get you started developing with Vue 3 in Vite.
It's HW1 for 1112 NCNU CSIE "Principles and Practice of Blockchains" ## Recommended IDE Setup
link to Metamask and create a transaction to the smart contract to get GoerliETH. [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
![](docs/Screenshot_20230226_025506.png) ## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup ## Project Setup
@ -15,19 +16,6 @@ link to Metamask and create a transaction to the smart contract to get GoerliETH
npm install npm install
``` ```
### fill in your smart contract's address
```javascript
// /src/views/FaucetView.vue line 46
const transactionParameters = {
from: ethereum.selectedAddress,
to: '', // smart contract's address
data: encodeFunctionCall,
value: '0x00',
}
```
### Compile and Hot-Reload for Development ### Compile and Hot-Reload for Development
```sh ```sh
@ -39,11 +27,3 @@ npm run dev
```sh ```sh
npm run build npm run build
``` ```
## Notice
Now, I am not sure of difference between `window.ethereum` & `web3`
I use `window.ethereum` to send transaction, check accounts, check network and use `web3` to encode ABI.
I am not sure whether it's a suitable implementation

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

View File

@ -8,8 +8,7 @@ export default {
return { return {
msg: '', msg: '',
linked: false, linked: false,
amount: 100000000, amount: 100000000
logs: []
} }
}, },
methods: { methods: {
@ -43,7 +42,7 @@ export default {
}, [web3.utils.toBN(this.amount)]) }, [web3.utils.toBN(this.amount)])
const transactionParameters = { const transactionParameters = {
from: ethereum.selectedAddress, from: ethereum.selectedAddress,
to: '', // smart contract's address to: '0x629fe41fd008a169fc073ac7a016401dfd7f17d9',
data: encodeFunctionCall, data: encodeFunctionCall,
value: '0x00', value: '0x00',
} }
@ -55,14 +54,7 @@ export default {
params: [transactionParameters] params: [transactionParameters]
}) })
console.log(txHash) print(txHash)
var amountToSave = this.amount
this.logs.push({
amount: amountToSave,
address: ethereum.selectedAddress,
tx: txHash
})
} }
} }
} }
@ -104,28 +96,6 @@ export default {
</div> </div>
</template> </template>
</div> </div>
<br><br>
<hr>
<br><br>
<template v-if="this.logs.length != 0">
<div class="row justify-content-center">
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0">Your Withdraw</h2>
<table class="table">
<thead>
<td> amount (ETH)</td>
<td> transaction hash </td>
<td> check </td>
</thead>
<tr v-for="log in logs">
<td> {{ Number(BigInt(log.amount))/10**18 }} ETH</td>
<td> {{ log.tx }} </td>
<td> <a v-bind:href='"https://goerli.etherscan.io/tx/"+log.tx'>EtherScan</a> </td>
</tr>
</table>
</div>
</template>
</div> </div>
</section> </section>
</template> </template>