Steemhunt / mint.club-v2-sdk

25 stars 2 forks source link

mintclub.network("avalanchefuji").token('SuperSquad').create({...params}) returns undefined #1

Open Resister-boy opened 6 months ago

Resister-boy commented 6 months ago

I just follow the official documentation but function create({...params}) returns undefined. We are planning build with mintclub-sdk how can i get returns Promise from function create({...params})

ggomaeng commented 6 months ago

could you please share the code you used?

Resister-boy commented 6 months ago
  const mmValue = mintclub.network("avalanchefuji").nft('SuperSquad');

  const createToken = async () => {
    try {
      const res = await mmValue.create({
        name: 'SuperSquad',

        reserveToken: {
          address: '0x4200000000000000000000000000000000000006',
          decimals: 18,
        },
        // Bonding curve data
        curveData: {
          curveType: 'EXPONENTIAL',

          stepCount: 10, // how granular the curve is
          maxSupply: 10_000, // NFT max supply
          initialMintingPrice: 0.01, // starting price, 0.01 WETH
          finalMintingPrice: 0.1, // ending price, 0.1 WETH
          creatorAllocation: 100, // initial supply to the deployer
        },
        metadataUrl: 'https://api.filebase.io/v1/ipfs',
      });

      console.log('res', res);
    } catch (e) {
      console.log(e);
    }
  };
ggomaeng commented 6 months ago

Note that create function can also return undefined if it runs into an error.

You should use use the callback functions provided.

The flow goes

  1. Create token function called https://sdk.mint.club/docs/sdk/network/token/create#onsignaturerequest-optional
  2. User signs the transaction https://sdk.mint.club/docs/sdk/network/token/create#onsigned-optional
  3. The transaction is successfully submitted https://sdk.mint.club/docs/sdk/network/token/create#onsuccess-optional

If any of this fails, it will trigger onError and return undefined https://sdk.mint.club/docs/sdk/network/token/create#onerror-optional


Also, from the code I can see that an invalid metadataUrl is provided.

Please check the example code here

ggomaeng commented 6 months ago

These will also help

You will want to pass the ipfs url passed from uploadMetadata to the metadataUrl function

ggomaeng commented 6 months ago

I added the debugging section so this could also help.

https://sdk.mint.club/docs/sdk/bonus/debugging

Resister-boy commented 6 months ago

Thank you, I will try this all. But there is another weird thing, when I choose 'base' for network, I work successfully while other case(means all chains except 'base') it does not work and returns undefiend for function create. I am wondering is there something difference.

ggomaeng commented 6 months ago

Thank you, I will try this all. But there is another weird thing, when I choose 'base' for network, I work successfully while other case(means all chains except 'base') it does not work and returns undefiend for function create. I am wondering is there something difference.

Do you have enough gas fees to cover the transaction?

Resister-boy commented 6 months ago

Yes, Of course. In most case, It does not request deploy token contract with out base.

ggomaeng commented 6 months ago

Yes, Of course. In most case, It does not request deploy token contract with out base.

could you share the code?

Resister-boy commented 6 months ago

Sorry, It is same code, there is a only defference "avalanchefuji" to "base"

ggomaeng commented 6 months ago

did you try console logging in the onError function?

Resister-boy commented 6 months ago

Sorry, I never tried yet. I'll try it now

ggomaeng commented 6 months ago

Sorry, I never tried yet. I'll try it now

did you figure it out?