Deploy a token on Base w/ 1 API call

Deploying a Token on Base with Neynar API

This guide provides a step-by-step process to deploy a fungible token on the Base network using Neynar's API. The deployment process is simplified to a single API call, eliminating the need for developers to write Solidity code or handle on-chain transaction signing. Neynar covers the on-chain deployment fees and assigns the specified owner address as the token owner.

Prerequisites

  • Neynar API Key: Ensure you have a valid API key from Neynar. You can obtain one by signing up at neynar.com.
  • Environment Setup: Follow the Getting Started Guide to set up your environment.

API Endpoint

  • Endpoint: /fungible
  • Method: POST
  • Content Type: multipart/form-data

Request Body Schema

The request body should include the following fields:

{
  "owner": "string", // Ethereum address of the token owner
  "symbol": "string", // Symbol/Ticker for the token
  "name": "string", // Name of the token
  "metadata": {
    "media": "string", // Media file or URI associated with the token
    "description": "string", // Description of the token
    "nsfw": "string", // "true" or "false" indicating if the token is NSFW
    "website_link": "string", // Website link related to the token
    "twitter": "string", // Twitter profile link
    "discord": "string", // Discord server link
    "telegram": "string" // Telegram link
  },
  "network": "string", // Default: "base"
  "factory": "string" // Default: "wow"
}

Required Fields

  • owner: Ethereum address of the token creator.
  • symbol: The token's symbol or ticker.
  • name: The name of the token.

Optional Metadata Fields

  • media: Can be a binary file (image/jpeg, image/gif, image/png) or a URI.
  • description: A brief description of the token.
  • nsfw: Indicates if the token is NSFW ("true" or "false").
  • website_link, twitter, discord, telegram: Links related to the token.

Example Request

Here's an example of how to deploy a token using the Neynar API:

import axios from 'axios';
import FormData from 'form-data';

const deployToken = async () => {
  const formData = new FormData();
  formData.append('owner', '0xYourEthereumAddress');
  formData.append('symbol', 'MYTKN');
  formData.append('name', 'My Token');
  formData.append('metadata[description]', 'This is a sample token.');
  formData.append('metadata[nsfw]', 'false');
  formData.append('network', 'base');
  formData.append('factory', 'wow');

  try {
    const response = await axios.post('https://api.neynar.com/fungible', formData, {
      headers: {
        'Content-Type': 'multipart/form-data',
        'Authorization': `Bearer ${process.env.NEYNAR_API_KEY}`
      }
    });
    console.log('Token deployed successfully:', response.data);
  } catch (error) {
    console.error('Error deploying token:', error.response.data);
  }
};

deployToken();

Response

A successful response will include the following details:

{
  "contract": {
    "fungible": {
      "object": "fungible",
      "name": "My Token",
      "symbol": "MYTKN",
      "media": "URI of the token media",
      "address": "Contract address of the token",
      "decimals": 18
    }
  }
}

Conclusion

By following this guide, you can easily deploy a fungible token on the Base network using Neynar's API. This process abstracts the complexities of blockchain development, allowing you to focus on building your application. For further assistance, reach out to Neynar support or consult the Neynar API documentation.