1

I have tried uploading metadata to arweave from the frontend using the metaplex.nfts().uploadMetadata and it is working great. I would like to know if it is possible to upload from the backend using metaplex.nfts().uploadMetadata and privateKey. If possible please share an example code or docs for the same.

Thank You🙏

edit: I tried something like this.

const connection = new Connection(clusterApiUrl('devnet'));
  const metaplex = new Metaplex(connection);
  const key = Uint8Array.from(
    base58.decode('PrivateKey'),
  );

  const keypair = Keypair.fromSecretKey(key);
  console.log(`keypair created: ${keypair.publicKey.toString()}`);

  metaplex.use(walletAdapterIdentity(keypair));
  metaplex.use(
    bundlrStorage({
      address: 'https://devnet.bundlr.network',
      providerUrl: 'https://api.devnet.solana.com',
      timeout: 60000,
    }),
  );

Which obviously threw an error saying The current wallet adapter does not support the following operation: [signTransaction]. How do I solve this?

edit: I think I solved it Just have to update the bundlrStorage to use the keypair generated from the private key

metaplex.use(
    bundlrStorage({
      address: 'https://devnet.bundlr.network',
      providerUrl: 'https://api.devnet.solana.com',
      timeout: 60000,
      identity: keypair,
    }),
5
  • Hey! Can you post the error which you're facing when you try to upload the metadata to Arweave via the backend?
    – 0xMukesh
    Sep 18, 2022 at 16:12
  • Hey Mukesh, I dont have any error. I want to know how I can use my wallet private key on backed to upload the metadata using metaplex.nfts().uploadMetadata. Thanks
    – JohnVersus
    Sep 19, 2022 at 4:07
  • Hey Mukesh, I tried something now and have an error now, please take a look at the edited question.
    – JohnVersus
    Sep 19, 2022 at 5:49
  • 1
    correction: It is solved now 😄
    – JohnVersus
    Sep 19, 2022 at 6:00
  • Glad that you have figured it out!
    – 0xMukesh
    Sep 19, 2022 at 17:11

1 Answer 1

1

Posting it here to close the topic.

const key = Uint8Array.from(
    base58.decode('PrivateKey'), // converting private key to bs58 array
  );

  const keypair = Keypair.fromSecretKey(key);

  metaplex.use(walletAdapterIdentity(keypair));metaplex.use(
    bundlrStorage({
      address: 'https://devnet.bundlr.network',
      providerUrl: 'https://api.devnet.solana.com',
      timeout: 60000,
      identity: keypair,
    }),

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.