实现eth转账功能

This commit is contained in:
cebgcontract 2022-06-18 18:20:13 +08:00
parent 5a4d7298f9
commit c2ee99b727
5 changed files with 688 additions and 316 deletions

View File

@ -115,6 +115,13 @@ export default class JCWallet {
}
public async sendEth(to: string, amount: number | string) {
let from = this.currentAccount().address;
const amountToSend = this.web3.utils.toWei(amount+'', "ether");
let gas = await this.web3.eth.estimateGas({ from, to, value: amountToSend })
this.web3.eth.sendTransaction({ from, to, gas, value: amountToSend });
}
public async getBalance(address?: string) {
console.log('get balance with address: ', address);
if (!address) {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,9 +0,0 @@
{
"ver": "1.0.5",
"uuid": "1239ade2-21c2-42b1-9449-1c69360bb44f",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": true,
"subMetas": {}
}

View File

@ -125,4 +125,11 @@ export default class WalletController extends cc.Component {
let info = await this.wallet.erc721Standard.getDetails(address, '', '101')
console.log(info)
}
async testSendEth() {
let amount = 0.1
let to = '0x50A8e60041A206AcaA5F844a1104896224be6F39'
let result = await this.wallet.sendEth(to, amount)
console.log(result)
}
}