Skip to content

Fix: Resolve Raw Array Private Key Issue#1

Open
TomasAgustin95 wants to merge 1 commit into
fdundjer:masterfrom
TomasAgustin95:master
Open

Fix: Resolve Raw Array Private Key Issue#1
TomasAgustin95 wants to merge 1 commit into
fdundjer:masterfrom
TomasAgustin95:master

Conversation

@TomasAgustin95

Copy link
Copy Markdown

No description provided.

@Wt9241

Wt9241 commented Dec 11, 2024

Copy link
Copy Markdown
export function getWallet(wallet: string): Keypair {
  // Check if the wallet string is in JSON array format, indicating a binary secret key
  if (wallet.startsWith('[')) {
    try {
      // Parse the wallet string as a JSON array and convert it to a Uint8Array
      const secretKeyArray = JSON.parse(wallet);
      if (Array.isArray(secretKeyArray)) {
        return Keypair.fromSecretKey(new Uint8Array(secretKeyArray));
      } else {
        throw new Error('Invalid secret key format');
      }
    } catch (error) {
      throw new Error(`Failed to parse wallet secret key: ${error.message}`);
    }
  }

  // Handle other wallet formats here if needed
  throw new Error('Unsupported wallet format');
}

@shasan111

Copy link
Copy Markdown

Hi i am trying to setup this bot but i am not able to do it as i am not a programmer or computer expert.. would you able to help me on this please?

@SkyNetRu

Copy link
Copy Markdown

@shasan111 to use this code you should either become a programmer or hire a programmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants