claim-rewards
Claim validator rewards on MantraChain using the MCP Server. Enter the validator's operator address and network name, with an optional memo, to process the transaction.
Instructions
Claim rewards for a specific validator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memo | No | Optional memo for the transaction | |
| networkName | Yes | Name of the network to use - must first check what networks are available through the mantrachain-mcp server by accessing the networks resource `networks://all` before you pass this arguments | |
| operatorAddress | Yes | Address of the validator to claim rewards from |
Implementation Reference
- src/tools/staking.ts:79-90 (handler)MCP tool execution handler for 'claim-rewards'. Initializes the MantraClient for the specified network and calls the client's claimRewards method, returning the transaction result as JSON.async ({ operatorAddress, networkName, memo }) => { await mantraClient.initialize(networkName); const result = await mantraClient.claimRewards({ operatorAddress, memo }); return { content: [{type: "text", text: JSON.stringify(result)}], }; }
- src/tools/staking.ts:73-78 (schema)Zod schema defining input parameters for the 'claim-rewards' tool: operatorAddress (required), networkName (required, validated against available networks), memo (optional).operatorAddress: z.string().describe("Address of the validator to claim rewards from"), networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."), memo: z.string().optional().describe("Optional memo for the transaction") },
- src/tools/staking.ts:69-91 (registration)Registration of the 'claim-rewards' tool on the MCP server within the registerStakingTools function, specifying name, description, input schema, and handler.server.tool( "claim-rewards", "Claim rewards for a specific validator", { operatorAddress: z.string().describe("Address of the validator to claim rewards from"), networkName: z.string().refine(val => Object.keys(networks).includes(val), { message: "Must be a valid network name" }).describe("Name of the network to use - must first check what networks are available by accessing the networks resource `networks://all` before you pass this arguments. Defaults to `mantra-dukong-1` testnet."), memo: z.string().optional().describe("Optional memo for the transaction") }, async ({ operatorAddress, networkName, memo }) => { await mantraClient.initialize(networkName); const result = await mantraClient.claimRewards({ operatorAddress, memo }); return { content: [{type: "text", text: JSON.stringify(result)}], }; } );
- Supporting utility in StakingService: the claimRewards method that performs the actual blockchain interaction by calling withdrawRewards on the wasmClient to claim staking rewards.async claimRewards({ operatorAddress, memo = '' }: ClaimRewardsParams): Promise<TransactionResponse> { try { const result = await this.wasmClient.withdrawRewards( this.address, operatorAddress, 'auto', memo ); return { transactionHash: result.transactionHash, explorerUrl: `${this.network.explorerUrl}/tx/${result.transactionHash}`, success: result.code === 0, gasUsed: result.gasUsed.toString(), gasWanted: result.gasWanted.toString(), }; } catch (error) { throw new Error(`Failed to claim rewards: ${error instanceof Error ? error.message : String(error)}`); } }
- src/mantra-client.ts:192-197 (helper)Wrapper method in MantraClient that delegates claimRewards to the underlying StakingService instance.async claimRewards(params: ClaimRewardsParams): Promise<TransactionResponse> { if (!this.stakingService) { throw new Error('Client not initialized. Call initialize() first.'); } return this.stakingService.claimRewards(params); }