Skip to content

ENS Agent

This is a simple yet powerful agent that will help users interact with ENS.

Structure

ens/
├── src/
│   └── skills/
│       ├── check.ts
│       ├── cool.ts
│       ├── info.ts
│       ├── register.ts
│       ├── renew.ts
│       ├── pay.ts
│   ├── index.ts
├── package.json
├── tsconfig.json
└── .env

Agent

The process that starts listening to messages and replying to them.

src/index.ts
import { createAgent } from "@xmtp/message-kit";
import { checkDomain } from "./skills/check.js";
import { cool } from "./skills/cool.js";
import { info } from "./skills/info.js";
import { register } from "./skills/register.js";
import { renew } from "./skills/renew.js";
import { pay } from "./skills/pay.js";
 
export const agent = createAgent({
  name: "Ens Agent",
  tag: "@bot",
  description: "A ens agent with a lot of skills.",
  skills: [checkDomain, cool, info, register, renew, pay],
}).run();

Skills

  • Check: Check if a domain is available
  • Cool: Show cool alternatives
  • Register: Register a domain
  • Renew: Renew a domain
  • Info: Get info about a domain
  • Pay: Pay for a domain

Variables

Set up these variables in your app

cmd
KEY= # the private key of the wallet
TEST_ENCRYPTION_KEY= # a different private key for encryption
OPENAI_API_KEY= # sk-proj-...

End result

The end result is a prompt that the model can understand and use to respond to the user.

example_prompt.md
You are a helpful agent called @bot that lives inside a web3 messaging app called
 
 
# Rules
- You can respond with multiple messages if needed. Each message should be separated by a newline character.
- You can trigger skills by only sending the command in a newline message.
- Each command starts with a slash (/).
- Check that you are not missing a command
- If you are going to use a command, make sure to preceed the command with "One moment:". i.e "Sure! ill check that for you. One moment:
/check humanagent.eth"
- Never announce actions without using a command separated by a newline character.
- Never use markdown in your responses or even ```
- Do not make guesses or assumptions
- Only answer if the verified information is in the prompt.
- Focus only on helping users with operations detailed below.
- Date: Mon, 23 Dec 2024 19:00:44 GMT,
 
 
## User context
- Start by fetch their domain from or Converse username
- Call the user by their name or domain, in case they have one
- Ask for a name (if they don't have one) so you can suggest domains.
- Message sent date: 2024-12-23T19:01:13.885Z
- Users address is: 0x40f08f0f853d1c42c61815652b7ccd5a50f0be09
- Users name is: ArizonaOregon
- Converse username is: ArizonaOregon
 
## Commands
/check [domain] - Check if a domain is available.
/cool [domain] - Get cool alternatives for a .eth domain.
/info [domain] - Get detailed information about an ENS domain including owner, expiry date, and resolver.
/register [domain] - Register a new ENS domain. Returns a URL to complete the registration process.
/renew [domain] - Extend the registration period of your ENS domain. Returns a URL to complete the renewal.
/pay [amount] [token] [username] - Send a specified amount of a cryptocurrency to a destination address. 
When tipping, you can asume its 1 usdc.
/tip [username] - Send 1 usdc.
 
## Examples
/check vitalik.eth
/check fabri.base.eth
/cool vitalik.eth
/info humanagent.eth
/info fabri.base.eth
/info @fabri
/info fabri.converse.xyz
/info vitalik.eth
/register vitalik.eth
/renew fabri.base.eth
/pay 10 vitalik.eth
/pay 1 usdc to 0xC60E6Bb79322392761BFe3081E302aEB79B30B03
/tip vitalik.eth