Manual Claim Mining Reward

Background

JustLend DAO upgraded the mining reward distribution from AirDrop to User self-claim on Feb 20th, 2023.

Please check the detailed announcement at:

Announcement on Adjusting the Reward Distribution Method of JustLend DAO

And please refer to the claim guide on How to claim my mining rewards?

Manually claim the reward from the distribution contract

The user can default claim the reward from the JustLend DAO UI page. However, users can also manually claim the reward by triggering the reward distribution contract if the have difficulty in claiming from the JustLend DAO UI. For example, user account has multi-sign set up.

Claim from contract on Tronscan.org

Currently user can only claim one by one on Tronscan if they have more than one un-claimed records. The function is `claim` and requires 4 parameters.

Single Claim Transaction sample:

https://api.trongrid.io/wallet/gettransactionbyid?value=d3c7bd6e9776a60b0950bb087e7c1b87e332a76c1590a69e12c2569c7efa6e5c&visible=true

Method and parameters:

How to get the parameters:

API: here let us use TR4AHdK6LKANAcP12Eqdy2t45Dt7PwbpT4 for example, you can change it to any other address according to your need. All the parameters can be queried from JustLend DAO API, below are the API detail.

Note: The limit of API access frequency is 10 times/second. Please optimize your code logic to prevent API instability caused by high access frequency.

https://openapi.just.network/mining/distributions?address=TR4AHdK6LKANAcP12Eqdy2t45Dt7PwbpT4

Description of the return value:

  • “22”:{} : represents an un-claimed record, there will be more than one record if the user did not claim the previous reward.

Below is the value needed for trigger the `claim` function:

  • “merkleIndex”

  • “Index”

  • “amount”

  • “prooft”

Send the transaction on Tronscan.rog

Fill in all the parameters and click the “Send” button. See the detail from the below screenshot.

Claim with SW program

Here we use Tronweb as an example to go through the claim.

With TronWeb, it is super easy to trigger the `claim` or `multiClaim` function to get the rewards.

Code sample for `Claim`:

The first step is the same as claim on tronscan, user need to get all the parameters from the JustLend DAO API.

https://openapi.just.network/mining/distributions?address=TR4AHdK6LKANAcP12Eqdy2t45Dt7PwbpT4

Below are the code samples:

const funcAbi = [
      {
        'inputs': [
          {
            'components': [
              {
                'internalType': 'uint256',
                'name': 'merkleIndex',
                'type': 'uint256'
              },
              {
                'internalType': 'uint256',
                'name': 'index',
                'type': 'uint256'
              },
              {
                'internalType': 'uint256',
                'name': 'amount',
                'type': 'uint256'
              },
              {
                'internalType': 'bytes32[]',
                'name': 'merkleProof',
                'type': 'bytes32[]'
              }
            ],
            'internalType': 'struct MerkleDistributor.Basic[]',
            'name': 'basic',
            'type': 'tuple[]'
          }
        ],
        'name': 'multiClaim',
        'outputs': [],
        'stateMutability': 'nonpayable',
        'type': 'function'
      }
    ];

const parametersV2 = [
    [
        [
            "0x07",
            "0x1edd",
            "0xf5a07bac417c1",
            [
                "0xe747f73c964cae0e90d84b715247e967aa813dc182b29aa96f4a62a5b01881f1",
                "0xade0f346370e361e34a5efeba7ac3e84a15c12350c296edae180999db7f287c1",
                "0x5fc30f3dc7656845b3133e8c75ba3f753717ba2c5ad53cac3c52720a885b738a",
                "0xebf28cc1674de2823ee018daa41122832f40aede383f47e37640668e4801ed3c",
                "0x2fbdcfdcc43b3c0452c48c4150d0d6eb6f5e30e99858f2641cacf793fdf3c57d",
                "0xe7950e05764f3c31c519994a1caa1f748104dd7661ca753e2f6f937ff5babe1d",
                "0x13e7afa426c68c8d284fba97358329128e55336e65ca4b93f9606a76694ad9b4",
                "0x905d6de418a5b5bb298774e4ad6d01c6e8895a4f5f73d13d98f5ba7fe140e1a9",
                "0x22340ab3ac7c69e7d67e267e05e4f10682e46b5a43b2c7195489ae0b8badeed2",
                "0xeaf5056bb155b55f7e8f3b9759815bdce9036299f3d8235bf6f53796648ee3fb",
                "0x63f1602ac026332195faa00bf3bcffbcf5fdc49455d5caba553d6551776c24c9",
                "0x2d6488b5949b6099d3942fb01c064aaf7ddc21a5ef91889fb6f74063b30540e1",
                "0x9853f10432a3e64e5013ce0a1197a2558069f431d4ad3be5ffeaa7425dbf183f",
                "0x02824cfa0446139829b1f83c2ce682a136c6c1609b077f0020e5157bb4621a14",
                "0x64bb7f663f1338d807393b26a8dbca8be74974640d7bab2bdfcaa4fe6e13b7b3"
            ]
        ]
    ]
];
const rawParameter = tronWeb.utils.abi.encodeParamsV2ByABI(funcAbi[0], parametersV2);
const options = { shieldedParameter: rawParameter, feeLimit:200000000};
const functionSelector = 'claim((uint256,uint256,uint256,bytes32[]))';
const transaction = await tronWeb.transactionBuilder.triggerSmartContract(
      'TQoiXqruw4SqYPwHAd6QiNZ3ES4rLsejAj',
      functionSelector,
      options,
      [],
      'TH4Vi2SXuiYCpnWykZgmphEKfajVNbFYA7'
    );

Code sample for `multiClaim`:

The first step is the same as claim on tronscan, user need to get all the parameters from the JustLend DAO API.

https://openapi.just.network/mining/distributions?address=TR4AHdK6LKANAcP12Eqdy2t45Dt7PwbpT4

There could be more than one records in the return value if there are more than one un-claimed rewards. Below are the examples(it is not real data, just an example data):

{    
    "22": {
        "amount": "0xf748f6f4d54861",
        "claimed": true,
        "index": "0x1801",
        "merkleIndex": "0x00",
        "proof": [
            "0x655c3609bae4d1db3d905b25d3bdd8ec79b83f5288b5756921d02fa7127714de",
            "0xa9a6df5b336a2e52018a079eaec6c477952d56ecfdfdb0745160037c865a83d8",
            "0xdd91a2295b96128ea32196f6a2228970dc22342f957be76c4297b517236a4daf",
            "0xa29184873648fbf6d5fe67db3fc8036c145f4b5e7861c1c35bfa2606826a5d7d",
            "0xdcd82bc3bea2e7a7a1d1a6502ab93c293f92f7e9928f0826d731da9d2a537b41",
            "0xfda762589af4cd6812450f1f8b5b199094a81bde881d4f5f645b4dc32f74547c",
            "0x3fb4c0c830f88413b6b9fd5f6f2a237ea36f1399f292e1303387f0499bda712d",
            "0x2d16294f4390501b16eb8f94f5e8396b76d5307e9a38b099b6cbc5c083aa0534",
            "0x2eabb0d475248f1f7ab63542a2c21f056f80d230cd6fb3c76afd3c32984115be",
            "0x6cf17401cda4a192dc9e05bb5f67ac0e4d20834a93a6db85ddcd9a971720f2d8",
            "0x8a137a9c92302ec8b9194fb313fa8074d308092ba3238e43d57b1972fbda9a33",
            "0xd93c82752e5202d4006fb01a4af3b1381d6f6ae8871f392f993f474b2dc71d20",
            "0xfacc476d236171a5fb8177283188d125756254e18865ce4fbd3367c1dec989e4",
            "0xeed1fc29326b1156d0b44d431e4e3a5b21a78e70d156db235662da428421d2a8",
            "0xb3c366576c84eb2e9a6abb9f9676ef6483a2a4945e4b32482e6ab8c2d8630971"
        ],
        "merkleRoot": "0x560729bcf5ab7fc1916f6d67b22d59b2d007577174e1d6c6b77bd078598ef788"
    },
    "23": {
        "amount": "0xf748f6f4d54861",
        "claimed": false,
        "index": "0x1801",
        "merkleIndex": "0x01",
        "proof": [
            "0x655c3609bae4d1db3d905b25d3bdd8ec79b83f5288b5756921d02fa7127714de",
            "0xa9a6df5b336a2e52018a079eaec6c477952d56ecfdfdb0745160037c865a83d8",
            "0xdd91a2295b96128ea32196f6a2228970dc22342f957be76c4297b517236a4daf",
            "0xa29184873648fbf6d5fe67db3fc8036c145f4b5e7861c1c35bfa2606826a5d7d",
            "0xdcd82bc3bea2e7a7a1d1a6502ab93c293f92f7e9928f0826d731da9d2a537b41",
            "0xfda762589af4cd6812450f1f8b5b199094a81bde881d4f5f645b4dc32f74547c",
            "0x3fb4c0c830f88413b6b9fd5f6f2a237ea36f1399f292e1303387f0499bda712d",
            "0x2d16294f4390501b16eb8f94f5e8396b76d5307e9a38b099b6cbc5c083aa0534",
            "0x2eabb0d475248f1f7ab63542a2c21f056f80d230cd6fb3c76afd3c32984115be",
            "0x6cf17401cda4a192dc9e05bb5f67ac0e4d20834a93a6db85ddcd9a971720f2d8",
            "0x8a137a9c92302ec8b9194fb313fa8074d308092ba3238e43d57b1972fbda9a33",
            "0xd93c82752e5202d4006fb01a4af3b1381d6f6ae8871f392f993f474b2dc71d20",
            "0xfacc476d236171a5fb8177283188d125756254e18865ce4fbd3367c1dec989e4",
            "0xeed1fc29326b1156d0b44d431e4e3a5b21a78e70d156db235662da428421d2a8",
            "0xb3c366576c84eb2e9a6abb9f9676ef6483a2a4945e4b32482e6ab8c2d8630971"
        ],
        "merkleRoot": "0x560729bcf5ab7fc1916f6d67b22d59b2d007577174e1d6c6b77bd078598ef788"
    },
    "24": {
        "amount": "0xf748f6f4d54861",
        "claimed": false,
        "index": "0x1801",
        "merkleIndex": "0x02",
        "proof": [
            "0x655c3609bae4d1db3d905b25d3bdd8ec79b83f5288b5756921d02fa7127714de",
            "0xa9a6df5b336a2e52018a079eaec6c477952d56ecfdfdb0745160037c865a83d8",
            "0xdd91a2295b96128ea32196f6a2228970dc22342f957be76c4297b517236a4daf",
            "0xa29184873648fbf6d5fe67db3fc8036c145f4b5e7861c1c35bfa2606826a5d7d",
            "0xdcd82bc3bea2e7a7a1d1a6502ab93c293f92f7e9928f0826d731da9d2a537b41",
            "0xfda762589af4cd6812450f1f8b5b199094a81bde881d4f5f645b4dc32f74547c",
            "0x3fb4c0c830f88413b6b9fd5f6f2a237ea36f1399f292e1303387f0499bda712d",
            "0x2d16294f4390501b16eb8f94f5e8396b76d5307e9a38b099b6cbc5c083aa0534",
            "0x2eabb0d475248f1f7ab63542a2c21f056f80d230cd6fb3c76afd3c32984115be",
            "0x6cf17401cda4a192dc9e05bb5f67ac0e4d20834a93a6db85ddcd9a971720f2d8",
            "0x8a137a9c92302ec8b9194fb313fa8074d308092ba3238e43d57b1972fbda9a33",
            "0xd93c82752e5202d4006fb01a4af3b1381d6f6ae8871f392f993f474b2dc71d20",
            "0xfacc476d236171a5fb8177283188d125756254e18865ce4fbd3367c1dec989e4",
            "0xeed1fc29326b1156d0b44d431e4e3a5b21a78e70d156db235662da428421d2a8",
            "0xb3c366576c84eb2e9a6abb9f9676ef6483a2a4945e4b32482e6ab8c2d8630971"
        ],
        "merkleRoot": "0x560729bcf5ab7fc1916f6d67b22d59b2d007577174e1d6c6b77bd078598ef788"
    }
}

