I am not able to initate a ncw wallet from a api key in nodejs getting error 401

even if i have added right api keys and right secret file iam getting 401 error from the backend side

here is the nodejs code - :slight_smile:

// Import required modules
const { FireblocksSDK } = require(“fireblocks-sdk”); // Correct way to import Fireblocks SDK
const fs = require(“fs”);

// Initialize Fireblocks Client with API Key and Secret
const apiSecret = fs.readFileSync(“src/utils/fireblock/fireblock.pem”, “utf8”); // Replace with your actual file path
const apiKey = “786fe7bf-0e26-448f-806e-e7c1ca5b8e6d”; // Replace with your actual Fireblocks API Key
const fireblocks = new FireblocksSDK(apiSecret, apiKey);

// Function to Create a New Customer Wallet
async function createNewCustomerWallet(walletName, assets = ) {
try {
// Create wallet options
const options = {
name: walletName,
assets: assets, // Array of asset symbols you want to include in the wallet (e.g., [“BTC”, “ETH”])
};

    // Call the Fireblocks API to create a new wallet
    const response = await fireblocks.createVaultAccount(walletName); // Correct function to create a vault account
    console.log("Customer Wallet Created:", response);
    return response;
} catch (error) {
    console.error("Error creating customer wallet:", error.message);
}

}

// Example usage of the function
(async() => {
const walletName = “My New Customer Wallet”; // Replace with your desired wallet name
const assets = [“BTC”, “ETH”]; // Specify assets for the wallet (optional)

// Create the customer wallet
await createNewCustomerWallet(walletName, assets);

})();

Hi Jeetvani,
I am mohammed from Fireblocks.
I have a few questions. so the API key mentioned in the above code is the one you are using correct?
Also, I do not see an NCW signer in the workspace. Please do create one.
Secondly, did you initialize the SDK?

Also, before adding an asset wallet, you. We need to generate keys and backup the keys before adding asset wallets.

I recommend taking a look at our demo to check out the implementation.

Below, we have an implementation article as well. Please feel free to take a look.

i will be doing it but is it possible for you to share and let me know if your sdk works on backend nodejs or not?

Yes, the backend uses node JS.

Please take a look at the demo code.