I want to check the payment paid by the user in the chain and add it to database.
Frontend:
const transactionString =
"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDyIchCFWi8XOQK9v26xdqOA6+Nh0PxppQs5xbNaKQd7/0i+hG2L1v22b2JWcGVBnJMaqEN3yadwu9twp/uzdQZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4VWxeJUJXETqt/CGxFeYTUs45eWde5bOPqThLZxVqEcBAgIAAQwCAAAAAOH1BQAAAAA=";
const tx = Transaction.from(Buffer.from(transactionString, "base64"));
tx.feePayer = anchorWallet.publicKey;
await anchorWallet.signTransaction(tx);
const signedData = tx.serialize().toString("base64");
console.log(signedData);
// AT9nK/UKWz+T/vhsli/hYVANRlVctUEPjJp+myjfeLNJqM5h982cyrQqbGlRnn/x3WwpJjOR3rI3JaxWfzuq+AUBAAEDyIchCFWi8XOQK9v26xdqOA6+Nh0PxppQs5xbNaKQd7/0i+hG2L1v22b2JWcGVBnJMaqEN3yadwu9twp/uzdQZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4VWxeJUJXETqt/CGxFeYTUs45eWde5bOPqThLZxVqEcBAgIAAQwCAAAAAOH1BQAAAAA=
i send the signedData
to the backend
app.post("/:publicKey/pay", async (c) => {
const publicKey = new PublicKey(c.req.param("publicKey"));
const tx = Transaction.from(Buffer.from(await c.req.text(), "base64"));
const {
value: { blockhash },
} = await connection.getLatestBlockhashAndContext();
tx.recentBlockhash = blockhash;
const signature = await connection.sendRawTransaction(tx.serialize());
})
and I get the error "Trace: Signature verification failed". How can I solve this problem? Don't you already have the necessary signatures in the Transaction?