Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ whoami Show current agent profile summary

wallet address Get agent wallet address
wallet balance Get all token balances
wallet topup Get topup URL to add funds
wallet send-transaction Send a raw transaction
--to <address> Recipient address (required)
--value <amount> Transaction value (default: 0)
--data <hex> Transaction calldata (default: 0x)

browse <query> Search agents on the marketplace

Expand Down Expand Up @@ -113,6 +118,9 @@ acp job pay 123 --accept true --content 'Looks good, please proceed'
# Check wallet
acp wallet balance

# Send a raw transaction
acp wallet send-transaction --to "0x1234..." --value "1000" --data "0x"

# Launch a token
acp token launch MYAGENT "My agent token"

Expand Down
19 changes: 19 additions & 0 deletions bin/acp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ function buildHelp(): string {
cmd("wallet address", "Get agent wallet address"),
cmd("wallet balance", "Get all token balances"),
cmd("wallet topup", "Get topup URL to add funds"),
cmd("wallet send-transaction", "Send a raw transaction"),
flag("--to <address>", "Recipient address (required)"),
flag("--value <amount>", "Transaction value (default: 0)"),
flag("--data <hex>", "Transaction calldata (default: 0x)"),
"",
section("Token"),
cmd("token launch <symbol> <desc>", "Launch agent token"),
Expand Down Expand Up @@ -227,6 +231,11 @@ function buildCommandHelp(command: string): string | undefined {
"",
cmd("address", "Get your wallet address (Base chain)"),
cmd("balance", "Get all token balances in your wallet"),
cmd("topup", "Get topup URL to add funds"),
cmd("send-transaction", "Send a raw transaction"),
flag("--to <address>", "Recipient address (required)"),
flag("--value <amount>", "Transaction value (default: 0)"),
flag("--data <hex>", "Transaction calldata (default: 0x)"),
"",
].join("\n"),

Expand Down Expand Up @@ -596,6 +605,16 @@ async function main(): Promise<void> {
if (subcommand === "address") return wallet.address();
if (subcommand === "balance") return wallet.balance();
if (subcommand === "topup") return wallet.topup();
if (subcommand === "send-transaction") {
const to = getFlagValue(rest, "--to");
const value = getFlagValue(rest, "--value") ?? "0";
const txData = getFlagValue(rest, "--data") ?? "0x";
if (!to) {
console.error("Error: --to <address> is required");
process.exit(1);
}
return wallet.sendTransaction(to, value, txData);
}
console.log(buildCommandHelp("wallet"));
return;
}
Expand Down
26 changes: 23 additions & 3 deletions src/commands/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// =============================================================================
// acp wallet address — Get wallet address
// acp wallet balance — Get token balances
// acp wallet topup — Get topup URL
// acp wallet address — Get wallet address
// acp wallet balance — Get token balances
// acp wallet topup — Get topup URL
// acp wallet send-transaction — Send a raw transaction
// =============================================================================

import { getPaymentUrl } from "../lib/api.js";
Expand Down Expand Up @@ -102,3 +103,22 @@ export async function topup(): Promise<void> {
output.fatal(`Failed to get topup URL: ${e instanceof Error ? e.message : String(e)}`);
}
}

export async function sendTransaction(to: string, value: string, data: string): Promise<void> {
try {
const res = await client.post("/acp/wallets/send-transaction", { to, value, data });

output.output(res.data, (res) => {
output.heading("Send Transaction");
output.field("To", to);
output.field("Value", value);
output.field("Data", data);
if (res?.data?.txHash) {
output.field("Tx Hash", res.data.txHash);
}
output.log("");
});
} catch (e) {
output.fatal(`Failed to send transaction: ${e instanceof Error ? e.message : String(e)}`);
}
}