> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getFeeForMessage

> Get the fee the network will charge for a particular message

## Parameters

<ParamField query="message" type="string" required>
  Base-64 encoded Message
</ParamField>

<ParamField query="commitment" type="string" optional>
  The commitment level to use for the fee calculation
</ParamField>

## Response

<ResponseField name="result" type="object">
  <Expandable title="result fields">
    <ResponseField name="context" type="object">
      <ResponseField name="slot" type="number">
        The slot this request was processed in
      </ResponseField>
    </ResponseField>

    <ResponseField name="value" type="number | null">
      Fee in lamports that will be charged for processing the message, or null if the message is invalid or the fee cannot be calculated
    </ResponseField>
  </Expandable>
</ResponseField>

## Code Examples

### Basic Request

```bash theme={null}
curl http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getFeeForMessage",
  "params": [
    "AQABAyRn/PA8jzJtN6oAyB3VR0nfOF0xnfkYaKwY4Ir3nrHFJGqhAQICAAEDAgABDAIAAAAEAAAAAAAA",
    {"commitment": "processed"}
  ]
}'
```

### Using web3.js

```typescript theme={null}
import { Connection } from '@solana/web3.js';

const connection = new Connection('http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
const message = 'AQABAyRn/PA8jzJtN6oAyB3VR0nfOF0xnfkYaKwY4Ir3nrHFJGqhAQICAAEDAgABDAIAAAAEAAAAAAAA';
const fee = await connection.getFeeForMessage(message);
console.log(fee);
```

### Using Python

```python theme={null}
from solana.rpc.api import Client

client = Client("http://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY")
message = "AQABAyRn/PA8jzJtN6oAyB3VR0nfOF0xnfkYaKwY4Ir3nrHFJGqhAQICAAEDAgABDAIAAAAEAAAAAAAA"
response = client.get_fee_for_message(message)
print(response)
```

## Notes

1. Returns the fee the network will charge for a particular message
2. Useful for calculating transaction fees more accurately
3. Preferred over older fee calculation methods
4. Different commitment levels can be specified
5. Returns null if the message is invalid or can't be processed

## Best Practices

1. Use this method for accurate fee prediction before sending transactions
2. Provide a valid base64-encoded message to avoid null responses
3. Handle null responses appropriately in your application
4. Handle network errors and retry when appropriate
5. Use this method when precise fee calculation is needed
