π¨Transaction construction
Most of accounts used by the program are PDAs. The SDK automatically derives these accounts from the provided arguments, reducing the account management.
Presently, my setup involves a server responsible for delivering serialized transactions to the client or application. When the client sends specific parameters through a request, the server responds by providing a pre-built and serialized transaction using the SDK. Check code.
Create a product:
app.get('/initProductTree', async (req: Request, res: Response) => {
try {
if (!rpc) res.status(500).send({error: 'Error: Server rpc not configured'});
const connection = new Connection(rpc);
const { signer, marketplace, paymentMint, params } = req.query;
if (!signer || !marketplace || !paymentMint) {
res.status(500).send({error: 'Error: Missing account'});
}
const accounts = {
signer: new PublicKey(signer),
marketplace: new PublicKey(marketplace),
paymentMint: new PublicKey(paymentMint)
};
const normalizedParams = {
id: String(params.id),
productPrice: Number(params.productPrice),
feeBasisPoints: Number(params.feeBasisPoints),
height: Number(params.height),
buffer: Number(params.buffer),
canopy: Number(params.canopy),
name: String(params.name),
metadataUrl: String(params.metadataUrl),
};
const transaction = await createInitProductTreeTransaction(
connection,
accounts,
normalizedParams
);
res.status(200).send({
transaction: Buffer.from(transaction.serialize()).toString('base64')
});
} catch (error) {
console.log(error)
res.status(500).send({ error: error.message });
}
});Registering a purchase:
Create a marketplace:
I am using a solana playground repo with more scripts calling more Brick program instructions.
With the following script you can create a marketplace:
Last updated