question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ajdusting gasPrice of fulfillOrder method by gasPriceAdditon Method

See original GitHub issue

I am trying to use openseajs library’s fulfillOrder method to buy NFT token. And I want to adjust the gas price to prioritize my transaction. Below shows how I do this.

I pass the tokenId, tokenAddress and owner address as arguments to the .getOrder() method to get the order instance. And then use fulfillOder() method to buy that token. But I realize that I am not able to manipulate the gas price section.

The reason why I want to do this is that in order to buy a certain popular token NFT as soon as it gets ready on sale. especially sometimes the valuable (popular) NFT buying transaction could be difficult to sign through using average gas price, so I would like to make the gas_price higher for certain NFT items. Do you think it will be possible? It will be very appreciated if anyone can let me know how to make this approach.

After checking around, I realized there is a gasPriceAddition property in seaport instance which has a default value as BigNumber(3) as below in source code: Screen Shot 2021-10-14 at 13 54 09

So I tried to adjust the value to set the gas price and I can see it is actually set successfully and then I use it to sign the transaction without problem. the log below is printed out from my console:

[10/14 0 : 31 : 16]   * Estimated gas price: 1.000000018

[10/14 0 : 31 : 17]   * Set fastest gas price 158.000000018

[10/14 0 : 31 : 40] ---> SUCCESS: token bought: 0xa3f6b07b54948081bd7478a5080c96b102bfd35c5fe334eabfd79a7216c20d78 

But when I check the real gas price in the signed transaction from etherscan, it turns out using the average gas price instead of the set gas price. Below is my transaction: https://rinkeby.etherscan.io/tx/0xa3f6b07b54948081bd7478a5080c96b102bfd35c5fe334eabfd79a7216c20d78

I do not know why it is happening, is anybody can let me know why? I also list my code herewith below:


    async buy(order: Order, item: TargetType): Promise<string|Error> { 
        let accountAddress = this.web3._provider.addresses[0]
        let price = order.currentPrice.toString()/1e18

        // fetch all async function return
        let balance = await this.web3.eth.getBalance(accountAddress)/1e18

        this.seaport.gasPriceAddition = this.web3.utils.toBN(String(0));
        let estimatedGasPrice = (await this.seaport._computeGasPrice()).toString()/1e9
        this.printLog(`Estimated gas price: ${estimatedGasPrice}`, "h2")
        let gasPrice = await this.getGasPrice(item.transaction_speed)
        // Set addtionalGas = target gasPric - estimatedPrice
        this.seaport.gasPriceAddition = gasPrice && gasPrice>estimatedGasPrice && this.web3.utils.toBN(String(Math.round(gasPrice-estimatedGasPrice)));        
        
        this.printLog(`Set ${item.transaction_speed} gas price ${(await this.seaport._computeGasPrice()).toString()/1e9}`, "h2" )

        if (balance < item.max_price) {
            this.printLog("---> wallet balance is less than price, breaking the process ....\n", "p")
            process.exit(1);
        } else if (price <= item.max_price) {
            try {
                let transactionHash = await this.seaport.fulfillOrder({ order, accountAddress })
                return transactionHash as string
            } catch (e) {
                return new Error(e as string)
            }
        } else {
            return new Error(`Selling price is larger than max_price: ${item.max_price}`)
        }       
    }

Below is my understanding of source code FYI.

The gasPriceAddition property is used in _computeGasPrice as addition price to add on top of average gasPrice Screen Shot 2021-10-14 at 13 55 27

Then I can see the gasPrice is actually passed into transaction like below: Screen Shot 2021-10-14 at 13 53 30

txHash = await this._wyvernProtocol.wyvernExchange.atomicMatch_.sendTransactionAsync(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], txnData)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:11

github_iconTop GitHub Comments

1reaction
nedosacommented, Oct 17, 2021

I also ran into this, it looks like the SDK does not yet support EIP-1559 type transactions and the gasPrice is not being taken into account. Some other open issues also ask for clarification in that regard: https://github.com/ProjectOpenSea/opensea-js/issues/158

0reactions
walruzperilcommented, Nov 21, 2022

Any update on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Max priority fee EIP-1559 #158 - ProjectOpenSea/opensea-js
Ajdusting gasPrice of fulfillOrder method by gasPriceAdditon Method #203 ... Is there some workaround for setting max priority fee?
Read more >
Gas Tutorial: How to Set Your Own Gas Prices - Medium
Metamask provides a way to set the gas price to be whatever the amount you are willing to pay and will wait to...
Read more >
Ethereum Gas: How to set gas price & gas limit in transactions?
... of web3 - getGasPrice() method of web3 - autoGas feature of TruffleContract - How Metamask handles gasPrice and gasLimit in transactions ...
Read more >
Gas fees EXPLAINED - How to save money when minting NFTs!
GAS FEES! What is this and why are they so freaking high? Gas fees are essential to run the Ethereum network. In this...
Read more >
Setting Transaction Gas Prices - Brownie - Read the Docs
increment : Multiplier applied to the previous gas price in order to ... In this way the price increase starts gradually and ramps...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found