Redefining Onchain Interactions with Agent Wallets

At Spectral, we're creating an Onchain Agent Economy—a platform where Web3 users can utilize AI Agents for diverse tasks. From navigating onchain data to managing complex cross-chain arbitrage strategies, our agents can handle it. The magic of engaging AI Agents (instead of humans) in the onchain world is their ability to distill context from multiple sources and information types to perform a set of deterministic logical actions. Consider the effort and expertise required for an average retail Web3 trader to analyze influential wallets, compare trades, assess social sentiment on platforms like Twitter and Farcaster, and execute optimal swaps across different blockchains. With SYNTAX, an AI agent can accomplish all of this efficiently - SYNTAX enables retail traders to easily create such agents through intuitive natural language conversations.

Given these capabilities, we had to ask: why should an AI Agent suffer through the same wallet experience that Web3 users do?

Not only was there a critical need to enhance the user experience, but we also recognized a deeper potential: AI agents can fundamentally transform how users interact onchain.

Evolution of Wallet Technologies

The evolution of wallet technology in the crypto space has been driven by the need for scalable performance and trustless ownership.While self-custodial wallets are now common, interacting onchain still presents several challenges. Many interfaces require users to manually manage wallet addresses, which can be cumbersome, especially for those not familiar with the technology. Additionally, transaction fees and gas price volatility add to the complexity, with costs often being unpredictable and high. Navigating across chains, finding optimal bridging methods, and swapping assets can make the onchain experience daunting for retail users.

At Spectral Labs, we recognize the potential of AI Agents in crypto to address these user experience issues. Our solution? Agent Wallets—a system where an AI Agent manages wallet operations in a secure, trustless, and deterministic manner, streamlining the entire process for users.

Agent Wallets: Transforming the Onchain Experience

An agent wallet is a special type of Smart Wallet that enables Spectral’s AI agents to autonomously and trustlessly deploy and run smart contracts. Here's how it works:

  • An AI agent can send any arbitrary smart contract action to a paymaster, through the Agent Wallet, without manual verification from a third party. The private information required to sign a transaction through the Smart Wallet is accessible only by the AI agent, and no one else (not even Spectral).
  • An agent wallet has special functionality that is not available in a typical custodial or non custodial wallet. It is set up as a 1:2 multisignature contract, which enables either an AI agent or Spectral SYNTAX user to broadcast transactions from a single wallet. In other words, the AI agent and Spectral SYNTAX user share a cryptocurrency wallet without the need to expose their private key or any other sensitive information.

Securing best in class infrastructure primitives with Turnkey

In order to ensure that only the AI Agents have secure access to private wallet keys, we’re working with Turnkey to build a next-gen wallet paradigm.

Turnkey is a secure and scalable key management service, which uses secure code environments to create embedded wallets and automate onchain actions. After rigorous technical evaluations and discussions with the team, we concluded that Turnkey’s stack was best suited to build wallets for agentic interaction:

  • Turnkey’s sensitive information is stored in such a way that even the engineers at Turnkey do not have access to your private keys.
  • Furthermore, they've implemented secure, isolated environments and immutable, verifiable data stores, which ensure that Spectral SYNTAX Agents and their respective users have full control over their assets. 
  • Turnkey accounts also do not use password authentication.

With these key differentiators, Turnkey offers a signing API, which is used by SYNTAX Agents to sign transactions without ever exposing the private key stored securely with Turnkey. Additionally, we’re also using Turnkey’s policy engine to provide fine-grained controls for how Agents can use their private keys. Using these controls, we’re setting platform wide limits for transaction amount and signature patterns (e.g. we’ve set controls such that any agent cannot spend the entire Agent Wallet balance on a single transaction). Changes to these controls are subject to approval workflows and leave behind an audit trail, thus ensuring maximum safety for the users on our SYNTAX platform.

Technical Architecture & Workflows

Spectral SYNTAX V2 technical architecture and Agentic workflows, powered by Agent Wallets

The flow of the Agent Wallet architecture in Spectral Syntax begins with a user signing into the platform using Privy, a secure authentication system. Once authenticated, the user proceeds to create a Gas Tank and an Agent Wallet. The Gas Tank uses a smart contract to deposit USDC, and is used to cover transaction fees without requiring Ether. The Agent Wallet, an ERC4337 smart account, is where the agent or user will execute transactions on the Spectral Syntax platform.

With the Gas Tank and agent wallet set up, the user can request the Agent to perform onchain transactions. For example, consider a Trading Agent - in this context, the above interaction involves the user defining specific parameters and market conditions that the agent will use to make trading decisions. The Execution Engine is responsible for generating agent instructions based on the user’s predefined conditions. These instructions guide the agent in making autonomous decisions on the blockchain.

Once the Execution Engine creates the necessary instructions, the next step involves the execution of onchain instructions. These instructions, which include transactions like buying or selling ETH, are sent for signing through the Agent Wallet portal. The signing process is facilitated by the Alchemy SDK, which requests Turnkey to sign the action on behalf of the agent.

Following the signing, the transaction is sent to the Alchemy paymaster. The paymaster is responsible for executing the onchain transaction. As the transaction is processed on the blockchain, the user’s Gas Tank balance is automatically reduced by the cost of the paymaster transaction, calculated in USDC.

Engaging AI Agents to transact autonomously

Using Agent Wallets, users can engage and direct several SYNTAX Agents to start transacting autonomously on their behalf, eliminating the need to “approve in wallet” every time an agent wants to do a transaction. This will enable retail users to completely bypass the hassles of managing and operating wallets, because onchain tasks (such as calling contracts, interacting with addresses for pools, etc.) can be fully taken care of by the agent.

We believe such agentic design of wallet systems will be the way forward for our industry, enabling the next wave of Web3 users to interact onchain in a near frictionless way. We’re taking the first step by embedding Agent Wallets across the upcoming version of our product, SYNTAX V2, through the following features:

Creating an Agent Wallet

Creating an Agent Wallet

SYNTAX requires you to have an Agent Wallet for the agent to take actions on your behalf (as a design principle, we’ve built the platform Agent first; all agents require an Agent Wallet to function, and cant be executed directly from a user’s wallet).

Once you proceed to create the Agent Wallet, an ERC4337 smart account gets created through a paymaster, and the agent you’ve been talking with gets added as a signer to this account (creation of the Agent Wallet is a one time activity). Once added, the agent has access to deploy smart contracts and run smart contract functions. More agents can be added as signers to your agent wallet as you increase your engagement on the platform.The Agent Wallet leverages Alchemy's modular account kit, and is extended to support 1:2 multisignature functionality, enabling both the agent and the user to autonomously execute transactions through the agent wallet.

Deposit and Withdraw from Agent Wallet

Viewing Agent Wallet in your SYNTAX profile

Depositing funds into Agent Wallet

Depositing and withdrawing from an Agent Wallet is similar to using a classic EOA such as Metamask, Coinbase Wallet, etc. To deposit assets to be used by the agent, access your profile settings and select the currency and amount to be deposited. Once you click “deposit”, a transaction from your connected personal wallet will be automatically triggered. The funds thus deposited can be used by your agents to transact on your behalf.

The withdrawal process also looks similar; upon choosing the asset and the amount, the Agent Wallet's 1:2 multisig setup requires that either the user or the AI agent approve the transaction. Since you’re withdrawing, you would have to sign the transaction to withdraw through your connected personal wallet. Once this multisig transaction gets confirmed the funds will then appear in your personal wallet (for security reasons, both deposits and withdrawals from an agent wallet sent or received in the personal wallet connected to SYNTAX).

Gasless Transactions using Gas Tank

Viewing gas tank balance
Depositing funds into gas tank

The agentic wallet system also features a novel component known as the Gas Tank, a smart contract designed for facilitating transaction broadcasting using USDC instead of Ether. This Gas Tank is necessary for users and agents to communicate with the ERC-4337 paymaster, which facilitates the sending of transactions through a user’s smart wallet on their behalf. 

The most significant benefit of the Gas Tank is that users do not need any Ethereum to utilize Spectral SYNTAX. The Gas Tank eliminates the need for users to maintain a balance of Ether in their wallets, and agents also do not need to hold ETH in their signing keys. This means that the process of interacting with any arbitrary agent is much more simple, and doesn’t require a preliminary step of transferring Eth to each autonomous agent which you want to interact with. Instead, by maintaining a sufficient balance of USDC in their Gas Tank, users and agents can broadcast and transaction autonomously.

We believe that the Gas Tank concept, as implemented by a few other projects as well, will usher in seamless transactions onchain. Accordingly, we’re building SYNTAX V2 to be primarily gasless; any user will have to top up their gas tank to engage with any SYNTAX Agent.

Case study: ETH Trading Agent

Let's go through a simple example to understand how Agent Wallets will transform onchain interactions.

Imagine a user who is an active cryptocurrency trader but lacks the time to constantly monitor the market, and that user wants to build positions in ETH for short to medium term horizons. This user can set up an ETH trading agent through Spectral SYNTAX, or leverage an already existing agent that another user has created. The process begins by defining specific market conditions, such as price thresholds, volume triggers, or technical indicators, that the agent will use to make trading decisions. Users can also add a variety of non-trading indicators, such as latest twitter sentiment, onchain stake/unstake events, etc. into the context of the agent and ask it to analyze these circumstances.These rules are then programmed into the agent, which is then given permission with an Ethereum public/private key pair to autonomously decide when to run smart contract actions.

The user can then decide to allocate an arbitrary amount of funds to their agent by depositing them in the Agent Wallet. As the market fluctuates, the ETH trading agent continuously monitors the conditions. When the predefined criteria are met, the agent autonomously executes buy or sell orders. For instance, if the agent is programmed to buy ETH when its price drops below a certain threshold and there is a positive sentiment for ETH on twitter, it will automatically do so, using the funds in the ERC4337 wallet and paying for the transaction with USDC from the Gas Tank. No manual intervention from the user would be necessary, and the agent can transact and settle trades at lightning speeds while comparing both price and sentiment related information instantaneously. How the agent does all this is also obscured from the user, because the Agent accesses SYNTAX’s pre-built plugins (tools) and their functions supporting key dApps such as Uniswap, Transpose, etc. 

Empowering the Future of Onchain Interactions

Agent Wallets represent a groundbreaking step towards redefining onchain interactions. By letting users build powerful Agents on SYNTAX, and giving these agents autonomous ability to operate their own wallets, we're empowering the next billion people to create exponential value onchain.

As we move forward, our commitment to innovation and user-centric design will continue to drive the development SYNTAX V2, which will pave the way for a more accessible and dynamic future for all Web3 users. Follow our blog and and X to keep receiving more updates on SYNTAX V2, launching soon in Q3 2024.