Cannot read properties of undefined (reading 'file')
I have error with BLOB pls help me
I can't use readAsBlob
try {
const fileBuffer = fs.readFileSync('tiho2.png');
const fileBlob = new Blob([fileBuffer], { type: 'image/png' });
console.log(fileBlob instanceof Blob);
console.log(typeof fileBlob);
console.log(fileBlob);
const mint = Keypair.generate();
const buyAmountSol = BigInt(0.00001 * 10 ** 9);
const transactionResult = await pumpClient.createAndBuy({
creator: wallet,
mint: mint,
createTokenMetadata: {
name: 'my bobus token',
symbol: 'BBS',
description: 'my bobus token',
file: fileBlob,
},
buyAmountSol: buyAmountSol,
slippageBasisPoints: 250,
priorityFees: {
unitLimit: 1000000,
unitPrice: 5000
},
commitment: 'confirmed',
finality: 'finalized'
});
console.log('token created :', transactionResult);
} catch (error) {
console.error('err when creating:', error);
}
PS C:\Users\prayer\Desktop\pumpfun> node .\create.js true object Blob { size: 13937, type: 'image/png' } err when creating: TypeError: Cannot read properties of undefined (reading 'file') at PumpFunSDK.createTokenMetadata (C:\Users\prayer\Desktop\pumpfun\node_modules\pumpdotfun-sdk\dist\cjs\pumpfun.js:148:40) at PumpFunSDK.createAndBuy (C:\Users\prayer\Desktop\pumpfun\node_modules\pumpdotfun-sdk\dist\cjs\pumpfun.js:28:40) at createToken (file:///C:/Users/prayer/Desktop/pumpfun/create.js:29:52) at file:///C:/Users/prayer/Desktop/pumpfun/create.js:55:1 at ModuleJob.run (node:internal/modules/esm/module_job:222:25) at async ModuleLoader.import (node:internal/modules/esm/loader:316:24) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)
It needs to be used in node.js
It needs to be used in node.js
it's node js :( idk what to do
` import bs from 'bs58'; import { Keypair, Connection } from '@solana/web3.js'; import { PumpFunSDK } from 'pumpdotfun-sdk'; import { AnchorProvider } from '@coral-xyz/anchor'; import fs from 'fs';
const connection = new Connection('', 'confirmed');
const wallet = Keypair.fromSecretKey(bs.decode(''));
const provider = new AnchorProvider(connection, wallet, { commitment: "finalized" }); const pumpClient = new PumpFunSDK(provider);
const createToken = async () => { try {
const fileBuffer = fs.readFileSync('tiho2.png');
const fileBlob = new Blob([fileBuffer], { type: 'image/png' });
console.log(fileBlob instanceof Blob);
console.log(typeof fileBlob);
console.log(fileBlob);
const mint = Keypair.generate();
const buyAmountSol = BigInt(0.00001 * 10 ** 9);
const transactionResult = await pumpClient.createAndBuy({
creator: wallet,
mint: mint,
createTokenMetadata: {
name: 'my bobus token',
symbol: 'BBS',
description: 'my bobus token',
file: fileBlob,
},
buyAmountSol: buyAmountSol,
slippageBasisPoints: 250,
priorityFees: {
unitLimit: 1000000,
unitPrice: 5000
},
commitment: 'confirmed',
finality: 'finalized'
});
console.log('token created :', transactionResult);
} catch (error) {
console.error('err when creating:', error);
}
};
const main = async () => { await createToken(); };
main(); `
cloudflare? mb problem?
Instead of using "fs" to read files, try using "fetch"