Packages
Upload Moments

Upload Moments

A moment can contain an image and/or text. With MomentsClient is easy to upload an image and create it as a moment associated with a Drop or a POAP.

From Node.js

import mime from 'mime';
import fsPromises from 'fs/promises';
import { Moment } from '@poap-xyz/moments';
 
// Load the image of the moment.
const fileBuffer = await fsPromises.readFile('path/to/poap-moment.png');
const mimeType = mime.getType('path/to/poap-moment.png');
 
// Upload it.
const moment: Moment = await client.createMoment({
  /**
   * Moments are associated with a Drop.
   */
  dropId: 110148,
 
  /**
    * The Token ID related to the moment (optional).
    */
  tokenId: 6568008,
 
  /**
   * Who is uploading the moment.
   */
  author: '0x82AB2941Cf555CED5ad7Ed232a5B5f6083815FBC',
 
  /**
   * The list of images in the moment.
   */
  media: [
    {
      fileBinary: fileBuffer,
      fileType: mimeType,
    },
  ],
 
  /**
   * Some text to describe the moment.
   */
  description: 'Look how much fun we were having!',
});