Skip to content

๐Ÿงช How to Check If a Wallet Has Staked MAT โ€‹

There are 21 active staking pools on Matchain.

ts
const stakingPoolAddresses = [
  "0xf9Ff433f14f237CE6643257ca4Cd5AEc355eaEE7",
  "0x256b02b26C67029B2881ab5d493cf8E5068D5Fcc",
  "0xa3BE9646116F834D0f9F1a035fdAd6862b5f0A2A",
  "0xfa38f584f561642Ff0d1AB67b5A175798668A047",
  "0x443D8318224C59c31987EA310033D0DC47A10d88",
  "0xc021A95E3Ad7D4e06745c4A12438A960c33859D7",
  "0xfF5Eb1345aa5d4C948C227742FCd32157539E480",
  "0x0B0381a2C4C3a537C614Afe71334c9F387718922",
  "0x9c4C30d5cD29c6D24CF1A712D93B756cBf5071bA",
  "0x8Aa82b86056af2DD5cdAAB45EEFE500c84d0af82",
  "0x4a47d64B074D730868623d89ec633d16adf53212",
  "0x739110f0233B8598957Af1321920787c13142910",
  "0xC3258AF62e46B502700c34ED7C3128F99f0fC532",
  "0xd899cd3cAFB1c9F6d585C36649592956D3dF5Ef9",
  "0xdB604bE88482cE061FBc2595E619f967dE1A7502",
  "0x96b5F62604729ED5b7219f1b3f15A8359E0a86Fb",
  "0xeEF37E218087Bca2f4c3c6C4c50f3D3B51B2Eb4d",
  "0xb4175a66e28F2C348959872B28AF0d12F891201F",
  "0xDD1904dcf7e0b6DFf60BD9729F626B076999E18f",
  "0x53F91B6aE02c8CDbC22565F7F7A158aDD6F1de6E",
  "0x0De1a88dcF7Fd12C54d9aC0807c990F26BD1C121"
];

To determine if a wallet has staked in any of the Matchain staking pools, follow the recommended approach below.

Query the smart contract method currentStake(address) on each pool using JSON-RPC:

  • RPC Endpoint: https://rpc.matchain.io/
  • Method: eth_call
  • Data: Encoded calldata for currentStake(address)
    • Function selector: 0x33e25771
    • Wallet address (without 0x prefix), padded to 32 bytes.

๐Ÿ”„ Example: โ€‹

json
{
  "jsonrpc": "2.0",
  "method": "eth_call",
  "params": [
    {
      "to": "0xPOOL_ADDRESS_HERE",
      "data": "0x33e25771{WALLET_ADDRESS_PADDED}"
    },
    "latest"
  ],
  "id": 1
}

๐Ÿ“„ Sample Successful Response โ€‹

js
โœ… Stake detected: 10.56184546790342367 MAT in pool 0xdB604bE88482cE061FBc2595E619f967dE1A7502

๐Ÿ” Full Example (Node.js + Axios) โ€‹

js
import axios from "axios";

// List of staking pool contract addresses
const stakingPoolAddresses = [
  "0xf9Ff433f14f237CE6643257ca4Cd5AEc355eaEE7",
  "0x256b02b26C67029B2881ab5d493cf8E5068D5Fcc",
  "0xa3BE9646116F834D0f9F1a035fdAd6862b5f0A2A",
  "0xfa38f584f561642Ff0d1AB67b5A175798668A047",
  "0x443D8318224C59c31987EA310033D0DC47A10d88",
  "0xc021A95E3Ad7D4e06745c4A12438A960c33859D7",
  "0xfF5Eb1345aa5d4C948C227742FCd32157539E480",
  "0x0B0381a2C4C3a537C614Afe71334c9F387718922",
  "0x9c4C30d5cD29c6D24CF1A712D93B756cBf5071bA",
  "0x8Aa82b86056af2DD5cdAAB45EEFE500c84d0af82",
  "0x4a47d64B074D730868623d89ec633d16adf53212",
  "0x739110f0233B8598957Af1321920787c13142910",
  "0xC3258AF62e46B502700c34ED7C3128F99f0fC532",
  "0xd899cd3cAFB1c9F6d585C36649592956D3dF5Ef9",
  "0xdB604bE88482cE061FBc2595E619f967dE1A7502",
  "0x96b5F62604729ED5b7219f1b3f15A8359E0a86Fb",
  "0xeEF37E218087Bca2f4c3c6C4c50f3D3B51B2Eb4d",
  "0xb4175a66e28F2C348959872B28AF0d12F891201F",
  "0xDD1904dcf7e0b6DFf60BD9729F626B076999E18f",
  "0x53F91B6aE02c8CDbC22565F7F7A158aDD6F1de6E",
  "0x0De1a88dcF7Fd12C54d9aC0807c990F26BD1C121"
];

// ABI selector for `currentStake(address)`
const methodSelector = "0x33e25771";

// Utility to pad address (no 0x) to 64 hex chars
function encodeData(walletAddress) {
  const addressNoPrefix = walletAddress.toLowerCase().replace(/^0x/, "");
  return methodSelector + addressNoPrefix.padStart(64, "0");
}

async function checkStakes(walletAddress) {
  const data = encodeData(walletAddress);

  const calls = stakingPoolAddresses.map((pool, index) => ({
    jsonrpc: "2.0",
    id: index + 1,
    method: "eth_call",
    params: [
      {
        to: pool,
        data: data
      },
      "latest"
    ]
  }));

  try {
    const res = await axios.post("https://rpc.matchain.io/", calls, {
      headers: { "Content-Type": "application/json" }
    });

    const results = res.data;

    let found = false;

    results.forEach((result, i) => {
      if (result && result.result) {
        const hexVal = result.result;
        const decimalVal = BigInt(hexVal).toString();
        const humanVal = Number(decimalVal) / 1e18;

        if (humanVal > 0) {
          found = true;
          console.log(`โœ… Stake detected: ${humanVal} MAT in pool ${stakingPoolAddresses[i]}`);
        }
      }
    });

    if (!found) {
      console.log("โŒ No stake found in any pool.");
    }
  } catch (err) {
    console.error("โŒ Error querying RPC:", err.message);
  }
}

// ๐Ÿงช Test the function
const testWallet = "0x4a52dc82d2ac98fa985b1204085e0fe2526da357"; // Replace with your test address
checkStakes(testWallet);