Go4Me Skill
Send XCH to Twitter users by resolving their Go4Me addresses.
Dependencies
- - sage-wallet — Required for XCH transactions
Commands
| Command | Description |
|---|
| INLINECODE0 | Get user's XCH address and profile |
| INLINECODE1 |
Send XCH to user (amount in XCH or mojos) |
|
/go4me tip <user> | Send 1 mojo tip |
Natural Language
- - "Send 1 XCH to @hoffmang"
- "Tip @sage_wallet"
- "What's @bramcohen's XCH address?"
- "Look up DracattusDev on Go4Me"
Lookup Script
CODEBLOCK0
Workflow
Lookup
- 1. Strip
@ from username if present - Run INLINECODE4
- Parse JSON response for
xchAddress, fullName, INLINECODE7 - If exit code 1: user not found on Go4Me
Send
- 1. Lookup user (as above)
- If not found, report error
- Display confirmation:
Send <amount> to @<username> (<fullName>)?
Address: <xchAddress>
[Yes] [No]
- 4. On confirm, call sage-wallet
send_xch:
curl -s --cert $CERT --key $KEY -X POST https://127.0.0.1:9257/send_xch \
-H "Content-Type: application/json" \
-d '{"address":"<xchAddress>","amount":"<mojos>","fee":"0","memos":[],"auto_submit":true}'
- 5. Report transaction result
Tip
Same as send with amount = 1 mojo.
Amount Conversion
| Input | Mojos |
|---|
| INLINECODE9 (no unit) | 1 mojo |
| INLINECODE10 |
1 |
|
0.001 XCH | 1000000000 |
|
1 XCH | 1000000000000 |
Parse amount: if contains "XCH", multiply by 10^12. Default unit is mojos for small numbers, XCH for decimals.
Error Handling
| Condition | Response |
|---|
| User not on Go4Me | "User @{username} not found on Go4Me" |
| Invalid address |
"Invalid XCH address returned from Go4Me" |
| Insufficient balance | "Insufficient balance for this transaction" |
| Network error | "Failed to connect to Go4Me" |
Data Available
| Field | Example |
|---|
| INLINECODE13 | DracattusDev |
| INLINECODE14 |
🌱Drac 🍊 |
|
xchAddress | xch1rvgc3naytvzhv4lxhzphrdr2fzj2ka340tdj8fflt4872t2wqveq9lwz7t |
|
description | Bio text |
|
avatarUrl | Profile image URL |
|
totalBadgeScore | 220 |
Go4Me 技能
通过解析用户的 Go4Me 地址,向 Twitter 用户发送 XCH。
依赖项
命令
| 命令 | 描述 |
|---|
| /go4me lookup <用户> | 获取用户的 XCH 地址和个人资料 |
| /go4me send <用户> <数量> |
向用户发送 XCH(数量以 XCH 或 mojos 为单位) |
| /go4me tip <用户> | 发送 1 mojo 小费 |
自然语言
- - 发送 1 XCH 给 @hoffmang
- 打赏 @sage_wallet
- @bramcohen 的 XCH 地址是什么?
- 在 Go4Me 上查找 DracattusDev
查找脚本
bash
source scripts/go4me-lookup.sh
go4me_lookup DracattusDev # 返回 JSON 或退出码 1
工作流程
查找
- 1. 如果用户名包含 @,则去除
- 运行 go4me_lookup <用户名>
- 解析 JSON 响应,获取 xchAddress、fullName、username
- 如果退出码为 1:Go4Me 上未找到该用户
发送
- 1. 查找用户(如上所述)
- 如果未找到,报告错误
- 显示确认信息:
发送 <数量> 给 @<用户名> (<全名>)?
地址:
[是] [否]
- 4. 确认后,调用 sage-wallet 的 send_xch:
bash
curl -s --cert $CERT --key $KEY -X POST https://127.0.0.1:9257/send_xch \
-H Content-Type: application/json \
-d {address:
,amount:,fee:0,memos:[],auto_submit:true}
- 5. 报告交易结果
打赏
与发送相同,数量为 1 mojo。
数量转换
| 输入 | Mojos |
|---|
| 1(无单位) | 1 mojo |
| 1 mojo |
1 |
| 0.001 XCH | 1000000000 |
| 1 XCH | 1000000000000 |
解析数量:如果包含 XCH,则乘以 10^12。小数字默认单位为 mojos,小数为 XCH。
错误处理
| 条件 | 响应 |
|---|
| Go4Me 上未找到用户 | Go4Me 上未找到用户 @{用户名} |
| 无效地址 |
Go4Me 返回的 XCH 地址无效 |
| 余额不足 | 交易余额不足 |
| 网络错误 | 无法连接到 Go4Me |
可用数据
| 字段 | 示例 |
|---|
| username | DracattusDev |
| fullName |
🌱Drac 🍊 |
| xchAddress | xch1rvgc3naytvzhv4lxhzphrdr2fzj2ka340tdj8fflt4872t2wqveq9lwz7t |
| description | 个人简介文本 |
| avatarUrl | 头像图片 URL |
| totalBadgeScore | 220 |