Skill 详情

injective-trading-autosign

Enables scoped automated perpetual-trading authorization.

匹配类型直接匹配已针对 交易 审核
来源injectivelabs/agent-skills外部来源
报告安装量30仅表示受欢迎程度

使用前先检查

自动化审核只检查相关性,不代表安全审查或推荐。使用前请阅读来源中的说明。

已保存的来源预览

SKILL.md

这段内容是审核时保存的快照。外部来源才是完整且最新的版本。

---
name: injective-trading-autosign
description: Set up AuthZ delegation on Injective for session-based auto-trading. Grants a scoped, time-limited permission to an ephemeral key so the AI can place and close perpetual trades without a wallet popup or password prompt for every order. Use authz_grant to enable, authz_revoke to disable. Requires the Injective MCP server to be connected.
uses: ["injective-mcp-servers", "injective-faucet"]
license: MIT
metadata:
  author: ckhbtc
  version: "0.0.0"
---

## Injective Trading Autosign, Skill Guide

AuthZ delegation lets a user grant a scoped, on-chain permission to a secondary key (the "grantee") to execute specific message types on their behalf.
This enables session-based trading without password prompts per trade.

**Security model**: The grant is scoped to specific Cosmos message types (trading only - no withdrawals or transfers).
It expires automatically. The user can revoke at any time.

## When to apply

- When you wish to give another account permission to execute transactions on behalf of your account
- When you wish to revoke this permission
- When you wish to granularly limit the scope of these permission to specific transaction types

Sample prompts: `./references/sample-prompts.md`

## Important

### Safe Message Types for Trading

**Only grant** these types - they cover all perpetual trading operations:

| Message Type | What it allows |
|---|---|
| `MsgCreateDerivativeMarketOrder` | Open/close positions via market order |
| `MsgCreateDerivativeLimitOrder` | Place limit orders |
| `MsgCancelDerivativeOrder` | Cancel limit orders |
| `MsgBatchUpdateOrders` | Batch order operations |
| `MsgIncreasePositionMargin` | Add margin to existing position |

**Never grant** `MsgSend`, `MsgWithdraw`, governance messages, or any transfer-related types.

## Notes

- AuthZ is an on-chain Cosmos SDK primitive - the grant is recorded on Injective and verifiable by anyone.
- The granter pays gas for the grant and revoke transactions. The grantee pays gas for authorized transactions.
- Injective's fee delegation (if enabled) can cover grantee gas, enabling fully gasless session trading.
- Expiry is in seconds from time of grant. 86400 = 24h, 259200 = 72h.
- If the grantee key is compromised, revoke immediately - the grant is limited to trading actions only, not withdrawals.

## Browser Readiness And Session Validation

For trading frontends, distinguish wallet connection, on-chain grant existence,
and app readiness:

- A connected wallet is not enough; the UI should show trading as unavailable
  until the AuthZ grant, grantee key, fee path, and current wallet address all
  line up.
- Revalidate the local grantee or session bundle against the active granter
  `inj1` address after connect, account swap, reload, and revoke. Stale session
  state from a prior wallet should force a fresh grant.
- Do not hide an on-chain revoke failure by clearing local state first.
  Broadcast `MsgRevoke`, verify success, then clear the local session bundle.
- In browser apps with trade buttons, keep a single in-flight trade lock for the
  active granter and grantee pair. Release it only once broadcast confirmation
  or failure is known.
- Use user-facing status copy such as `Authorize wallet`, `Order pending`, or
  `Order failed, please try again.` Keep sequence numbers, raw CheckTx logs, and
  tx internals in developer logs.

## Browser-Based AutoSign (MetaMask, Rabby, Keplr + EIP-712)

When implementing AutoSign in a browser frontend (e.g. `autosign.ts` with `enableAutoSign`):

### evmChainId — Read from Wallet, Never Hardcode

The `evmChainId` stored in the AutoSign state must be the **actual wallet chain at the moment the grant tx is signed**, NOT a hardcoded value:

```js
// Correct — read from wallet
const evmChainId = parseInt(await window.ethereum.request({ method: 'eth_chainId' }), 16);
// Wrong — hardcoding bypasses wallet chain enforcement
const evmChainId = 1776;
```

### Wallet Compatibility

**W
在 GitHub 阅读完整来源 (打开外部页面)
相关上下文

相关工作