I'd like to show my users if an error occurred while doing a proxy.proxy call. While I know how to decode a system.ExtrinsicFailed, as this is well documented, I have difficulties finding the correct way to decode an error from proxy.ProxyExecuted when printed to string, it shows [{"err":{"module":{"index":4,"error":"0x02000000"}}}] when there's an error or [{"ok": null}] in case it succeeded.

What would be the best way to check the status and decode the error?

I am ideally looking at something similar than

const [dispatchError] = data
const decoded = api.registry.findMetaError((dispatchError as any).asModule);
const errorInfo = `${decoded.docs} - ${decoded.section}.${decoded.name}`;

But checking if dispatchError.err exists or forcing it with asModule doesn't end well, although it looks like a module. It needs a step in between to be decoded it seems, that I'm missing.

  • Did you strip the trailing zeroes from the 0x02000000 before encoding it as a number? e.g. use 0x02. The other zeroes are for extra error data.
    – forgetso
    Commented Feb 1, 2023 at 15:14

2 Answers 2


Thanks a lot forgetso for your help. this definitely got me on the right track. For some reason, the asModule didn't work. I had subsequent TS errors such as toNumber is not a function.

I had to use toJSON to what came back from the event to work my way through. That's the working code:

const [dispatchError]: any = data.toJSON();

// if proxy has an error
if (dispatchError?.err?.module) {
  const mod = dispatchError.err.module
  const error = api.registry.findMetaError(
    new Uint8Array([Number(mod.index), Number(mod.error.slice(0, 4))])

  errorInfo = Array.isArray(error.docs) ? error.docs.join('') : error.docs || ''
  • Glad you got it sorted. If you're getting TS errors like x doesn't exist on Codec you can use this guide.
    – forgetso
    Commented Feb 2, 2023 at 9:28

I think you need to strip the trailing zeroes from the error code and decode the error as follows:

            const mod = dispatchError.asModule
            const error = api.registry.findMetaError(
                new Uint8Array([mod.index.toNumber(), bnFromHex(mod.error.toHex().slice(0, 4)).toNumber()])
            message = `${error.section}.${error.name}${
                Array.isArray(error.docs) ? `(${error.docs.join('')})` : error.docs || ''

This will give you the module at index 4, error with index 2. e.g. in substrate


          "name": "Authorship",

          "errors": {
            "type": 424 // use this value to look for the errors
          "index": 4

    "id": 424,
    "type": {
      "path": [
      "def": {
        "variant": {
          "variants": [
              "name": "TooManyUncles", // this might be your error
              "fields": [],
              "index": 2,
              "docs": [
                "Too many uncles."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.