@dimcool/wallet
v0.1.36
Published
Readme
@dimcool/wallet
A quick and simple non-custodial wallet for agents — send funds to other DIM users, Solana addresses, or .sol usernames without any browser or OAuth setup.
Canonical docs:
- https://docs.dim.cool/capabilities/agent-wallet
- https://docs.dim.cool/guides/wallet-package
@dimcool/wallet helps you:
- create/load wallets from mnemonic or private key
- sign Solana messages and transactions
- authenticate to DIM with
wallet.login(...) - send USDC to a DIM username, a Solana address, or a
.soldomain with a single call - run high-level DIM wallet actions (
send,getBalances,getInfo)
Install
npm install @dimcool/walletQuick Start
import { Wallet } from '@dimcool/wallet';
const wallet = new Wallet({
enabledNetworks: ['solana'],
fromPrivateKey: process.env.DIM_WALLET_PRIVATE_KEY!,
rpcUrls: {
solana: 'https://api.mainnet-beta.solana.com',
},
});
const session = await wallet.login({
referralCode: 'optional-referrer',
walletMeta: { type: 'keypair' },
});
console.log('Logged in as', session.user.id);
console.log('Addresses', wallet.getAddresses());Create Wallet
From mnemonic
const wallet = new Wallet({
enabledNetworks: ['solana', 'evm'],
fromMnemonic: process.env.DIM_MNEMONIC!,
// Solana default path: m/44'/501'/0'/0'
// Optional alternatives:
// solanaDerivationPath: "m/44'/501'/1'/0'",
// solanaAccountIndex: 1,
rpcUrls: {
solana: 'https://api.mainnet-beta.solana.com',
evm: 'https://mainnet.infura.io/v3/<key>',
},
});From private key
const wallet = new Wallet({
enabledNetworks: ['solana'],
fromPrivateKey: process.env.DIM_WALLET_PRIVATE_KEY!,
});Core APIs
wallet.getAddresses(); // { solana?: string, evm?: string }
wallet.solana?.signMessage('hello');
wallet.solana?.signAndSendTransaction(tx);DIM Convenience Methods
await wallet.login({ referralCode: 'optional-referrer' });
await wallet.setUsername('agentname');
await wallet.getInfo();
await wallet.getBalances();
// Send to a DIM username
await wallet.send({ recipient: 'alice', amount: 1.25, token: 'USDC' });
// Send to a Solana address
await wallet.send({
recipient: '7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU',
amount: 5.0,
token: 'USDC',
});
// Send to a .sol domain
await wallet.send({ recipient: 'alice.sol', amount: 0.5, token: 'USDC' });SDK Interoperability (Optional)
If you also use @dimcool/sdk, wallet.getSigner() returns an SDK-compatible signer:
const signer = wallet.getSigner();
// signer: { address, signMessage, signTransaction }The wallet package uses the signTransaction mode — it signs the transaction locally and returns the signed bytes; the server submits the transaction to the network. This is distinct from the signAndSendTransaction mode used by wallets that cannot return signed bytes, where the client both signs and sends.
Notes
recipientinwallet.send(...)can be a DIM username, Solana address, or.soldomain..soldomains are resolved server-side during transfer preparation.- Works in Node.js and browser environments.
- EVM signing/sending APIs are scaffolded and will be expanded in upcoming releases.
wallet.swap(...)is reserved for upcoming aggregator-backed swap routes.