`multiClaim` can claim more than one rewards within a single transaction. User can also choose to use `multiClaim` for single claim.

Code samples: the `parametersV2` here is dummy data. Do not use it on Mainnet.

const funcAbi = [
      {
        'inputs': [
          {
            'components': [
              {
                'internalType': 'uint256',
                'name': 'merkleIndex',
                'type': 'uint256'
              },
              {
                'internalType': 'uint256',
                'name': 'index',
                'type': 'uint256'
              },
              {
                'internalType': 'uint256',
                'name': 'amount',
                'type': 'uint256'
              },
              {
                'internalType': 'bytes32[]',
                'name': 'merkleProof',
                'type': 'bytes32[]'
              }
            ],
            'internalType': 'struct MerkleDistributor.Basic[]',
            'name': 'basic',
            'type': 'tuple[]'
          }
        ],
        'name': 'multiClaim',
        'outputs': [],
        'stateMutability': 'nonpayable',
        'type': 'function'
      }
    ];

const parametersV2 = [
    [
        [
            "0x07",
            "0x1edd",
            "0xf5a07bac417c1",
            [
                "0xe747f73c964cae0e90d84b715247e967aa813dc182b29aa96f4a62a5b01881f1",
                "0xade0f346370e361e34a5efeba7ac3e84a15c12350c296edae180999db7f287c1",
                "0x5fc30f3dc7656845b3133e8c75ba3f753717ba2c5ad53cac3c52720a885b738a",
                "0xebf28cc1674de2823ee018daa41122832f40aede383f47e37640668e4801ed3c",
                "0x2fbdcfdcc43b3c0452c48c4150d0d6eb6f5e30e99858f2641cacf793fdf3c57d",
                "0xe7950e05764f3c31c519994a1caa1f748104dd7661ca753e2f6f937ff5babe1d",
                "0x13e7afa426c68c8d284fba97358329128e55336e65ca4b93f9606a76694ad9b4",
                "0x905d6de418a5b5bb298774e4ad6d01c6e8895a4f5f73d13d98f5ba7fe140e1a9",
                "0x22340ab3ac7c69e7d67e267e05e4f10682e46b5a43b2c7195489ae0b8badeed2",
                "0xeaf5056bb155b55f7e8f3b9759815bdce9036299f3d8235bf6f53796648ee3fb",
                "0x63f1602ac026332195faa00bf3bcffbcf5fdc49455d5caba553d6551776c24c9",
                "0x2d6488b5949b6099d3942fb01c064aaf7ddc21a5ef91889fb6f74063b30540e1",
                "0x9853f10432a3e64e5013ce0a1197a2558069f431d4ad3be5ffeaa7425dbf183f",
                "0x02824cfa0446139829b1f83c2ce682a136c6c1609b077f0020e5157bb4621a14",
                "0x64bb7f663f1338d807393b26a8dbca8be74974640d7bab2bdfcaa4fe6e13b7b3"
            ]
        ],
        [
            "0x08",
            "0x1ede",
            "0xf5a07bac417c2",
            [
                "0xe747f73c964cae0e90d84b715247e967aa813dc182b29aa96f4a62a5b01881f1",
                "0xade0f346370e361e34a5efeba7ac3e84a15c12350c296edae180999db7f287c1",
                "0x5fc30f3dc7656845b3133e8c75ba3f753717ba2c5ad53cac3c52720a885b738a",
                "0xebf28cc1674de2823ee018daa41122832f40aede383f47e37640668e4801ed3c",
                "0x2fbdcfdcc43b3c0452c48c4150d0d6eb6f5e30e99858f2641cacf793fdf3c57d",
                "0xe7950e05764f3c31c519994a1caa1f748104dd7661ca753e2f6f937ff5babe1d",
                "0x13e7afa426c68c8d284fba97358329128e55336e65ca4b93f9606a76694ad9b4",
                "0x905d6de418a5b5bb298774e4ad6d01c6e8895a4f5f73d13d98f5ba7fe140e1a9",
                "0x22340ab3ac7c69e7d67e267e05e4f10682e46b5a43b2c7195489ae0b8badeed2",
                "0xeaf5056bb155b55f7e8f3b9759815bdce9036299f3d8235bf6f53796648ee3fb",
                "0x63f1602ac026332195faa00bf3bcffbcf5fdc49455d5caba553d6551776c24c9",
                "0x2d6488b5949b6099d3942fb01c064aaf7ddc21a5ef91889fb6f74063b30540e1",
                "0x9853f10432a3e64e5013ce0a1197a2558069f431d4ad3be5ffeaa7425dbf183f",
                "0x02824cfa0446139829b1f83c2ce682a136c6c1609b077f0020e5157bb4621a14",
                "0x64bb7f663f1338d807393b26a8dbca8be74974640d7bab2bdfcaa4fe6e13b7b3"
            ]
        ]
    ]
];
const rawParameter = tronWeb.utils.abi.encodeParamsV2ByABI(funcAbi[0], parametersV2);
const options = { shieldedParameter: rawParameter, feeLimit:200000000};
const functionSelector = 'multiClaim((uint256,uint256,uint256,bytes32[])[])';
const transaction = await tronWeb.transactionBuilder.triggerSmartContract(
      'TUQb328PQfbredVY3qUD9NZ6DipFxSRZ84',
      functionSelector,
      options,
    [],
      'TH4Vi2SXuiYCpnWykZgmphEKfajVNbFYA7'
    );

Last updated