ProjectOpenSea / opensea-js

TypeScript SDK for the OpenSea marketplace
https://docs.opensea.io/reference
MIT License
2.28k stars 964 forks source link

Max priority fee EIP-1559 #158

Closed walruzperil closed 1 year ago

walruzperil commented 3 years ago

Since EIP-1559 need setup Max priority fee. By default it set 1 i think. How we can increase Max priority fee?

overfocus commented 3 years ago

I also need to be able to do this. Does this sdk even support EIP-1559 transactions?

nedosa commented 3 years ago

It would be good to get some clarification on this. Has anyone managed to set a higher gas price in fulfillOrder ?

theboxer commented 3 years ago

Is there some workaround for setting max priority fee?

workhard9999 commented 3 years ago

not here, but there is a solution. there are many bots out there executing with faster than average gas price. not sure if they are going directly through web3 or if they have figured out how to change code here. i have tried both gasPriceAddition and gasIncreaseFactor, neither work. is there a way to hardcode the the transaction data gas?

nmduarteus commented 2 years ago

Was anyone able to go around this problem using the SDK?

hack3r-0m commented 2 years ago

I have a fork https://github.com/hack3r-0m/opensea-js/commit/44feced07439ee48d9b07aa83fc83feb03ac7e1e which returns abi encoded transaction data, you can then send that transaction using ethers.js

nmduarteus commented 2 years ago

I have a fork hack3r-0m@44feced which returns abi encoded transaction data, you can then send that transaction using ethers.js

Thanks. Will give it a try! Just adding your encoded transaction data to the sendTransaction would be enough then, is that it?

hack3r-0m commented 2 years ago
(async () => {
    const order = await seaport.api.getOrder({ side: OrderSide.Sell, asset_contract_address: asset_contract_address, token_id: token_id })
    const abiEncoded = await seaport.fulfillOrder({ order, accountAddress: wallet.address })

    const txn = {
        to: wyvern,
        type: 2,
        data: abiEncoded.encoded,
        value: ethers.BigNumber.from(abiEncoded.txnData.value.toString()),
        maxPriorityFeePerGas: ethers.utils.parseUnits(additionalGas, "gwei"),
        maxFeePerGas: ethers.utils.parseUnits(baseGas, "gwei") + ethers.utils.parseUnits(additionalGas, "gwei")
    }

    try {
        const response = await wallet.sendTransaction(txn)
        console.log(response)
    } catch (e) {
        console.log(e.name)
        console.log(e.message)
    }

})();
nmduarteus commented 2 years ago

thanks a lot. works great!

emorling commented 2 years ago

Thanks, do you have a version for OpenSeaJS 2.0.1?

skyonedot commented 2 years ago

Great, your skill is unparalleled. May i have a question that how could i use it? Sorry, I can only use opensea-js . I don't know how to modify opensea-js module. pay high tribute to you

emorling commented 2 years ago

Any news on this?

Verrok commented 2 years ago
(async () => {
    const order = await seaport.api.getOrder({ side: OrderSide.Sell, asset_contract_address: asset_contract_address, token_id: token_id })
    const abiEncoded = await seaport.fulfillOrder({ order, accountAddress: wallet.address })

    const txn = {
        to: wyvern,
        type: 2,
        data: abiEncoded.encoded,
        value: ethers.BigNumber.from(abiEncoded.txnData.value.toString()),
        maxPriorityFeePerGas: ethers.utils.parseUnits(additionalGas, "gwei"),
        maxFeePerGas: ethers.utils.parseUnits(baseGas, "gwei") + ethers.utils.parseUnits(additionalGas, "gwei")
    }

    try {
        const response = await wallet.sendTransaction(txn)
        console.log(response)
    } catch (e) {
        console.log(e.name)
        console.log(e.message)
    }

})();

Where I can find what wyvern variable is stands for?

Verrok commented 2 years ago
(async () => {
    const order = await seaport.api.getOrder({ side: OrderSide.Sell, asset_contract_address: asset_contract_address, token_id: token_id })
    const abiEncoded = await seaport.fulfillOrder({ order, accountAddress: wallet.address })

    const txn = {
        to: wyvern,
        type: 2,
        data: abiEncoded.encoded,
        value: ethers.BigNumber.from(abiEncoded.txnData.value.toString()),
        maxPriorityFeePerGas: ethers.utils.parseUnits(additionalGas, "gwei"),
        maxFeePerGas: ethers.utils.parseUnits(baseGas, "gwei") + ethers.utils.parseUnits(additionalGas, "gwei")
    }

    try {
        const response = await wallet.sendTransaction(txn)
        console.log(response)
    } catch (e) {
        console.log(e.name)
        console.log(e.message)
    }

})();

