hashlips-lab / safe-nft-metadata-provider

A safe metadata provider for your NFT collection.
MIT License
74 stars 77 forks source link

Version 2.0.0 #48

Closed liarco closed 2 years ago

liarco commented 2 years ago

This new implementation is a complete redesign of the whole app which is based on the new @hashlips-lab/collection-data-updater library.

⚠️ Disclaimer ⚠️

This version is experimental, it may not work properly at this stage. Use at your own risk!

During this beta stage I won't provide any support for customizations. I have to finalize this implementation first and release the stable version before I can focus on custom features.

Why?

Deprecated features

How it works

This version works in a completely different way compared to version 1. With version 1 the app was serving the file directly, with version 2 the app is simply updating the files on the S3 storage, the files will be served by the S3 storage itself. All your files will be stored on an S3 bucket inside a /private folder and your URI prefix will point to the public URL of a /public folder at the same level of your private one.

Example: If you have your assets on a DigitalOcean space called my-bucket, on region FRA1, then the URL of the metadata for token 1 will be https://fra1.digitaloceanspaces.com/my-bucket/public/metadata/1.json. Your URI prefix for this setup would be https://fra1.digitaloceanspaces.com/my-bucket/public/metadata/.

You won't have to put anything into the /public folder, the app will create it for you and copy all the data whenever a new token has to be revealed. It's extremely important that you make sure your files in the /private folder are not publicly accessible (you can set file permissions on your file manager of choice).

How to use it

The following instructions take into consideration a basic deployment using the default configuration.

Requirements

  1. you must have an S3 bucket (e.g. DigitalOcean's space) configured properly (file listing disabled, all files private, CDN is optional but highly recommended, with a cache time of at least 1 minute)
  2. you have to upload your files to your bucket inside a dedicated private folder (/private) and they must not be publicly readable (that's usually the default policy on DigitalOcean, but make sure you can't access them using the direct URL). The private folder must contain both the assets and metadata folders with all your files in it. (hidden metadata and mapping files are not needed anymore)

Deployment steps

  1. open the v2 branch page on GitHub and click on the "Deploy to DigitalOcean" button
  2. you can lower the plan to the 5$/month one
  3. set the values for the environment variables in your worker's settings:
    • RPC_ENDPOINT: an RPC endpoint for your chain (e.g. use Infura or a public node of your choice)
    • CONTRACT_ADDRESS: the contract address
    • START_TOKEN_ID: ID of the first token of your collection (default: 1)
    • PRIVATE_ASSETS_PATH: private path of your assets (default: /private/assets)
    • PUBLIC_ASSETS_PATH: public path of your assets (default: /public/assets)
    • ASSETS_EXTENSION: the default project supports standard collections only, so here you can specify only one extension (you can override this behavior with custom code)
    • PRIVATE_METADATA_PATH: private path of your metadata (default: /private/metadata)
    • PUBLIC_METADATA_PATH: public path of your metadata (default: /public/metadata)
    • PUBLIC_ASSETS_URI_TEMPLATE: all token files will be "revealed" by copying them over to a /public folder at the same level of your /private one. This URL template should point to the public URL of your S3 storage (you can use the {{TOKEN_ID}} placeholder as the file name)
    • S3_ACCESS_KEY: S3 bucket access key
    • S3_SECRET_KEY: S3 bucket secret key
    • S3_ENDPOINT_URL: S3 API endpoint URL (please make sure to specify the correct region if you are using DigitalOcean)
    • S3_BUCKET_NAME: S3 bucket name
    • S3_PATH_PREFIX: you can leave this blank if you uploaded your files to the root path of your bucket
    • FULL_REFRESH_DELAY: number of seconds to wait before doing a full collection refresh (default: 1800, 30 minutes). Please remember that tokens will be automatically revealed on each mint, so there is no need to run this too often. It's purpose is to keep everything in sync after network issues occur or the if app crashes for any reason

Once the deployment is ready you should start seeing something happening in the "Runtime Logs" section of your app. Your metadata and images should appear in the /public folder automatically as soon as they are revealed.