SudoAsDone

Event Re-added v101 → v150, v151 → current #3

Emitted when a sudo_as call completes, reporting success or failure.

View events on chain
Useful for: validatorsdevelopersanalytics

The Big Picture

SudoAsDone records when the sudo key has acted on behalf of another account. This is a sensitive operation - the sudo key is essentially impersonating users. The event provides transparency, allowing anyone to see when and for whom this power was used.

Why This Matters

sudo_as allows administrators to act as any user - a powerful but dangerous tool. SudoAsDone creates an audit trail of these actions. Users can check if admin ever acted on their behalf, and governance can verify these powers aren't abused.

Example Scenario

A user's account is stuck due to a bug requiring a signed call to fix. The sudo key calls sudo_as(who=user_account, call=fix_bug()). SudoAsDone fires with sudo_result=Ok(()). The user can see this event and verify the intervention happened (and why).

Common Questions

How can users detect if sudo_as was used on their account?
Filter SudoAsDone events by the 'who' parameter (target account). Any such events indicate admin action on that account.
Is sudo_as more dangerous than regular sudo?
Different danger. Regular sudo gets Root origin (can do anything). sudo_as gets Signed origin (acts as a specific user). Both are powerful and need monitoring.

Use Cases

  • Track impersonation for support operations
  • Audit when sudo acts on behalf of users
  • Monitor for misuse of sudo_as powers
  • Investigate account-specific admin interventions

How to Use This Event

  • Alert on SudoAsDone events for governance monitoring
  • Track which accounts have been acted upon
  • Cross-reference with support tickets for legitimate uses

From Chain Metadata

A [sudo_as](Pallet::sudo_as) call just took place.

Triggers

Emitted by

Preconditions

  • Caller is the current sudo key
  • A sudo_as call was executed
  • Target account is valid

Effects

Postconditions

  • Inner call result is recorded
  • If successful, state changes reflect the target account having signed

Side Effects

  • Target account's state may have changed as if they acted
  • Audit trail shows the sudo key acted on their behalf

Event Data

#NameTypeDescription
0
sudo_result
Result Result of the inner call execution (Ok or Err with error details)

Code Examples

import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";

const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });

// Subscribe to SudoAsDone events
api.query.system.events((events) => {
  events
    .filter(({ event }) =>
      event.section === stringCamelCase("Sudo") &&
      event.method === "SudoAsDone"
    )
    .forEach(({ event }) => {
      console.log("SudoAsDone:", event.data.toHuman());
    });
});

Version History

v101 block 1 1 args
v151 block 3,157,274 1 args Current

Runtime Info

Pallet Index
12
Event Index
3
First Version
v101
Current Version
v393