为okx修改gasLimt和gasPrice的设置方式
This commit is contained in:
parent
22d253fc6a
commit
5cee1d8cde
@ -331,6 +331,15 @@ export class Wallet {
|
||||
return new web3.eth.Contract(abi, address, { from: user });
|
||||
}
|
||||
|
||||
async fetchGasPrice() {
|
||||
const params = []
|
||||
let res = await requestChain(chainData.rpc, 'eth_gasPrice', params)
|
||||
if (res.error) {
|
||||
throw new Error(res.error.message)
|
||||
}
|
||||
return parseInt(res.result) * 2
|
||||
}
|
||||
|
||||
async estimateGas(address, data) {
|
||||
const params = [
|
||||
{
|
||||
@ -354,9 +363,8 @@ export class Wallet {
|
||||
}
|
||||
let web3 = this.web3;
|
||||
const instance = this.initInstance(web3, process.env.VUE_APP_CONTRACT, treasureAbi, address);
|
||||
let gasPrice = await web3.eth.getGasPrice()
|
||||
let gasPrice = await this.fetchGasPrice()
|
||||
// console.log('chainCheckIn gasPrice: ', gasPrice)
|
||||
gasPrice = gasPrice * 2n
|
||||
let gasLimit = await this.estimateGas(address, '0xd8edeb1b');
|
||||
console.log('gasLimit: ', gasLimit, 'gasPrice:', gasPrice)
|
||||
return instance.methods.dailyCheckin().send({ from: address, gasPrice, gasLimit });
|
||||
@ -384,8 +392,7 @@ export class Wallet {
|
||||
let web3 = this.web3;
|
||||
let idBN = web3.utils.toBigInt('0x'+exploreId)
|
||||
const instance = this.initInstance(web3, process.env.VUE_APP_CONTRACT, treasureAbi, address);
|
||||
let gasPrice = await web3.eth.getGasPrice()
|
||||
gasPrice = gasPrice * 2n
|
||||
let gasPrice = await this.fetchGasPrice()
|
||||
// let gasLimit = await instance.methods.explore(idBN).estimateGas({ from: address });
|
||||
const dataStr = '0x6457e389' + exploreId.padStart(64, '0');
|
||||
const gasLimit = await this.estimateGas(address, dataStr)
|
||||
@ -417,7 +424,7 @@ export class Wallet {
|
||||
.join("");
|
||||
let codeBn = web3.utils.toBigInt('0x'+codeHex)
|
||||
const instance = this.initInstance(web3, process.env.VUE_APP_CONTRACT, treasureAbi, address);
|
||||
let gasPrice = await web3.eth.getGasPrice()
|
||||
let gasPrice = await this.fetchGasPrice()
|
||||
// let gasLimit = await instance.methods.enhanceBox(codeBn).estimateGas({ from: address });
|
||||
const dataStr = '0x44a17e06' + codeHex.padStart(64, '0');
|
||||
const gasLimit = await this.estimateGas(address, dataStr)
|
||||
@ -451,8 +458,7 @@ export class Wallet {
|
||||
let boxIdBN = web3.utils.toBigInt('0x'+boxId)
|
||||
const instance = this.initInstance(web3, process.env.VUE_APP_CONTRACT, treasureAbi, address);
|
||||
|
||||
let gasPrice = await web3.eth.getGasPrice()
|
||||
gasPrice = gasPrice * 2n
|
||||
let gasPrice = await this.fetchGasPrice()
|
||||
// let gasLimit = await instance.methods.openBox(boxIdBN).estimateGas({ from: address });
|
||||
const dataStr = '0xb1e5e2b7' + boxId.padStart(64, '0');
|
||||
const gasLimit = await this.estimateGas(address, dataStr)
|
||||
@ -484,8 +490,7 @@ export class Wallet {
|
||||
.join("");
|
||||
let taskIdBN = web3.utils.toBigInt('0x'+taskIdHex)
|
||||
const instance = this.initInstance(web3, process.env.VUE_APP_CONTRACT, treasureAbi, address);
|
||||
let gasPrice = await web3.eth.getGasPrice()
|
||||
gasPrice = gasPrice * 2n
|
||||
let gasPrice = await this.fetchGasPrice()
|
||||
// let gasLimit = await instance.methods.claimTaskReward(taskIdBN).estimateGas({ from: address });
|
||||
const dataStr = '0x4052a9c7' + taskIdHex.padStart(64, '0');
|
||||
const gasLimit = await this.estimateGas(address, dataStr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user