I am trying to create a neuron programmatically using the js library. However I am running into the following error.
Stake neuron error: Ce [Error]: Unrecognized ClaimOrRefresh error in {"command":[{"Error":{"error_message":"Account does not have enough funds to stake a neuron. Please make sure that account has at least 100000000 e8s (was 0 e8s)","error_type":14}}]}
Here is the code snippet that I am using.
const nonce = BigInt(0); // You can use different nonces for multiple neurons
const subAccount = SubAccount.fromPrincipal(principal);
console.log("subAccount", subAccount);
const governancePrincipal = Principal.fromText(GOVERNANCE_CANISTER_ID);
await ledger.transfer({
to: AccountIdentifier.fromPrincipal({
principal: governancePrincipal,
subAccount: subAccount,
}),
amount: BigInt(1000000),
fee: DEFAULT_FEE,
memo: nonce, // Use same nonce as memo
fromSubAccount: undefined,
createdAt: undefined,
});
I suspect the issue is with how i derive the subaccount. But I am not sure of another method to use since I am using the Subaccount methods from the dfinity packages