Skip to main content
3 of 5
added 365 characters in body

How to generate an arweave link using a generated keypair and the metaplex SDK?

These is my main code

// Generating keypair
const keypair = Keypair.generate();

await connection.requestAirdrop(keypair.publicKey, LAMPORTS_PER_SOL);
await uploadPrivate(keypair, connection);

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 enter image description here

if I go here: enter image description here

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: enter image description here

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, any help please?