Skip to content

Latest commit

 

History

History

getting-started-expressjs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Getting Started with Metaplex and Express.js

This example sets up a new Express.js app with Metaplex.

The Express.js app contains one route that accepts a mint address and returns the associated NFT object as the response. It requires Node.js to run.

  1. Create a new Express.js project.

     mkdir getting-started-expressjs
     cd getting-started-expressjs
     npm init -y
     npm install express
  2. Install the Metaplex and Solana SDKs.

    npm install @metaplex-foundation/js @solana/web3.js
  3. Create your index file.

    Create a new index file that will be the main entry point for your app.

    touch index.cjs

    Then, copy/paste the source code from index.cjs inside that file.

  4. Provide the path to your keypair.

    Ensure the pathToMyKeypair points to whichever local keypair you want to use.

    const pathToMyKeypair = process.env.HOME + "/.config/solana/id.json";
  5. Run the server.

    node index.cjs
  6. Send a request to your server.

    Open the following URL in your browser:

    http://localhost:3000/getNFT?mint=xxx

    Where xxx is the mint address of the NFT you want to query.

  7. That's it. 🎉

    Feel free to play with the index.cjs to see what else you can do with the Metaplex JS SDK.

Learn More

Here are some useful resources for you if you'd like to learn more about the Metaplex JS SDK: