Skip to main content

Execute Transaction From Agent Wallet

An agent wallet is an embedded wallet that is controlled by the AI agent and owned by the user that can be used to execute on-chain transactions for users.

Each user that created a Senpi account on senpi.ai automatically assigned a unique agent wallet, which on the the platform is labeled as an Embedded Wallet.

As a skills developer, you can access the user's agent wallet to execute onchain transactions and sign messages.

Executing Transactions Using the Agent Wallet

To execute transactions using the agent wallet, you can simply use the moxieWalletClient state in your skill that is injected by the Senpi Client as shown below:

info

Currently, only EVM transactions are supported within the Senpi Eliza Skills Framework.

import {
type Action,
type IAgentRuntime,
type Memory,
type HandlerCallback,
type State,
} from "@moxie-protocol/core";

export const exampleAction: Action = {
handler: async (
runtime: IAgentRuntime,
message: Memory,
state: State,
_options: { [key: string]: unknown },
callback: HandlerCallback
) => {
const moxieWalletClient = state.moxieWalletClient;
// Execute a transaction on user's agent wallet
const { hash, caip2 } = await moxieWalletClient.sendTransaction(
// EVM Chain ID
"8453",
// Transaction Data
{
fromAddress: "0x1234567890123456789012345678901234567890",
toAddress: "0x1234567890123456789012345678901234567890",
data: "0x",
value: 1000000000000000000,
}
);
return true;
},
};

Keep in mind that in production, the agent wallet will be dynamically injected into the skill's runtime state depending on the user interacting with the skill.

However, for local development purposes, the agent wallet will be based on the private key that you have set in the local .env file.

Developer Support

If you have any questions or need help with other use cases, feel free to join the Senpi Telegram Developers Channel and ask your questions there.

Our team is always ready to help you with any questions you may have.