Where I can find what wyvern variable is stands for?

nvm, I've understood

robotesteves commented 2 years ago
})();

Could you get this to work with the new contract? I can't seem to get it

esteban-OpenSea commented 2 years ago

Hey, is everyone still having issue with this?

simonare commented 2 years ago

we really need EIP-1559 support to be added to the library (not limited to fulfilorder, but needed to be extended to all transactional operations)

DavydenkovM commented 2 years ago
(async () => {
    const order = await seaport.api.getOrder({ side: OrderSide.Sell, asset_contract_address: asset_contract_address, token_id: token_id })
    const abiEncoded = await seaport.fulfillOrder({ order, accountAddress: wallet.address })

    const txn = {
        to: wyvern,
        type: 2,
        data: abiEncoded.encoded,
        value: ethers.BigNumber.from(abiEncoded.txnData.value.toString()),
        maxPriorityFeePerGas: ethers.utils.parseUnits(additionalGas, "gwei"),
        maxFeePerGas: ethers.utils.parseUnits(baseGas, "gwei") + ethers.utils.parseUnits(additionalGas, "gwei")
    }

    try {
        const response = await wallet.sendTransaction(txn)
        console.log(response)
    } catch (e) {
        console.log(e.name)
        console.log(e.message)
    }

})();

Could someone please explain what wyvern is stands for? It isn't clear how to get this address (@hack3r-0m, @Verrok)

Btw, there's maybe a small issue with big numbers addition, because

