集成挖矿奖励申领
Last updated
Last updated
JustLend DAO 于 2023 年 2 月 20 日将存款挖矿奖励发放方式从空投升级为用户主动申领。
详细公告请查看:关于调整 JustLend DAO 奖励发放方式的公告
领取挖矿收益请参阅:如何领取挖矿收益?
用户可以在JustLend DAO UI页面默认领取奖励。 如果用户无法从 JustLend DAO UI 中领取奖励,也可以通过触发奖励分配合约手动领取奖励。 例如,用户帐户设置了多签。
目前,如果用户有多个未申领的记录,则只能在 tronscan 上逐一申领。 申领函数名为“claim”,需要 4 个参数。
单笔领取交易样本:
方法及参数:
API:https://openapi.just.network/mining/distributions?address=
注:API 访问的频率限制是 10次/秒, 请开发者优化代码逻辑,防止由于访问频率过高引起 API 不稳定。
以TR4AHdK6LKANAcP12Eqdy2t45Dt7PwbpT4为例,用户可以根据需要改成其他地址。 所有参数都可以从 JustLend DAO API 查询,下面是 API 的详细信息。
https://openapi.just.network/mining/distributions?address=TR4AHdK6LKANAcP12Eqdy2t45Dt7PwbpT4
返回值说明:
“22”:{} : 表示一条未领取的记录。如果用户没有认领之前的奖励,将会有多个记录。
以下是触发 claim
函数所需的参数:
“merkleIndex”
“Index”
“amount”
“prooft”
填写所有参数,然后单击“发送”按钮。 以下为参数详细信息。
以 TronWeb 为例详细说明如何领取。通过 TronWeb 触发 claim
或 multiClaim
函数可以轻松获得奖励。
Claim
的代码示例:第一步与 Tronscan 上领取相同,用户需要从 JustLend DAO API 获取所有参数。
https://openapi.just.network/mining/distributions?address=TR4AHdK6LKANAcP12Eqdy2t45Dt7PwbpT4
以下是代码示例:
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'
);
multiClaim
的代码示例:第一步与 Tronscan 上领取相同,用户需要从 JustLend DAO API 获取所有参数。
https://openapi.just.network/mining/distributions?address=TR4AHdK6LKANAcP12Eqdy2t45Dt7PwbpT4
如果有多个未领取的奖励,则返回值中可能有多个记录。 示例如下(不是真实数据,只是示例数据):
{
"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
可以在单笔交易中领取多个奖励,也可以在单笔交易中领取单个奖励。
代码示例:parametersV2
是虚拟数据,不要在主网上使用它。
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'
);