索拉纳交易,未知签名者

发布于 2025-02-12 20:29:15 字数 2001 浏览 0 评论 0原文

我正在尝试使用Node JS/Typescript脚本从Magic Eden Solana购买NFT,

首先,我使用Solana Cli使用以下命令来获取Keypair

cat .../.config/solana/id.json

let Array_key = [98, 90, 131, ...]; ```got it using solana cli from .../.config/solana/id.json```
let secret = Uint8Array.from(Array_key)
let signers = Keypair.fromSecretKey(Uint8Array.from(secrete))

const connection = new Connection("https://api.mainnet-beta.solana.com",'confirmed');
let publickey = new PublicKey("2Eod3hjZBJZzGYSJVrVtRC3UMZeonZYfUScmAy1tjD5c");```Wallet address```


let allocateTransaction = new Transaction({
                  feePayer: publickey,
                });
    
const databuf = Buffer.from(parsed_buy_response['tx']['data'], "hex");```from https://api-mainnet.magiceden.io/v2/instructions/buy_now```

const keys: AccountMeta[] = await generateAccountList(MintAddress,publickey, connection);```function used from transaction.ts https://github.com/solanasoulja/sol-nft-sniper/blob/main/src/views/HomeView/transaction.ts```

allocateTransaction.add(new TransactionInstruction({
              keys: keys,
              programId: publickey,
              data: databuf,
            }));

await sendAndConfirmTransaction(connection, allocateTransaction, [signers]).then(resolve => {
        console.log('transaction sent')
        console.log(resolve)
      }).catch(err => {
        console.log('err at sending transaction')
        console.log(err)
      })

输出是错误:未知签名者xxxxxxxxxxxxxxxxxx, 注意到我的钱包地址与签名者不同,我不知道为什么我会得到另一个签名者。

我通过使用BIP39方法生成Keypair来尝试不同的方法:如下所示:

async getKeyPair(mnemomic) {
    const seed = bip39.mnemonicToSeedSync(mnemomic).slice(0, 32);
    console.log(seed)
    // let _KeyPairseed = await web3.PublicKey.createWithSeed(publicKey, seed, publicKey)
    // console.log(_KeyPairseed)
    const keypair = Keypair.fromSeed(seed);
    console.log(keypair)
    return keypair;
};

我得到不同的错误=>验证错误

不确定我是否缺少步骤。

I am trying to buy NFT from Magic Eden Solana with node js/typescript script,

at first I used solana CLI to get the keypair by using the command below

cat .../.config/solana/id.json

typescript :

let Array_key = [98, 90, 131, ...]; ```got it using solana cli from .../.config/solana/id.json```
let secret = Uint8Array.from(Array_key)
let signers = Keypair.fromSecretKey(Uint8Array.from(secrete))

const connection = new Connection("https://api.mainnet-beta.solana.com",'confirmed');
let publickey = new PublicKey("2Eod3hjZBJZzGYSJVrVtRC3UMZeonZYfUScmAy1tjD5c");```Wallet address```


let allocateTransaction = new Transaction({
                  feePayer: publickey,
                });
    
const databuf = Buffer.from(parsed_buy_response['tx']['data'], "hex");```from https://api-mainnet.magiceden.io/v2/instructions/buy_now```

const keys: AccountMeta[] = await generateAccountList(MintAddress,publickey, connection);```function used from transaction.ts https://github.com/solanasoulja/sol-nft-sniper/blob/main/src/views/HomeView/transaction.ts```

allocateTransaction.add(new TransactionInstruction({
              keys: keys,
              programId: publickey,
              data: databuf,
            }));

await sendAndConfirmTransaction(connection, allocateTransaction, [signers]).then(resolve => {
        console.log('transaction sent')
        console.log(resolve)
      }).catch(err => {
        console.log('err at sending transaction')
        console.log(err)
      })

and the output is Error: unknown signer xxxxxxxxxxxxxxx,
noting that my wallet address is different than the signer, I don't know why I am getting a different signer.

I tried different method by generating the keypair using bip39 method as shown below:

async getKeyPair(mnemomic) {
    const seed = bip39.mnemonicToSeedSync(mnemomic).slice(0, 32);
    console.log(seed)
    // let _KeyPairseed = await web3.PublicKey.createWithSeed(publicKey, seed, publicKey)
    // console.log(_KeyPairseed)
    const keypair = Keypair.fromSeed(seed);
    console.log(keypair)
    return keypair;
};

I get different error => verification error

not sure if I am missing a step.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪我鬧 2025-02-19 20:29:15

如果其他人正在遇到这个问题,则是答案。确保将钱包写为锚。

If someone else is going through this problem, here is the answer. Make sure the wallet is written Anchor.toml and this same wallet should match the wallet in your test file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文