Ale*_*kov 5 javascript solana metaplex solana-web3js
自2022年6月20日起,注册代币的规则发生变化: https: //github.com/solana-labs/token-list
我已经尝试过以下方法:
1)。通过服务创建新令牌:
创建这些代币并尝试通过网络应用程序(web3js)将它们转移到另一个钱包后,它们被定义为 NFT:
同样在 Solscan 上,这些令牌显示为“无法识别的令牌”:
2)。然后我尝试通过 Metaplex 注册令牌,但不断遇到各种错误。我的代码(JavaScript):
import { createCreateMetadataAccountV2Instruction} from '@metaplex-foundation/mpl-token-metadata';
const tokenMetadata = {
name: 'EUR demo-stablecoin',
symbol: 'EURX',
uri: {
name: 'EUR demo-stablecoin',
symbol: 'EURX',
description: 'Fully for testing purposes only',
image: 'https://raw.githubusercontent.com/.../logo.png',
},
sellerFeeBasisPoints: 0,
creators: null,
collection: null,
uses: null,
};
const createNewTokenTransaction = new solanaWeb3.Transaction().add(
createCreateMetadataAccountV2Instruction(
{
metadata: 'https://vxmxabesb3yfewwf4jcplmstg2fe3cngsphlgnrvwp46iftqdm.arweave.net/.../arweave-metadata-JSON',
mint: mintKeypair.publicKey,
mintAuthority: provider.publicKey,
payer: provider.publicKey,
updateAuthority: provider.publicKey,
},
{
createMetadataAccountArgsV2:
{
data: tokenMetadata,
isMutable: true,
},
},
),
);
await sendTransaction(
createNewTokenTransaction,
connection,
{ signers: [mintKeypair] },
);
Run Code Online (Sandbox Code Playgroud)
也许现在有人知道如何在 Solana 中注册 Fungible 代币?如果示例是注册现有令牌,那么它将特别有用。
您的 URI 不正确。它应该是元数据链接。
import { DataV2, createCreateMetadataAccountV2Instruction } from '@metaplex-foundation/mpl-token-metadata';
import { findMetadataPda } from '@metaplex-foundation/js';
const metadataPDA = await findMetadataPda(mintKeypair.publicKey); // This is derived from the mint account's public key
const tokenMetadata = {
name: "Test Token",
symbol: "TEST",
uri: https://token-creator-lac.vercel.app/token_metadata.json,
sellerFeeBasisPoints: 0,
creators: null,
collection: null,
uses: null
} as DataV2;
const createNewTokenTransaction = new Transaction().add(
createCreateMetadataAccountV2Instruction({
metadata: metadataPDA,
mint: mintPublicKey,
mintAuthority: userPublicKey,
payer: userPublicKey,
updateAuthority: userPublicKey,
},
{ createMetadataAccountArgsV2:
{
data: tokenMetadata,
isMutable: true
}
}
)
await sendTransaction(createNewTokenTransaction, connection);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
617 次 |
| 最近记录: |