solana/docs/src/api/methods/_getFeeForMessage.mdx

87 lines
1.5 KiB
Plaintext

import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## getFeeForMessage
Get the fee the network will charge for a particular Message
:::caution
**NEW: This method is only available in solana-core v1.9 or newer. Please use
[getFees](#getFees) for solana-core v1.8**
:::
<DocSideBySide>
<CodeParams>
### Parameters:
<Parameter type={"string"} required={true}>
Base-64 encoded Message
</Parameter>
<Parameter type={"object"} optional={true}>
Configuration object containing the following fields:
<Field
name="commitment"
type="string"
optional={true}
href="/api/http#configuring-state-commitment"
></Field>
<Field name="minContextSlot" type="number" optional={true}>
The minimum slot that the request can be evaluated at
</Field>
</Parameter>
### Result:
- `<u64|null>` - Fee corresponding to the message at the specified blockhash
</CodeParams>
<CodeSnippets>
### Code sample:
```bash
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{
"id":1,
"jsonrpc":"2.0",
"method":"getFeeForMessage",
"params":[
"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",
{
"commitment":"processed"
}
]
}
'
```
### Response:
```json
{
"jsonrpc": "2.0",
"result": { "context": { "slot": 5068 }, "value": 5000 },
"id": 1
}
```
</CodeSnippets>
</DocSideBySide>
</DocBlock>