Basic setup to equip your AI agent with a Smart Account
Get started with Safe AI integration in just a few steps.
This guide will help you set up a Safe Smart Account with the AI agent as the only signer. This 1-out-of-1 signer setup is discouraged by Safe, as it is not the most secure. However, many projects choose this setup for simplicity.
Installation
First, add the Safe Protocol Kit to your project:
_10import Safe from '@safe-global/protocol-kit'
Creating a Safe Smart Account for your AI agent
When your AI agent is ready to interact with the blockchain, you can create a Safe Smart Account for it.
_16import Safe from '@safe-global/protocol-kit'_16_16const SIGNER_ADDRESS = // ..._16const SIGNER_PRIVATE_KEY = // ..._16const RPC_URL = 'https://rpc.ankr.com/eth_sepolia'_16_16const safeClient = await Safe.init({_16 provider: RPC_URL,_16 signer: SIGNER_PRIVATE_KEY,_16 predictedSafe: {_16 safeAccountConfig: {_16 owners: [SIGNER_ADDRESS],_16 threshold: 1_16 }_16 }_16})
This creates a Safe Smart Account, but the actual smart contract will be deployed when you send the first transaction.