metaplex-foundation / sugar

Candy Machine Rust CLI.
Apache License 2.0
198 stars 111 forks source link

[Feature]: Ability to bypass file upload #280

Closed 0xJohnnyboy closed 1 year ago

0xJohnnyboy commented 1 year ago

Feature

Hi,

I tried to setup a quick CM on devnet earlier today, but I've been frustrated not to be able to easily bypass the upload step: It's not a hidden settings, but all the NFT have the same assets (image and quick video). I wish I could have pre-stored myself just the 2 assets I needed, and then generate my JSON files with these assets already hosted on a shdw drive or whatever.

TL;DR: I want to be able to handle upload myself and go straight to deploy.

EDIT: Forgot to mention that you guys are doing an amazing work. Sugar is way simpler and works extremely well 🙏 Thanks !

Ideal solution or implementation

I see two things that could be improved:

  1. allow the users to put url of files that are not just the same name as the json file: right now, you have 0.png/0.json/0.mp4, 1.png/1.json/1.mp4 .... It could be interesting to be able to put just image.png/0.json/video.mp4 for example (this may work idk but partially: when using animation_url without the proper naming, it simply puts null). Even better, being able to put http links like https://shdw-drive.genesysgo.net/{YOUR ADDRESS}/{YOUR FILE}.

  2. add a parameter in config.json like:

    {
    "upload" : "auto|manual"
    }

    where auto would be the current behaviour and manual would bypass all uploads.

The only thing is for manual upload, I guess the cli would have to ask a list of the NFT addresses to make the cache file and still validate. That could maybe just be a list of addresses, and validation would just check that there are enough addresses to cover the whole supply.

Alternative solutions or implementations

No response

Other context

No response

samuelvanderwaal commented 1 year ago

The deploy command just reads from the cache.json file to know what to upload so you can skip the upload step if you make your own cache file. Example:

{
    "program": {
        "candyMachine": "",
        "candyMachineCreator": "",
        "collectionMint": ""
    },
    "items": {
        "0": {
            "name": "Test NFT #1",
            "image_hash": "",
            "image_link": "https://arweave.net/JaMTex7VDgSI6Z5J7DlXuVmLAqrA48D8e3qb1UxbE_U",
            "metadata_hash": "",
            "metadata_link": "https://arweave.net/6xfhSRFsoZLXeqxzp3ipiukkEYq_8B9o5Zwemcf2j5Q",
            "onChain": false
        },
        "1": {
            "name": "Test NFT #2",
            "image_hash": "",
            "image_link": "https://arweave.net/JaMTex7VDgSI6Z5J7DlXuVmLAqrA48D8e3qb1UxbE_U",
            "metadata_hash": "",
            "metadata_link": "https://arweave.net/6xfhSRFsoZLXeqxzp3ipiukkEYq_8B9o5Zwemcf2j5Q",
            "onChain": false
        },
        "2": {
            "name": "Test NFT #3",
            "image_hash": "",
            "image_link": "https://arweave.net/JaMTex7VDgSI6Z5J7DlXuVmLAqrA48D8e3qb1UxbE_U",
            "metadata_hash": "",
            "metadata_link": "https://arweave.net/6xfhSRFsoZLXeqxzp3ipiukkEYq_8B9o5Zwemcf2j5Q",
            "onChain": false
        },
        "3": {
            "name": "Test NFT #4",
            "image_hash": "",
            "image_link": "https://arweave.net/JaMTex7VDgSI6Z5J7DlXuVmLAqrA48D8e3qb1UxbE_U",
            "metadata_hash": "",
            "metadata_link": "https://arweave.net/6xfhSRFsoZLXeqxzp3ipiukkEYq_8B9o5Zwemcf2j5Q",
            "onChain": false
        }
    }
}

This cache file has four NFTs that all have the same image and JSON URI (you could use different JSON uris too). You can ignore the *_hash fields as those are used by the upload method, just make sure to set onChain to false so Sugar knows to upload the items and also set the correct number of items in the number field in the config.json file. This will create a candy machine with four NFTs that have the data specified. The verify command will still work.

0xJohnnyboy commented 1 year ago

Thanks ! That's good enough for me. I was worried about those *_hash fields but I've got an answer.

What about collections ? I'll probably find my way around exploring generated cache files but that would be great to have the explanation here too.

0xJohnnyboy commented 1 year ago

I'll answer myself here:

As long as the collection item is represented in the cache file with the index -1, you can leave the field in the program part blank, Sugar will complete it during deployment. It sometimes messes up the first time but re-running the deploy seems to solve it.

Here's what it should look like (assuming this in the items part)

{
  ...
  "24": {
    "name": "{YOUR NFT #25}",
    "image_hash": "",
    "image_link": "{YOUR IMAGE URL}",
    "metadata_hash": "",
    "metadata_link": "{YOUR METADATA URL}",
    "onChain": true,
    "animation_link": "{YOUR ANIMATION URL}"
  },
  "-1": {
    "name": "{YOUR COLLECTION NAME}",
    "image_hash": "",
    "image_link": "{YOUR COLLECTION IMG URL}",
    "metadata_hash": "",
    "metadata_link": "{YOUR COLLECTION METADATA URL}",
    "onChain": true
  }
}

I'm closing the issue since @samuelvanderwaal answered the question.