Encountering issues with Secp256k1Pen while deploying Secret Network NFT using a script

I’m working on a Secret NFT project and ran into a problem when trying to deploy it using a script. The deployment fails at this part of the code:

const signingPen = await CryptoSigner.fromSeedPhrase(seedWords).catch((error) => {
  throw new Error(`Failed to create signing pen: ${error}`);
});

I get this error message:

TypeError: Cannot read properties of undefined (reading 'fromSeedPhrase')

I imported CryptoSigner at the top of my file like this:

const {
  EncryptionUtils,
  CryptoSigner,
  CosmWasmClientWithSignature,
  addressFromPublicKey,
  encodePublicKeySecp256k1
} = require('secretnetworkjs');

Why is it saying CryptoSigner is undefined? Am I missing something in my setup or imports? Any help would be great!

It seems like you’re encountering an issue with the CryptoSigner import. From my experience working with Secret Network, the issue might be related to the version of secretnetworkjs you’re using or how it’s being imported.

First, double-check that you’ve installed the latest version of secretnetworkjs. If you’re sure it’s up to date, try destructuring the import differently. Instead of importing multiple modules at once, try importing CryptoSigner separately:

const { CryptoSigner } = require('secretnetworkjs');

If that doesn’t work, you might need to import the entire module and access CryptoSigner as a property:

const secretnetworkjs = require('secretnetworkjs');
const signingPen = await secretnetworkjs.CryptoSigner.fromSeedPhrase(seedWords);

These approaches have resolved similar issues for me in the past. If you’re still facing problems, consider checking the documentation or reaching out to the Secret Network community for more specific guidance.

yo, i’ve had similar probs before. try importing secretnetworkjs like this:

const secretjs = require(‘secretnetworkjs’);

then use it like:

const signingPen = await secretjs.CryptoSigner.fromSeedPhrase(seedWords);

if that doesn’t work, maybe check ur package.json to make sure secretnetworkjs is listed there. good luck with ur nft project!

hey there, fellow secret nft enthusiast! :wave:

i’ve been tinkering with secret network stuff too, and i’ve run into similar head-scratchers before. have you considered that maybe the CryptoSigner isn’t actually part of the secretnetworkjs package anymore? :thinking:

what if you try importing from ‘@iov/crypto’ instead? something like:

import { Secp256k1Pen } from '@iov/crypto'

the idea is that you could then use Secp256k1Pen.fromMnemonic() to create your signing pen. just a thought!

also, are you using typescript or javascript? sometimes type issues can cause weird undefined errors like that.

let me know if any of this helps or if you figure it out! i’m super curious to hear more about your nft project too, if you’re up for sharing :blush: