# author_pendingExtrinsics - Moonbase RPC Method

Returns all pending extrinsics currently in the transaction pool on Moonbase Alpha. These are signed extrinsics that have been submitted but not yet included in a finalized block.

> **Why Moonbase?** Build on the Moonbeam testnet for risk-free EVM dApp development and deployment testing with free testnet tokens, full EVM compatibility, XCM testing capabilities, and identical feature set to Moonbeam mainnet.

## When to Use This Method

`author_pendingExtrinsics` is essential for Moonbeam developers, dApp testers, and teams validating cross-chain integrations:

- **Transaction Confirmation** -- Verify whether a submitted extrinsic is still pending or has been included in a block on Moonbase
- **Mempool Monitoring** -- Monitor the transaction pool size and activity for EVM dApp testing, XCM integration validation, and pre-mainnet deployment verification
- **Network Congestion Analysis** -- Gauge current network load by inspecting the number and type of pending extrinsics
- **Validator Tooling** -- Build block authoring tools that inspect the ready queue before producing blocks

## Best Practices

- Response can be large on congested networks -- filter by sender address client-side
- Not available on all node configurations (some providers disable author namespace)
- Use for mempool inspection and transaction congestion diagnosis
- Pending extrinsics are not guaranteed to be included -- monitor with confirmation polling

## Request Parameters

This method accepts no parameters.

## Request Example

```json
{
  "jsonrpc": "2.0",
  "method": "author_pendingExtrinsics",
  "params": [],
  "id": 1
}
```

## Response Fields

- `result` (`Array<String>, required`): Array of hex-encoded SCALE-encoded signed extrinsics currently in the transaction pool

## Successful Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    "0x2d0284ff...",
    "0x3102840f..."
  ]
}
```

## Error Responses

### Error Response

- Code: `-32603`

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32603,
    "message": "Internal error"
  }
}
```

## Code Examples

cURL
JavaScript
Python
Rust

```bash
curl -X POST https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "author_pendingExtrinsics",
    "params": [],
    "id": 1
  }'
```

```javascript
// Using @polkadot/api
import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('wss://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });

const pending = await api.rpc.author.pendingExtrinsics();
console.log('Pending extrinsics:', pending.length);

pending.forEach((ext, idx) => {
  console.log(`${idx}: ${ext.method.section}.${ext.method.method}`);
  console.log(`   Signer: ${ext.signer.toString()}`);
  console.log(`   Nonce: ${ext.nonce.toString()}`);
  console.log(`   Tip: ${ext.tip.toString()}`);
});

await api.disconnect();

// Using fetch (HTTP JSON-RPC)
const response = await fetch('https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'author_pendingExtrinsics',
    params: [],
    id: 1
  })
});

const { result } = await response.json();
console.log(`${result.length} pending extrinsics in pool`);
```

```python
import requests

def get_pending_extrinsics():
    response = requests.post(
        'https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY',
        json={
            'jsonrpc': '2.0',
            'method': 'author_pendingExtrinsics',
            'params': [],
            'id': 1
        }
    )
    return response.json()['result']

pending = get_pending_extrinsics()
print(f'Pending extrinsics: {len(pending)}')

# Using substrate-interface
from substrateinterface import SubstrateInterface

substrate = SubstrateInterface(url='wss://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY')
result = substrate.rpc_request('author_pendingExtrinsics', [])['result']
print(f'Pending extrinsics: {len(result)}')

for i, ext_hex in enumerate(result):
    print(f'  {i}: {ext_hex[:40]}...')
```

```rust
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    let response = client
        .post("https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "author_pendingExtrinsics",
            "params": [],
            "id": 1
        }))
        .send()
        .await?;

    let result: serde_json::Value = response.json().await?;
    let pending = result["result"].as_array().unwrap();

    println!("Pending extrinsics: {}", pending.len());
    for (i, ext) in pending.iter().enumerate() {
        let hex = ext.as_str().unwrap();
        println!("  {}: {}...", i, &hex[..std::cmp::min(40, hex.len())]);
    }
    Ok(())
}
```

## Common Use Cases

### 1. Transaction Pool Monitor

Continuously monitor the Moonbase transaction pool and alert on unusual activity:

```javascript
import { ApiPromise, WsProvider } from '@polkadot/api';

async function monitorPool(api, interval = 6000) {
  let previousCount = 0;

  setInterval(async () => {
    const pending = await api.rpc.author.pendingExtrinsics();
    const count = pending.length;

    if (count !== previousCount) {
      console.log(`Pool size changed: ${previousCount} -> ${count}`);

      if (count > 100) {
        console.warn('High pool activity detected!');
      }
    }

    // Analyze pending extrinsic types
    const byPallet = {};
    pending.forEach((ext) => {
      const key = `${ext.method.section}.${ext.method.method}`;
      byPallet[key] = (byPallet[key] || 0) + 1;
    });

    if (Object.keys(byPallet).length > 0) {
      console.log('Pending by type:', byPallet);
    }

    previousCount = count;
  }, interval);
}
```

### 2. Verify Transaction Submission

Check that a submitted extrinsic appears in the pool:

```javascript
async function verifyInPool(api, txHash) {
  const pending = await api.rpc.author.pendingExtrinsics();

  const found = pending.find((ext) => ext.hash.toHex() === txHash);

  if (found) {
    console.log(`Transaction ${txHash} is in the pool`);
    console.log(`  Call: ${found.method.section}.${found.method.method}`);
    return true;
  }

  console.log(`Transaction ${txHash} not found in pool (may already be included)`);
  return false;
}
```

### 3. Pool Congestion Analysis

Analyze network congestion to decide on tip amounts:

```javascript
async function analyzeCongestion(api) {
  const pending = await api.rpc.author.pendingExtrinsics();

  const tips = pending.map((ext) => ext.tip.toBigInt());
  const totalTips = tips.reduce((sum, tip) => sum + tip, 0n);
  const avgTip = tips.length > 0 ? totalTips / BigInt(tips.length) : 0n;
  const maxTip = tips.length > 0 ? tips.reduce((a, b) => (a > b ? a : b), 0n) : 0n;

  return {
    poolSize: pending.length,
    averageTip: avgTip.toString(),
    maxTip: maxTip.toString(),
    congested: pending.length > 50
  };
}
```

## Related Methods

- [`author_submitExtrinsic`](https://www.dwellir.com/docs/moonbase-alpha/author_submitExtrinsic) -- Submit a signed extrinsic to the transaction pool
- [`payment_queryInfo`](https://www.dwellir.com/docs/moonbase-alpha/payment_queryInfo) -- Estimate fees for an extrinsic before submission
- [`system_chain`](https://www.dwellir.com/docs/moonbase-alpha/system_chain) -- Get the chain name
- [`chain_getBlock`](https://www.dwellir.com/docs/moonbase-alpha/chain_getBlock) -- Get a finalized block to see which extrinsics were included
