Releases: onflow/freshmint
v0.0.17 (Alpha 1)
This release brings a new set of features into the Freshmint CLI that have been built and tested over the past several weeks.
Installation
npm install -g freshmint@alpha
Quick Start
# Create a new Freshmint project in ./my-project
fresh start my-project
✨ New Features
On-chain metadata
All NFT metadata is now stored on the blockchain. Gone are the days of external JSON files. Using Cadence's rich type system, Freshmint NFT contracts define metadata using fields directly on the NFT resource.
This opens the door for composable NFTs that can be consumed, extended and integrated by other contracts on the Flow blockchain.
This also means that Freshmint no longer creates JSON files, but still uses IPFS to pin file-based assets such as images, videos and other media. Pinning as changed too, but there's more on that in the breaking changes section below.
TL;DR: a basic NFT now looks like this:
pub resource NFT: NonFungibleToken.INFT {
pub let id: UInt64
pub let name: String
pub let description: String
pub let thumbnail: String
// ...
}
Edition-based NFTs
There's a new contract template for edition-based NFTs. Editions are sets of NFTs that all share the same metadata. The only difference is their serial numbers.
Run fresh start
and choose "Edition NFT" to try it out!
YAML configuration files
Freshmint now stores project configuration in a freshmint.yaml
in your project's root (previously it was fresh.config.js
).
Honestly, this is a bit of an experiment and may not last. But the hope is that Freshmint projects and contracts will be consumed outside of the JavaScript ecosystem, so a JS config file felt limiting. YAML is nice because it allows comments, unlike JSON.
fresh generate
will regenerate your contracts and transactions
You can change your metadata schema in freshmint.yaml
and then run fresh generate cadence
to get new contracts and transactions. This command is useful during local development on the emulator, but should be avoided (or used very carefuly) on live networks like testnet and especially mainnet.
Metadata views
This version extends the metadata schema logic to add initial support for metadata views, with the eventual goal of supporting all core NFT views by default.
Here's what that looks like:
# freshmint.yaml
contract:
name: FooNFT
type: standard
schema:
fields:
- name: name
type: string
- name: description
type: string
- name: thumbnail
type: ipfs-file
views:
- type: display
options:
# Populate the display view from the name, description and thumbnail fields above
name: name
description: description
thumbnail: thumbnail
Freshmint as a Node.js package
Yep, you heard that right. The core Freshmint logic and contract templates are now available as a Node.js package. It doesn't support everything that the CLI does (and vice versa), but it gives JavaScript developers a set of building blocks they can use to build their own tools on top of Freshmint.
Check out the Node.js usage guide, but be warned -- this library is experimental and subject to change.
Asynchronous transaction support
I'm not sure that's the best name for this feature, but let's roll with it. The NFT contract classes provided by the Freshmint Node.js library now allow you to choose when each transaction is sent to the Flow network. Previously they sent the transactions for you, but that can be limiting for advanced users.
For example, deploying a contract now looks like this:
import * as fcl from '@onflow/fcl';
import { FreshmintClient, FreshmintConfig } from 'freshmint';
const client = FreshmintClient.fromFCL(fcl, FreshmintConfig.TESTNET);
// After creating a `contract` instance...
const deployTransaction = contract.deploy(publicKey, hashAlgorithm);
const contractAddress = await client.send(deployTransaction);
❌ Breaking Changes
fresh start
no longer generates a Next.js app
It's coming back and will be better than ever!
The fresh pin
command has been removed
This command doesn't make much sense now that metadata is stored on the blockchain. IPFS fields are now automatically pinned at mint time.
The pin
command was useful for blind mints, but there is a new on-chain blind minting feature coming... (hint: it's already in the Node.js library).
fresh inspect
is now fresh get
It's shorter to type.
The fresh deploy
command has been removed
It's best to just use flow run
on the emulator and flow project deploy
on testnet and mainnet.
⚠️ Deprecation Warnings
@fresh-js/core
and @fresh-js/crypto
are deprecated
Those of you using these libraries can continue to do so and upgrade when you're ready. I'll wait :).
They're not gone, they just moved. I merged all of the former @fresh-js
packages into freshmint
for a couple reasons:
- "Fresh" is already the name of a web framework for Deno.
- The Fresh framework is a larger initiative that will ideally generalize the best parts of Freshmint. But I'm not sure what the best parts are, so for now I'm going to put all the code in one pot and watch the cream rise to the top.
Migration guide
-
Replace imports from
@fresh-js/crypto
withfreshmint/crypto
:// Old code: import { HashAlgorithm } from '@freshjs/crypto'; import { HashAlgorithm } from 'freshmint/crypto';
-
Switch from
Authorizer
toTransactionAuthorizer
:// Old code: // import { Authorizer } from '@freshjs/core'; // const authorizer = new Authorizer({ address, keyIndex, signer }); import { TransactionAuthorizer } from 'freshmint'; const authorizer = new TransactionAuthorizer({ address, keyIndex, signer });
NFT collections are deprecated
You can continue to use these classes and upgrade when you're ready.
The following collection classes from the Node.js package have been deprecated and replaced with equivalent contract classes:
Old class | New class |
---|---|
OnChainCollection |
StandardNFTContract |
OnChainBlindCollection |
BlindNFTContract |
EditionCollection |
EditionNFTContract |
EditionBlindCollection |
BlindEditionNFTContract |
Please see the Node.js usage guide for detailed documentation on how to use the new classes. You'll hopefully notice that not too much has changed.