Skip to content

Adding Subaccounts after client initialisationΒ #41

@Arul131

Description

@Arul131

Bug Description
When trying to create a subaccount with my wallet, I receive an error despite having sufficient SOL balance. I have attached a screenshot of my code for reference. Please review and assist in resolving the issue.
Screenshots
not able to add screenshots,
consoled everything:

Image

πŸ”Ή Checking Wallet Connection...
newDrift.js:269 βœ… Wallet Ready. Initializing Drift Client...
newDrift.js:161 βœ… Wallet connected: 6jtiTE5RavgbU11YaR7Yfyy17uKVoAfZZ2FqoSUUNLWL
newDrift.js:183 βœ… Drift Client Initialized
newDrift.js:245 πŸ’° SOL Balance: 1 SOL
newDrift.js:191 πŸ”Ή Checking for existing user accounts...
newDrift.js:197 πŸš€ No accounts found, initializing user account...
newDrift.js:215 βœ… Wallet connected. Initializing user account...

getting this error:
newDrift.js:234 ❌ Error initializing user account: TypeError: Cannot read properties of undefined (reading 'slice')
at sign (index.browser.esm.js:145:121)
at VersionedTransaction.sign (index.browser.esm.js:2176:38)
at RetryTxSender.sendVersionedTransaction (baseTxSender.js:73:16)
at DriftClient.sendTransaction (driftClient.js:4906:34)
at DriftClient.initializeUserAccount (driftClient.js:574:38)
at async initializeUserAccount (newDrift.js:230:40)
at async initDriftClient (newDrift.js:199:9)
at async handleSubscribe (newDrift.js:270:5)

here the code :
try {
console.log("βœ… Wallet connected. Initializing user account...");

    // Ensure driftClient is initialized
    if (!client) {
        console.error("❌ Drift Client is not initialized!");
        return;
    }

    // Debugging: Check signTransaction function
    if (!signTransaction) {
        console.error("❌ signTransaction function is missing!");
        return;
    }

    // Initialize user account
    const [txSig, userPublicKey] = await client.initializeUserAccount(0, "TestAccount");

    console.log("βœ… User initialized:", userPublicKey.toBase58(), "Tx:", txSig);
} catch (error) {
    console.error("❌ Error initializing user account:", error);
}

};

Browser (please complete the following information):

  • Browser [ chrome]

Last upstream Slate commit (run git log --author="\(Robert Lord\)\|\(Matthew Peveler\)\|\(Mike Ralphson\)" | head -n 1):
Put the commit hash here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions