SDK
createWallet
client.createWallet creates a smart-account wallet for a signer. The signer's key lives wherever you keep it (env var, OS keychain, hardware wallet). Altana never sees it.
First create a client with createClient, configured with the chains the wallet should work on. The same wallet address is provisioned on every chain the client lists.
import { createClient, BNB, signerFromPrivateKey } from "@altananetwork/sdk";
const client = createClient({ chains: [BNB] });
const signer = signerFromPrivateKey("0x...");
const wallet = await client.createWallet({ signer });The wallet is counterfactual. Its address is deterministic, but it isn't a smart account onchain until the first execute. That first execute is what registers the admin key in Keystore.
Parameters
type ClientCreateWalletOptions = {
/** Bring your own signer. If omitted, the SDK generates a fresh private-key signer. */
signer?: Signer;
};The chains the wallet is provisioned on come from the client (createClient({ chains })), not from this call.
Returns
type CreateWalletResult = {
address: Address; // the wallet's smart-account address (same on every chain)
signer: Signer; // same reference if you passed one in
};Notes
- Fund
result.addresswith native tokens before callingexecute— the wallet is counterfactual and has no balance until you send some. - If you omit
signer, the SDK generates a fresh private-key signer and returns it on the result. Persistresult.signerhowever your app stores keys. - The address is identical on every chain the client was configured with, so one wallet handle works across all of them: pass
chainIdper operation to pick which one.
Private key helpers
Two functions handle the private-key signer path:
signerFromPrivateKey(key): reconstructs a signer from a key you already have. Use this when the key is stored in an env var, OS keychain, or secrets manager.
import { signerFromPrivateKey } from "@altananetwork/sdk";
const signer = signerFromPrivateKey(process.env.PRIVATE_KEY as `0x${string}`);Need a new key? Generate it yourself, then wrap it. The SDK never stores key material and has no supported way to hand a key back to you, so the copy you make here is the only one.
import { generatePrivateKey } from "viem/accounts";
import { signerFromPrivateKey, createClient, BNB } from "@altananetwork/sdk";
const privateKey = generatePrivateKey();
console.log("Save this key:", privateKey); // persist before continuing
const signer = signerFromPrivateKey(privateKey);
const client = createClient({ chains: [BNB] });
const wallet = await client.createWallet({ signer });createPrivateKeySigner() also generates a fresh secp256k1 key, and createWallet() with no signer argument calls it internally and attaches the result to wallet.signer. Both are fine when the key is ephemeral, for a test or a throwaway wallet. Neither is a good fit when you need to keep the key: wallet.signer is typed as a Signer, which exposes an address, a public key, and the ability to sign, and nothing that yields the private key. Generate the key yourself whenever you intend to persist it.