NodeJS Solana事务,未知签名者

bis0qfac  于 2022-12-29  发布在  Node.js
关注(0)|答案(1)|浏览(161)

我试图购买NFT从魔术伊甸园索拉纳与节点js/typescript脚本,
首先,我使用solana CLI通过以下命令获取密钥对

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)
      })

输出为错误:未知签名人xxxxxxxxxxxxxxx,注意到我的钱包地址与签名人不同,我不知道为什么我得到了不同的签名人。
我尝试了不同的方法,使用bip 39方法生成密钥对,如下所示:

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;
};

我得到不同的错误=〉验证错误
不确定我是不是漏了一步。

afdcj2ne

afdcj2ne1#

如果其他人正在经历这个问题,这里有答案。确保钱包写为锚.Toml,并且这个相同的钱包应该与您的测试文件中的钱包匹配。

相关问题