These is my main code
// Generating keypair
const keypair = Keypair.generate();
await connection.requestAirdrop(keypair.publicKey, LAMPORTS_PER_SOL);
try {
const arweaveLinks = await uploadPrivate(keypair, connection);
console.log(arweaveLinks);
} catch (error) {
console.log(error);
return;
}
The definition of the uploadPrivate
function (where is the error):
export async function uploadPrivate(
keypair: Keypair,
connection: Connection
): Promise<string[]> {
console.log("these is the keypair", keypair);
console.log("these is the connection", connection);
const metaplex = Metaplex.make(connection, { cluster: "devnet" as Cluster })
.use(keypairIdentity(keypair))
.use(
bundlrStorage({
address: "https://devnet.bundlr.network",
providerUrl: "https://api.devnet.solana.com",
timeout: 600000
})
);
const metaplexFile = await toMetaplexFileFromJson({ test: "test" });
const metaplexFileArray = [metaplexFile];
console.log("Procesing images");
const imageLinks = await metaplex.storage().uploadAll(metaplexFileArray);
console.log("imageLinks", imageLinks);
}
The error seems to be in these line of code:
const imageLinks = await metaplex.storage().uploadAll(metaplexFileArray);
This is what the console tells me
I encounter these line of code: https://github.com/Bundlr-Network/js-sdk/blob/e1a1584b5a058311451dcde4d60fdd0a7d052b5c/src/web/currencies/solana.ts#L144
The network tab tell me these:
I encountered these issue in the metaplex repo too, maybe is related with my problem? https://github.com/metaplex-foundation/js/issues/202
I even run these code in node.js and works
import { Connection, Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";
const {
Metaplex,
keypairIdentity,
bundlrStorage,
toMetaplexFileFromJson
} = require("@metaplex-foundation/js");
async function uploadPrivate(keypair: Keypair, connection: Connection){
const metaplex = Metaplex
.make(connection, { cluster: "devnet" })
.use(keypairIdentity(keypair))
.use(
bundlrStorage({
address: "https://devnet.bundlr.network",
providerUrl: "https://api.devnet.solana.com",
timeout: 600000
})
);
const metaplexFile = await toMetaplexFileFromJson({ test: "test" });
const metaplexFileArray = [metaplexFile];
console.log("Procesing images");
const imageLinks = await metaplex
.storage()
.uploadAll(metaplexFileArray);
console.log("imageLinks", imageLinks);
}
async function main(){
let connection = new Connection("https://api.devnet.solana.com");
let keypair = Keypair.generate();
await connection.requestAirdrop(keypair.publicKey, LAMPORTS_PER_SOL);
await uploadPrivate(keypair, connection);
}
if(require.main)
main();
I just need to generate an arweave link using a generated keypair but in the browser not in node.js, any help please?