15

does someone know how to buy Solana Nfts from secondary market like Magiceden through programming. I prefer though Python but If you know with another programming language also let me know please. Thanks

3 Answers 3

13

you'd just have to create a script that can create transactions with the correct instructions for the marketplace program for Magic Eden and then submit it to any node. Check out their API documentation because there are endpoints that will return the correct instructions for you https://api.magiceden.dev/

something like

curl --location --request GET 'api-devnet.magiceden.dev/v2/instructions/buy?buyer=AAWVJkRBAdVngqVCwGJcTApD5i4PGkc4kg3UtZ52Y3C8&auctionHouseAddress=E8cU1WiRWjanGxmn96ewBgk9vPTcL6AEZ1t6F6fkgUWe&tokenMint=FxbVG8cxxb845YgWdnB6mBDu6ohkcc7M6nxNoe47Jpm8&price=0.5&buyerReferral=&expiry='
5
  • I tried with their Api but it hasn’t worked. (I’m really new to coding btw)
    – JasOn
    Commented Jul 12, 2022 at 21:47
  • @JasOn I would suggest you get used to using Postman and learn some more about APIs. You dont necessarily need the API to construct the instructions but they offer that service to make it easier for you. Commented Jul 13, 2022 at 0:09
  • Buys will require an API key. See TJs answer for applying.
    – Bryon M
    Commented Jul 14, 2022 at 18:07
  • Also for the node, you can get one free with Chainstack chainstack.com/protocols/solana or other providers listed here solana.com/rpc
    – Ake
    Commented Dec 28, 2023 at 0:24
  • Not directly related to the OP's problem, but it might be useful for others: As a Solana newbie coming from the EVM world, I kept encountering the "failed to generate buy instruction" error when testing against the Magic Eden API. It turns out the price should be formatted as '42.025', which differs from the EVM convention of '42025000000'. I realize this after I see the 'price=0.5' part of this answer, thanks
    – DiveInto
    Commented Nov 29 at 3:40
5

You can use Magic Eden's API to accomplish this.

Find their documentation here: https://api.magiceden.dev/#intro

I saw you mention you tried to use Magic Eden's api to accomplish this but you were unsuccessful.

It may have been because you don't have a valid API key. This is required for any "write" API calls that would return a transaction. I believe their "read" calls don't require an API key.

You can apply for an API key here: https://airtable.com/shrsYtSEJ8M8ESaNq

2
  • Ahh this could be the problem thanks! I think I have to hope that they accept my application then
    – JasOn
    Commented Jul 14, 2022 at 12:42
  • This is correct. We currently run a secondary market via our app that lets us have the same functionality as Magic Eden. Reads do not need a key, writes do. Most information needed can be found in their API docs.
    – Bryon M
    Commented Jul 14, 2022 at 18:06
3

magiceden has a closed source fork of auction house. there are a few people who have reverse engineered some or all of it - but it is a spy vs spy game.

2
  • Okay, do you know if there’s a way through other secondary markets like Coralcube?
    – JasOn
    Commented Jul 12, 2022 at 21:47
  • jordan wrote the actual auction house one of two ways. require ah signing is what opensea uses and they are using the actual auction house, yet gage was required to use this setting so that nobody else could tap into their ah liquidity. that said, there is no way for ah using this setting. without ah signing it is in the cli, easy to compose. jordan joked that he built this option for stacc ha - he meant in spirit of foss.
    – jrsfiend
    Commented Jul 13, 2022 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.