metaplex-foundation / sugar

Candy Machine Rust CLI.
Apache License 2.0
200 stars 114 forks source link

[Bug]: Can't launch a CM with an SplToken mint on devnet #281

Closed 0xJohnnyboy closed 2 years ago

0xJohnnyboy commented 2 years ago

Issue description

Hi,

I tried to set up a CM (on devnet) with an Spl token, basically so that people can mint using USDC. But when using the launch command, I get an error (see relevant log output section).

I used this Spl Token mint address at first 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU which is USDC, and then I created a token account using the spl-token tool suite, which is SPZPFkHV7LKzENjXCvMYTCioS5CDhJvtNFKn7tcfDm8.

I used this config file. My assets are fine since it runs flawlessly without the Spl setting. EDIT: {VARIABLE} are placeholder for actual addresses or values

{
  "price": 1.0,
  "number": 25,
  "gatekeeper": null,
  "creators": [
    {
      "address": "{MY WALLET ADDRESS}",
      "share": 100
    }
  ],
  "solTreasuryAccount": null,
  "splTokenAccount": "{MY WALLET ADDRESS}",
  "splToken": "{SPL TOKEN ADDRESS}",
  "goLiveDate": "18 Jul 2022 17:00:24 +0000",
  "endSettings": null,
  "whitelistMintSettings": {
    "mode": "burnEveryTime",
    "mint": "{WL TOKEN ADDRESS}",
    "presale": true,
    "discountPrice": null
},
  "hiddenSettings": null,
  "uploadMethod": "bundlr",
  "retainAuthority": true,
  "isMutable": true,
  "symbol": "{MY SYMBOL}",
  "sellerFeeBasisPoints": 800,
  "awsS3Bucket": null,
  "nftStorageAuthToken": null,
  "shdwStorageAccount": null
}

I also clone Sugar and tried looking for the error message using ctrl + shift + F, but nothing came up.

Is this related to devnet ? I don't really mind trying mainnet if you tell me this should work but people should at least be aware that it breaks on devnet if that's the case.

Thanks for reading :)

Relevant log output

>>> sugar deploy

[1/3] 🍬 Creating candy machine

🛑 Error running command (re-run needed): An account's data contents was invalid

Priority this issue should have

Medium (should be fixed soon)

samuelvanderwaal commented 2 years ago

Thanks for all the detail and the clear description in the bug report, this makes it much easier to troubleshoot.

The splTokenAccount should be the SPL token account address where you want to receive the SPL tokens from mint proceeds. You didn't specify an actual address but from the variable you used it looks like you're using your wallet address instead of an actual SPL token account. If that's the case, you can just leave that value blank and Sugar will create the associated token account for your user wallet by default (user wallet = signing keypair running the command).

That's likely the issue. If you can try putting in an actual SPL token address or leaving it blank and rerunning, let me know if that works. If not, we'll do more troubleshooting.

0xJohnnyboy commented 2 years ago

Oh sorry that wasn't really clear, I'm actually using an address, that's just a placeholder to say what I'm using because I figured an arbitrary base58 chain wouldn't mean anything for debugging purposes. I'm using the same wallet address that I use in creators field.

I'll edit the original post right now.

I didn't know that Sugar would create the account I'll try that ASAP this evening and I'll let you know.

0xJohnnyboy commented 2 years ago

Leaving the splTokenAccount field blank solved it for me, thanks @samuelvanderwaal 🎉 🙏

But if I were to put one, what should I put exactly ? Since this is not part of Sugar docs, I referred to the CMV2 docs which state the following:

splTokenAccount   PublicKey SPL token wallet to receive proceedings from SPL token payments

This may be candid, but I thought I just had to put my wallet address. I assume the spl-token create-account {json file} creates the account needed for the keypair in solana config. Am I right ?

samuelvanderwaal commented 2 years ago

Leaving the splTokenAccount field blank solved it for me, thanks @samuelvanderwaal tada pray

But if I were to put one, what should I put exactly ? Since this is not part of Sugar docs, I referred to the CMV2 docs which state the following: splTokenAccount PublicKey SPL token wallet to receive proceedings from SPL token payments

This may be candid, but I thought I just had to put my wallet address. I assume the spl-token create-account {json file} creates the account needed for the keypair in solana config. Am I right ?

Yeah, the description here isn't the best. Sugar is currently expecting either: 1) a blank field or 2) an actual SPL token account.

If you leave the field blank it creates the associated SPL token account for your wallet. If you provide a specific SPL token account, it uses that to send received SPL token funds to.

In case the confusion here is around SPL token accounts:

Native Solana wallets can only hold SOL, not SPL tokens. SPL tokens are always stored at a token account that is specific to the mint for that SPL token. Associated token accounts are ways to deterministically derive the token account for any given wallet. You can read more about that here.

0xJohnnyboy commented 2 years ago

Thanks for the in depth explanation. I'm closing the issue since I can confirm this works fully, on devnet, mainnet with a spl-token account.