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). Functor 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_TESTNET, signerFromPrivateKey } from "@functornetwork/agentic-wallet";
const client = createClient({ chains: [BNB_TESTNET] });
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 "@functornetwork/agentic-wallet";
const signer = signerFromPrivateKey(process.env.PRIVATE_KEY as `0x${string}`);createPrivateKeySigner(): generates a fresh random secp256k1 key and returns the signer. Use this when you want the SDK to create the key. You are responsible for persisting it: it is not stored anywhere automatically.
import { createPrivateKeySigner, createClient, BNB_TESTNET } from "@functornetwork/agentic-wallet";
const signer = createPrivateKeySigner();
console.log("Save this key:", signer._privateKey); // persist before continuing
const client = createClient({ chains: [BNB_TESTNET] });
const wallet = await client.createWallet({ signer });Calling createWallet() with no signer argument is equivalent: it calls createPrivateKeySigner() internally and attaches the result to wallet.signer.