const maxFeePerGas = ethers.utils.parseUnits(baseGas, "gwei") + ethers.utils.parseUnits(additionalGas, "gwei";

and

const maxFeePerGas = ethers.utils.parseUnits(`${baseGas + additionalGas}`, "gwei");

is not the same (in my case, the second option is working while the first isn't)

simonare commented 2 years ago

wyvern is the contract address of Opensea's Wyvern Exchange Protocol

bernardovski commented 2 years ago

The transaction to wyvern with the returned abi encoded data keeps failing. I compared the returned abi with the original hex data when buying through OS and it doesn't match.

jerryfane commented 2 years ago

I have a fork hack3r-0m@44feced which returns abi encoded transaction data, you can then send that transaction using ethers.js

How can I make this same change on my code?

Slers commented 2 years ago

@hack3r-0m Thanks for the code, do you happen to have a version which works with the new Opensea-js contracts by any chance?

Verrok commented 2 years ago
wallet.sendTransaction(

Sry for long reply, I've replaced wyvern with invoking seaport.api.getOrderCreateWyvernExchangeAddress()

WebScripti commented 2 years ago
(async () => {
    const order = await seaport.api.getOrder({ side: OrderSide.Sell, asset_contract_address: asset_contract_address, token_id: token_id })
    const abiEncoded = await seaport.fulfillOrder({ order, accountAddress: wallet.address })

    const txn = {
        to: wyvern,
        type: 2,
        data: abiEncoded.encoded,
        value: ethers.BigNumber.from(abiEncoded.txnData.value.toString()),
        maxPriorityFeePerGas: ethers.utils.parseUnits(additionalGas, "gwei"),
        maxFeePerGas: ethers.utils.parseUnits(baseGas, "gwei") + ethers.utils.parseUnits(additionalGas, "gwei")
    }

    try {
        const response = await wallet.sendTransaction(txn)
        console.log(response)
    } catch (e) {
        console.log(e.name)
        console.log(e.message)
    }

})();

Where I can find what wyvern variable is stands for?

Hi, i tried 20 hours this code. My all code below list. This code bought nft but not change gas setting. Please help to me

const Web3 = require('web3'); const express = require('express'); const opensea = require("opensea-js"); const BigNumber = require('bignumber.js'); const from = require('from'); const OrderSide = require("opensea-js/lib/types"); const http = require('http'); const OpenSeaPort = opensea.OpenSeaPort; const Network = opensea.Network; const EventType = opensea.EventType; const ethers = require("ethers");

const privateKey = (walletprivatekey).toString('hex'); const wallet = new ethers.Wallet(privateKey);

const address = wallet.address; console.log("Public Address:", address);

(async () => {

let provider = new HDWalletProvider(walletprivatekey, "https://mainnet.infura.io/v3/MYINFURAKEYINHERE"); const web3 = new Web3(provider); web3.setProvider(provider);

const seaport = new OpenSeaPort(provider, { networkName: Network.Main, apiKey: "MYOPENSEAAPIKEYINHERE" }

let estimatedGasPrice = (await seaport._computeGasPrice()).toString()/1e9*2 seaport.gasPriceAddition = estimatedGasPrice;

console.log(estimatedGasPrice);

const order = await seaport.api.getOrder({ side: 1, asset_contract_address: asset_contract_address, token_id: token_id }) console.log(order); const abiEncoded = await seaport.fulfillOrder({ order, accountAddress: walletno, gasMultiplier: 4 })

const txn = { to: wyvern, type: 2, data: abiEncoded.encoded, value: ethers.BigNumber.from(abiEncoded.txnData.value.toString()), gasLimit: "500000", // basic transaction costs exactly 21000 maxPriorityFeePerGas: ethers.utils.parseUnits('150','gwei'), // Recommended maxPriorityFeePerGas maxFeePerGas: ethers.utils.parseUnits('170','gwei') // Recommended maxFeePerGas }

  try {
    console.log("geliyor");
      const response = await wallet.sendTransaction(txn)
      console.log(response)
  } catch (e) {
      console.log(e.name)
      console.log(e.message)
  }

})();

bernardovski commented 2 years ago

@hack3r-0m since atomic match has been relegated to legacy due to the implementation of the new seaport protocol, is there a way to get abiencoded data from the new seaport fulfillorder method? I managed to get the arguments before transaction is made: image however i don't know how to convert that into this: image

ching2018 commented 2 years ago

@hack3r-0m since atomic match has been relegated to legacy due to the implementation of the new seaport protocol, is there a way to get abiencoded data from the new seaport fulfillorder method? I managed to get the arguments before transaction is made: image however i don't know how to convert that into this: image

Do you solve this problem?

bernardovski commented 2 years ago

@hack3r-0m since atomic match has been relegated to legacy due to the implementation of the new seaport protocol, is there a way to get abiencoded data from the new seaport fulfillorder method? I managed to get the arguments before transaction is made: image however i don't know how to convert that into this: image

Do you solve this problem?

No, still haven't figured out. Unfortunately i'll be just using just the normal fulfillOrder for now without the ability to adjust gas settings. But hopefull someone will explain to us how to adjust gas settings with the new Seaport Contract.

dcapeluto commented 2 years ago

@hack3r-0m since atomic match has been relegated to legacy due to the implementation of the new seaport protocol, is there a way to get abiencoded data from the new seaport fulfillorder method? I managed to get the arguments before transaction is made: image however i don't know how to convert that into this: image

How were you able to get the list of args?

riessnico commented 2 years ago

Any news on this issue? I really need to be able to set the gas params.

Slers commented 2 years ago

You need to reconstitute the order and send it using ethers.js

On 30 Aug 2022, at 18:45, Nicolau Riess @.***> wrote:

 Any news on this issue? I really need to be able to set the gas params.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

Alotrobo commented 2 years ago

Hi, still no solution with the new version? The abiEncoded is not working anymore with ethers.js

emorling commented 2 years ago

We need someone to make a wrapper for this overcomplicated library. Simply:

list() bid() acceptOffer() etc.

dcapeluto commented 2 years ago

Re controlling the gas, download the source of opensea-js and look for the references to seaport-js. Instead of assuming the reference as a dependency, get seaport-js from ProjectOpenSea's repo, and compile it yourself (https://github.com/ProjectOpenSea/seaport-js). You can update the references in opensea-js to seaport-js instead of the default packaged dependency. i.e. to your compiled (e.g. yarn tsc in the root folder of seaport-js) ( in sdk.ts change import { Seaport } from "@opensea/seaport-js"; to import { Seaport } from "./seaport-js/src/seaport"; or wherever you placed the seaport-js code). Then you can peep into the code that creates the fulfillOrder and update it to give you just the order params.

walruzperil commented 2 years ago

any news for new version opensea-js, seaport.fulfillOrder still send transaction in Legacy type)

frxncisjoseph commented 2 years ago

Any update on this? The code no longer works (returns a 404)

frxncisjoseph commented 2 years ago

Managed to get a workaround working with the Opensea Graph QL API.

walruzperil commented 2 years ago

Finally I was able to send a transaction with Max priority and maxFeePerGas image

max1404 commented 1 year ago

Finally I was able to send a transaction with Max priority and maxFeePerGas!)

Very nice! Can you explain it? Thanks <3

YsingKitchen commented 1 year ago

Finally I was able to send a transaction with Max priority and maxFeePerGas image

Can you give me some hints I've been stuck with it for days

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.