opensea-js icon indicating copy to clipboard operation
opensea-js copied to clipboard

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

Open SourceSafe opened this issue 5 years ago • 16 comments

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 ??

SourceSafe avatar Sep 30 '21 09:09 SourceSafe

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

pguardiario avatar Oct 07 '21 01:10 pguardiario

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

pguardiario avatar Oct 07 '21 01:10 pguardiario

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.

SourceSafe avatar Oct 07 '21 11:10 SourceSafe

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.

azvast avatar Oct 08 '21 05:10 azvast

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

river-korbit avatar Oct 08 '21 07:10 river-korbit

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

azvast avatar Oct 08 '21 08:10 azvast

So the expected behaviour is :-

  • try and place a buy order
  • you will get a 429 on the first call - why is this ? surely it should not always fail on the first call.
  • then sleep for 1min 20 sec / 2 mins
  • repeat till order is place

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

SourceSafe avatar Oct 08 '21 15:10 SourceSafe

@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.

Blaschuko avatar Oct 08 '21 18:10 Blaschuko

Please use createBundleBuyOrder() function then.

azvast avatar Oct 08 '21 19:10 azvast

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

Blaschuko avatar Oct 08 '21 19:10 Blaschuko

same error :(

fabdarice avatar Oct 11 '21 23:10 fabdarice

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

ism avatar Oct 18 '21 06:10 ism

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.

SourceSafe avatar Oct 19 '21 07:10 SourceSafe

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.

ANG3L0 avatar Nov 03 '21 09:11 ANG3L0

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

river-korbit avatar Nov 08 '21 01:11 river-korbit

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

esteban-OpenSea avatar Apr 18 '22 23:04 esteban-OpenSea