5

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 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 but in the browser not in node.js, any help please?

1
  • How are you generating the array for your images? Do you have the code?
    – Bryson
    Dec 19, 2022 at 5:55

2 Answers 2

0

Looks like you're using @solana/wallet-adapter ?

If so, what does console.log(wallet) give you? Looks like bundlr expect a string. You can Try wallet.toBase58()

Also, here's an example of usage from the docs that might help:

import { useConnection, useWallet } from '@solana/wallet-adapter-react';

const { publicKey, sendTransaction } = useWallet();

// then you give bundlr "publicKey" or publicKey.toBase58()

Source

1
  • I fixed a little the post, as you can see I can't see possible that is a problem of the wallet adapter because I'm not using that wallet at all Aug 19, 2022 at 19:02
0

I encounter the solution!! Just was a problem where the metaplex SDK was unable to use a keypairIdentity in the browser... Was fixed thanks to this PR

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.