i am building a test NFT-minting website on replit.co as a nodeJS project with an Express server
i am willing to use the Metaplex JS SDK and its Candy Machines in order to do so
i instantiated a Metaplex object like so
const m = require("@metaplex-foundation/js");
const s = require("@solana/web3.js");
// i couldn't figure out a way to use import statements somehow
// it might have something to see with this message i get anytime i run my app:
// bigint: Failed to load bindings, pure JS will be used
const connection = new s.Connection(s.clusterApiUrl("devnet"));
const mainAuthority = s.Keypair.generate();
// below i define a makeMetaplex() function rather than directly a metaplex variable as in documentation
// because the arrow function wouldn't return and i'd have to use metaplex().candyMachines()
// rather than metaplex.candyMachines() every time which i find inelegant
// it makes me feel like i can't use ES features somehow and that might be the root of all
// the evil i'm going through
const makeMetaplex = () => {
return m.Metaplex.make(connection)
.use(m.keypairIdentity(mainAuthority))
.use(m.bundlrStorage());
};
const metaplex = makeMetaplex();
// i also had to remove all 'await' syntax compared to documentation otherwise i'd get an error telling me
// i can only use it in top levels of modules (which i'm supposed to be on) or async functions
// maybe this is the problem or part of it
and created a collection NFT like so
const collectionAuthority = s.Keypair.generate();
// below when i put 'const { nft: collectionNft }' like in documentation
// i got an error later in the code saying collectionNft was undefined
// i guess that could be the problem too
// i am unfamiliar with this syntax which looks a bit like the desctructuring syntax i learned
// on FreeCodeCamp but not quite or i'm missing something
const collectionNft = metaplex.nfts().create({
name: "ULT:VOID Collection NFT",
uri: "",
sellerFeeBasisPoints: 0,
isCollection: true,
updateAuthority: collectionAuthority,
});
then i set up my Candy Machine settings like so
const candyMachineSettings = {
authority: mainAuthority,
sellerFeeBasisPoints: 200
symbol: "MYNFT",
maxEditionSupply: m.toBigNumber(0),
isMutable: true,
collection: {
address: collectionNft.address, // that's when i'd get an 'unedefined' error for collectionNft
updateAuthority: collectionAuthority,
},
itemsAvailable: m.toBigNumber(1111),
itemSettings: {
type: "configLines",
prefixName: "My NFT #$ID+1$",
nameLength: 0,
prefixUri: "", //"https://arweave.net/",
uriLength: null,//43,
isSequential: true,
}
};
when i now create my Candy Machine here's what it logs for the returned Object and one of its alleged properties
// line below i got rid of await as mentioned earlier
const candyMachine = metaplex.candyMachines().create(candyMachineSettings);
console.log(candyMachine); // logs Promise { <Pending> }
console.log(candyMachine.address); // logs undefined
when i mouse over my candyMachine variable a tooltip from Replit says
Promise<m.CreateCandyMachineOutput<m.CandyGuardDefaultSettings>>
i get the strong feeling that my basic JS skills have reached their limits and that there is something beyond the scope of my comprehension of the language and.or framework and.or Metaplex tool that i'm missing
any help?