Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 8046

Deserialize transaction input data with publickey

$
0
0

How can I deserialize input args with publicKey inputs?

Full Code:

const borsh = require('borsh');const bs58 = require('bs58');const schema = { 'struct': { 'discriminator': 'u64', 'mint': "publicKey", 'solAmount': 'u64', 'tokenAmount': 'u64', 'isBuy': 'bool', 'user': "publicKey", 'timestamp': 'i64', 'virtualSolReserves': 'u64', 'virtualTokenReserves': 'u64', } };const encodeddata = "2K7nL28PxCW8ejnyCeuMpbXf8Xj7ysXeidJ55TJtZ8PzmG6NLHutyvhym8DqCYcg92aNSXYc4zw6BTJH2matHQR2vqYABBozk3wQJnArhbuCarwm6a1rdvkWiQS8JzqX5citcf3Hf8VMppEpJHtxDQ7J6FJHdnvUG7tyfqG6iU2wpqKR9MZS8515ZAXq";const decoded = borsh.deserialize(schema, Buffer.from(bs58.decode(encodeddata)));console.log(decoded);

I got this error:

throw new ErrorSchema(schema, VALID_OBJECT_KEYS.join(', ') +' or '+VALID_STRING_TYPES.join(', '));^

Error: Invalid schema: "publicKey" expected option, enum, array, set,map, struct or u8, u16, u32, u64, u128, i8, i16, i32, i64, i128, f32,f64, bool, string


Viewing all articles
Browse latest Browse all 8046

Trending Articles