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

How to programmatically create new items under a collection

Open sjkelleyjr opened this issue 5 years ago • 8 comments

Is it possible to programmatically create new items under a collection without owning and deploying a smart contract? Basically, I'd like to automate the "Create" -> "Submit NFTs" -> "Add New Item" workflow on the UI programmatically, and I'm wondering what the best way of doing this is.

If I do have to own and deploy my own smart contract to achieve my goal, could you give some guidance on how best to achieve this goal?

sjkelleyjr avatar Mar 07 '21 01:03 sjkelleyjr

I'm also interested in knowing more about this...

mfsousa avatar Mar 07 '21 06:03 mfsousa

Definitely interested in this, is this even possible to do programmatically at the moment?

MetarDev avatar Mar 30 '21 11:03 MetarDev

Also interested in this. Is that possible? @alexanderatallah @taylorjdawson @DJViau

Thanks guys for awesome product, btw =)

airon-tark avatar Mar 31 '21 11:03 airon-tark

I haven't found an official way to do this but the below flow works for me. I don't want to share my code yet because it's a huge mess and took me a while. But to point you in the right direction go through the creation process and capture the network calls in your browser. It basically boils down to:

  1. Make an unauthed POST request to https://api.opensea.io/graphql/ using the challengeNonceQuery query and passing in your wallet address to get a nonce.

  2. You will need to sign a message with your web3 wallet using the nonce to get a signature - you usually do this via the MetaMask popup. You can automate the signing using web3js, see web3.eth.accounts.sign(data, privateKey). Passing this signature to the same graphql endpoint using authLoginMutation will give you a JWT auth token.

  3. Using the above JWT token you make a request to the same endpoint using collectionManagerAssetCreateMutation and attaching your media.

eth0izzle avatar Apr 20 '21 00:04 eth0izzle

I'd like to know the answer as well

nikodean1 avatar Apr 25 '21 18:04 nikodean1

Also, using Selenium works like a charm :)

pardo-bsso avatar Sep 27 '21 01:09 pardo-bsso

I haven't found an official way to do this but the below flow works for me. I don't want to share my code yet because it's a huge mess and took me a while. But to point you in the right direction go through the creation process and capture the network calls in your browser. It basically boils down to:

  1. Make an unauthed POST request to https://api.opensea.io/graphql/ using the challengeNonceQuery query and passing in your wallet address to get a nonce.
  2. You will need to sign a message with your web3 wallet using the nonce to get a signature - you usually do this via the MetaMask popup. You can automate the signing using web3js, see web3.eth.accounts.sign(data, privateKey). Passing this signature to the same graphql endpoint using authLoginMutation will give you a JWT auth token.
  3. Using the above JWT token you make a request to the same endpoint using collectionManagerAssetCreateMutation and attaching your media.

Always getting {"errors":[{"message":"[401] Not authorized.","locations":[{"line":9,"column":5}],"path":["auth","login"]}],"data":null}

Probably signing issue ?

realstrings avatar Feb 09 '22 13:02 realstrings

Hey @esteban-OpenSea I assume this is because now there's an official way to do it and not just inactivity, right? (or maybe just a joke given it's April 1st...)

pardo-bsso avatar Apr 01 '22 23:04 pardo-bsso