Skill-Details

injective-trading-autosign

Enables scoped automated perpetual-trading authorization.

ÜbereinstimmungDirektGeprüft für trading
Quelleinjectivelabs/agent-skillsExterne Quelle
Gemeldete Installationen30Nur Popularitätssignal

Vor Nutzung prüfen

Die automatische Prüfung bewertet Relevanz, nicht Sicherheit oder Empfehlung. Lies vor der Nutzung die Quellanweisungen.

Gespeicherte Quellvorschau

SKILL.md

Dieser Auszug wurde bei der Prüfung gespeichert. Die externe Quelle enthält die vollständige und aktuelle Version.

---
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
Vollständige Quelle auf GitHub lesen (öffnet externe Seite)
Kontext

Verwandte Arbeit