'Possible to create token and metadata in one transaction?
Am I correct in saying that it's not possible to mint(create) an spl token and token metadata in the one transaction ?
Here is me cerating the mpl token metadata for a previously cerated spl token:
const createMetadataTx = new CreateMetadataV2(
{ feePayer: this.appTreasPair.publicKey },
{
metadata,
metadataData: new DataV2({
uri: `${host}/token_type/${token_type.token_type_id}/metadata`,
name: token_type.name,
symbol: token_type.symbol,
sellerFeeBasisPoints: 100,
creators: null,
collection: null,
uses: null,
tokenStandard: TokenStandard.FungibleAsset,
}),
updateAuthority: this.appTreasPair.publicKey,
mint: new web3.PublicKey(token_type.token_address),
mintAuthority: this.appTreasPair.publicKey,
}
);
const connection = solanaUtils.getConnection(token_type.cluster);
const transaction = new web3.Transaction();
console.log("creating metadata")
transaction.add(createMetadataTx)
const sig = await web3.sendAndConfirmTransaction(connection, transaction, [this.appTreasPair], {
skipPreflight: skipPreflight
})
the mint
field needs the address of the spl token which I can only get if I do the spl token creation in an initial separate transaction
Solution 1:[1]
It is possible. E.g. candy machine is creating a SPL token and then assign metadata to it. If you want a NFT: https://solanacookbook.com/references/nfts.html#mint-the-nft
If you rather want a standard SPL token the current method is create the SPL Token and then add it to the Solana Token list https://github.com/solana-labs/token-list (a better solution is WIP)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mark Sackerberg |