索拉纳交易,未知签名者
我正在尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果其他人正在遇到这个问题,则是答案。确保将钱包写为锚。
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.