1.0.6 • Published 1 year ago
@brian-ai/cdp-sdk v1.0.6
Brian <> Coinbase SDK
A TypeScript SDK that integrates Brian AI's transaction capabilities with Coinbase's wallet functionality, providing a seamless interface for blockchain interactions.
Features
- Easy integration with Brian AI and Coinbase SDKs
- Wallet management (create, import, export)
- Support for various blockchain operations:
- Transfers (ETH and ERC20 tokens)
- Swaps
- Bridging
- Deposits and Withdrawals
- Borrowing and Repaying (AAVE)
- ENS Registration and Renewal
- Automatic transaction handling based on Brian AI's responses
Installation
npm install @brian-ai/cdp-sdkUsage
Here's a quick example of how to use the SDK:
import { BrianCoinbaseSDK } from "brian-coinbase-sdk";
const sdk = new BrianCoinbaseSDK({
brianApiKey: "your_brian_api_key",
coinbaseApiKeyName: "your_coinbase_api_key_name",
coinbaseApiKeySecret: "your_coinbase_api_key_secret",
});
// Create a wallet
await sdk.createWallet({ networkId: "base-sepolia" });
// Fund the wallet (only for Sepolia testnet)
await sdk.fundWallet();
// Execute a transaction based on a prompt
const txHashes = await sdk.transact("Swap 0.1 ETH for USDC");
console.log("Transaction hashes:", txHashes);Configuration
The BrianCoinbaseSDK constructor accepts the following options:
brianApiKey(required): Your Brian AI API keybrianApiUrl(optional): Custom Brian AI API URLcoinbaseApiKeyName(required if not using file path): Your Coinbase API key namecoinbaseApiKeySecret(required if not using file path): Your Coinbase API key secretcoinbaseFilePath(required if not using API key): Path to Coinbase configuration filecoinbaseOptions(optional): Additional Coinbase SDK options
API Reference
createWallet(options: WalletCreateOptions): Promise<Wallet>importWallet(walletData: WalletData): Promise<Wallet>exportWallet(): WalletDatasaveWallet__insecure(filePath: string, encrypt?: boolean): stringgetDefaultAddress(): Promise<WalletAddress | undefined>fundWallet(): Promise<FaucetTransaction>transact(prompt: string): Promise<(Transfer | ContractInvocation)[]>
For detailed information on each method, please refer to the source code and comments.
License
This project is licensed under the MIT License - see the LICENSE file for details.