ProjectOpenSea / opensea-js

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

seaport.createBuyOrder is not working - returns 429 error every time. #189

Closed SourceSafe closed 2 years ago

SourceSafe commented 2 years ago

Hi Team

I'm using code from the opensea-creatures project (sell.js) to create an OpenSeaPort instance and call seaport.createBuyOrder()

My Node & npm versions C:\Users\Owner>node -v v12.18.4

C:\Users\Owner>npm -v 6.14.6

Script const {OpenSeaPort,Network} = require('opensea-js') const RPCSubprovider = require('web3-provider-engine/subproviders/rpc') const Web3ProviderEngine = require('web3-provider-engine') const {MnemonicWalletSubprovider} = require('@0x/subproviders'); const accountAddress = "0x2c649A72529FfB801825a52136e0D5C8F171f6Bd" const API_KEY = ""; const NFT_CONTRACT_ADDRESS_SVS = "0x219b8ab790decc32444a6600971c7c3718252539"; const NFT_TOKEN_ID = "3400"; const NETWORK = "mainnet"; const NODE_API_KEY = "e1d6858ba67049bc934a9b764efb9c31"; const isInfura = true;//!!process.env.INFURA_KEY; const MNEMONIC = "My Metamask Mneumonic here"; const BASE_DERIVATION_PATH = 44'/60'/0'/0; const network = NETWORK === "mainnet" || NETWORK === "live" ? "mainnet" : "rinkeby";

const mnemonicWalletSubprovider = new MnemonicWalletSubprovider({ mnemonic: MNEMONIC, baseDerivationPath: BASE_DERIVATION_PATH, });

const infuraRpcSubprovider = new RPCSubprovider({ rpcUrl: isInfura ? "https://" + network + ".infura.io/v3/" + NODE_API_KEY : "https://eth-" + network + ".alchemyapi.io/v2/" + NODE_API_KEY, });

const providerEngine = new Web3ProviderEngine(); providerEngine.addProvider(mnemonicWalletSubprovider); providerEngine.addProvider(infuraRpcSubprovider); providerEngine.start();

const seaport = new OpenSeaPort( providerEngine, { networkName: NETWORK === "mainnet" || NETWORK === "live" ? Network.Main : Network.Rinkeby, apiKey: API_KEY, }, (arg) => console.log(arg) );

placeOffer(NFT_CONTRACT_ADDRESS_SVS, NFT_TOKEN_ID, 0.0000001, Math.round(Date.now() / 1000 + 60 * 3))

async function placeOffer(address, tokenId, price , expirationTime) {
const asset = { tokenId: tokenId, tokenAddress: address, } try{
const makeOffer = await seaport.createBuyOrder({ asset: asset, accountAddress,
startAmount: price, expirationTime })
console.log(Successfully created a offer! ${makeOffer.asset.openseaLink}); } catch(ex) { console.log(ex) }
}

packages.json

{ "name": "newscript", "version": "1.0.0", "description": "", "main": "test.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "@0x/subproviders": "^6.4.1", "opensea-js": "^1.1.5" }, "engines": { "node": "^12.18.x"
} }

When i run the script the sdk outputs the following log to console :- Already approved enough currency for trading Order hashes match

but then it always returns the 429 Error: API Error 429: Message: {"detail":"Request was throttled."}

I understand throttling. Why is it that I'm getting the 429 when I have never once called this function successfully. I've most certainly not called it multiple times a second or at any rate to induce throttling limits.. In fact even when I leave it for 24 hrs plus and try again it give me the 429.

I have the correct node version installed as specified in the engines section in the opensea-creatures package.json.

I also have the same node module dependencies as opensea-creatures

"@0x/subproviders": "^6.4.1", "opensea-js": "^1.1.5"

My code to create the OpenSeaPort client is identical to the opensea-creatures script file. Yet it still return 429.

I know all the the code is OK because when I run the same code from a react-app the buy order is placed successfully. But I cannot get it to run from script.

I know that I don't need an API key because the code runs successfully from my react-app.

please help ! I much appreciate the sdk but why the persistent 429?

Also what is the magic combination of latest node and opensea modules that I can use to place a buy order ??

pguardiario commented 2 years ago

Maybe another device on your network is hitting opensea very fast.

pguardiario commented 2 years ago

This one should probably get closed since there's no solution other than to slow down.

SourceSafe commented 2 years ago

I don’t think you understand the problem. How can I slow down anymore . Even if I call it once a week it throws a 429.

There are no other devices running anywhere.

Have you actually tested the code snipit provided ? You will get the same problem and hopefully be able to explain what the problem is.

azvast commented 2 years ago

I have posted answer here. [https://github.com/ProjectOpenSea/opensea-js/issues/193]

I faced same error and I fixed it with 1 min 20 s delay when I got 429 error. Even if I call the method one time, it throws the 429 error about my request.

So you need to wait when you got the error. Hope you to solve this problem.

river-korbit commented 2 years ago

@alexandera73 Was it fixed by that way? I call createBuyOrder just once, but I god 429 error.

azvast commented 2 years ago

Yes, it will work well. If it doesn't work, please increase the delay time with over 2min.

SourceSafe commented 2 years ago

So the expected behaviour is :-

Why is the expected behaviour that It will always fail on the first call ? - surely this is BUG.

Blaschuko commented 2 years ago

@alexanderatallah Is there something we are missing? I'm working on a bot that needs this function, and I can't wait +2 minutes every time I need to use it.

azvast commented 2 years ago

Please use createBundleBuyOrder() function then.

Blaschuko commented 2 years ago

I'm using it, but still getting the same response.

fabdarice commented 2 years ago

same error :(

ism commented 2 years ago

Your API key is overused by dozen of bots, no wonder you were throttled. Change opensea api key.

SourceSafe commented 2 years ago

Read the above problem again. I clearly state that i don’t use an api key. Have you looked at the code that I posted and seen an opensea api key? There is no opensea api key so how can it be used by anyone else.

The devs here are terrible . I posted here to get a response from a dev who knows what’s going on. Any devs there to respond ?

Sent from my iPhone

On 18 Oct 2021, at 07:27, ism @.***> wrote:

 Your API key is overused by dozen of bots, no wonder you were throttled. Change opensea api key.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

ANG3L0 commented 2 years ago

Were you even able to get this working with the hack? I wasn't able to create a sell order successfully even if I were to wait 80 seconds or 2 minutes or whatever. It just always 429s.

river-korbit commented 2 years ago

Me, too. I got alway 429s!!!!! @ANG3L0

esteban-OpenSea commented 2 years ago

Please follow https://github.com/ProjectOpenSea/opensea-js/issues/86 issue for the latest update on the 429 issues. Closing this out so since it's a duplicate case.

Also, the rate limit is 4/sec