【发布时间】:2022-01-15 09:53:20
【问题描述】:
就我而言,我正在尝试在 Serum 测试网市场 (SOL/USDT) 下订单。我知道我可能做错了几件事,但我无法发现它们。这是我的代码:
let connection = new web3.Connection(web3.clusterApiUrl("devnet")),
wallet = web3.Keypair.generate();
console.log('Airdropping some SOL');
let airdropSignature = await connection.requestAirdrop(
wallet.publicKey,
web3.LAMPORTS_PER_SOL,
);
await connection.confirmTransaction(airdropSignature);
let myMint = new web3.PublicKey("So11111111111111111111111111111111111111112"),
myToken = new splToken.Token(
connection,
myMint,
splToken.TOKEN_PROGRAM_ID,
wallet
);
// Create associated token accounts for my token if they don't exist yet
var ownerTokenAccount = await myToken.getOrCreateAssociatedAccountInfo(wallet.publicKey);
console.log('Placing order...');
let market = await handlers.fetchMarketData(new web3.PublicKey('HWHvQhFmJB3NUcu1aihKmrKegfVxBEHzwVX6yZCKEsi1')), //SOL/USDT
owner = ownerTokenAccount,
payer = owner,
res = await market.placeOrder(connection, { //TODO: Add error handling
owner,
payer,
side: 'sell',
price: 1,
size: 1.0,
orderType: 'limit',
})
【问题讨论】:
标签: solana