wutayng / moments-cadence

NFT Moments Cadence/Flow Smart Contracts and JS/Node/Jest Testing
3 stars 1 forks source link

Setup

  1. Configure a ./flow.json to deploy the 5 contracts to the Emulator Account

    https://docs.onflow.org/flow-cli/configuration/
    "contracts": {
      "Moments": "./contracts/Moments.cdc",
      "MomentsMarket": "./contracts/MomentsMarket.cdc",
      "FungibleToken": "./contracts/FungibleToken.cdc",
      "FUSD": "./contracts/FUSD.cdc",
      "NonFungibleToken": "./contracts/NonFungibleToken.cdc"
    },
    "accounts": {
      "emulator-account": {
        "address": "f8d6e0586b0a20c7",
        "keys": "xxxxx",
        "chain": "flow-emulator"
      }
    },
    "deployments": {
      "emulator": {
        "emulator-account": [
          "Moments",
          "MomentsMarket",
          "NonFungibleToken",
          "FungibleToken",
          "FUSD"
        ]
      }
    },
  2. Configure .env with the Emulator HTTP server port and Emulator account address

Test

Run Jest testing suites to test contracts with Scripts and Transactions

  1. Start the flow emulator in the same repo directory

    flow emulator

  2. Deploy Contracts to the Emulator Account

    flow project deploy --network=emulator

  3. npm test

    This runs all tests sequentially, so there are no overlapping transaction errors in the emulator - which look like this:

    invalid proposal key: public key 0 on account f8d6e0586b0a20c7 has sequence number 19, but given 18

    Once the test suites are run, 4 accounts will be set up, FUSD and Moments minted, sent, put up for sale, removed from the market, and bought/sold.

Use Cadence Scripts & Transactions

Examples:

Testnet Deployment

flow project deploy --network=testnet

Attribution

Most of the cadence smart contracts are templated off of the kitty-items example application.

https://github.com/onflow/kitty-items