Closed Milerius closed 1 year ago
QTUM Offline staking documentation: https://docs.qtum.site/en/OfflineStaking.html
Qtum Offline Staking allows the address for a non-staking wallet (capable of making the delegation assignment transaction) to be delegated to a Super Staker. Offline Staking is non-custodial: the delegation user keeps full control of their coins and private keys. The address delegation is made via a smart contract transaction from the delegation user's wallet which identifies the delegator's address, the Super Staker address, and the fee the delegator agrees to pay. If the Super Staker accepts this fee, it will begin staking the delegated address UTXOs.
The normal rules for staking UTXOs apply to delegated UTXOs:
UTXOs may only be used for staking after they mature (500 confirmations)
The Super Staker will set a minimum size of UTXOs to stake, defaulting to 100 QTUM. Delegated UTXOs below this amount will be ignored.
It is best practice (for optimum returns) to break UTXOs up into sizes of 100 to 200 QTUM each. For users of the Qtum Core wallet, this can be easily accomplished with the command line version of splitutxosforaddress, described below.
To make the delegation assignment from the Qtum Core wallet, select Stake – Delegations, the Add delegation "+" button in the upper right corner, enter the Staker name (for local reference only), Staker address, Fee you agree to pay, and your Address to be delegated. Leave the default Gas settings alone unless you understand how to set these. The delegation transaction will require at least 0.9 QTUM in fees and any excess will be refunded.
https://github.com/qtumproject/qips/issues/25
New specs details: https://github.com/JB395/documents2/blob/master/README.md#offline-staking-address-delegation---undelegation-transaction-details
@Milerius Please do research on QTUM staking and propose staking API specification in this issue.
according to the doc:
offline_staking_contract_address = bytes.fromhex("0000000000000000000000000000000000000086")
pod = signmessage(delegator_eckey, staker_address_hex)
calldata = bytes.fromhex("4c0e968c") # function abi
calldata += b'\x00'*12 + bytes.fromhex(staker_address_hex)
calldata += b'\x00'*31 + b'\x63'
calldata += b'\x00'*31 + b'\x60'
calldata += b'\x00'*31 + b'\x41'
calldata += pod
contract_call_script = CScript([b'\x04', CScriptNum(2250000), CScriptNum(40), calldata, offline_staking_contract_address, OP_CALL])
I see in the code we have:
pub fn generate_contract_call_script_pubkey(
function_call: &[u8],
gas_limit: u64,
gas_price: u64,
contract_address: &[u8],
) -> Qrc20AbiResult<Script> {
if gas_limit == 0 || gas_price == 0 {
// this is because the `encode_contract_number` will return an empty bytes
return MmError::err(Qrc20AbiError::InvalidParams(
"gas_limit and gas_price cannot be zero".to_owned(),
));
}
if contract_address.is_empty() {
// this is because the `push_bytes` will panic
return MmError::err(Qrc20AbiError::InvalidParams("token_addr cannot be empty".to_owned()));
}
let gas_limit = encode_contract_number(gas_limit as i64);
let gas_price = encode_contract_number(gas_price as i64);
Ok(ScriptBuilder::default()
.push_opcode(Opcode::OP_4)
.push_bytes(&gas_limit)
.push_bytes(&gas_price)
.push_data(function_call)
.push_bytes(contract_address)
.push_opcode(Opcode::OP_CALL)
.into_script())
}
That look's very similar, what do you think @artemii235 ? can i use this function to generate the delegate tx?
req:
{
"userpass": "simplepassword123",
"mmrpc": "2.0",
"method": "add_delegation",
"params": {
"coin": "tQTUM",
"staking_details": {
"type": "Qtum",
"address": "qcyBHeSct7Wr4mAw18iuQ1zW5mMFYmtmBE",
"fee": 10
}
},
"id": 0
}
resp:
{
"mmrpc": "2.0",
"result": {
"tx_hex": "tx_hex...",
"tx_hash": "tx_hash...",
"from": [
"qWY5jHd6jM4vRYikMQh6kvCPgWTFZVZwL6"
],
"to": [
"qWY5jHd6jM4vRYikMQh6kvCPgWTFZVZwL6"
],
"total_amount": "189.95811134",
"spent_by_me": "189.95811134",
"received_by_me": "189.95811134",
"my_balance_change": "0.00000000",
"block_height": 0,
"timestamp": 1633851284,
"fee_details": {
"type": "Qrc20",
"coin": "tQTUM",
"miner_fee": "0.004",
"gas_limit": 2250000,
"gas_price": 40,
"total_gas_fee": "0.9"
},
"coin": "tQTUM",
"internal_id": "",
"transaction_type": "StakingDelegation"
},
"id": 0
}
get_staking_infos rpc
req:
{
"userpass": "simplepassword123",
"mmrpc": "2.0",
"method": "get_staking_infos",
"params": {
"coin": "tQTUM"
},
"id": 0
}
{
"mmrpc": "2.0",
"result": {
"staking_infos_details": {
"type": "Qtum",
"amount": "111.591066",
"staker": "qcyBHeSct7Wr4mAw18iuQ1zW5mMFYmtmBE",
"am_i_staking": true
}
},
"id": 0
}
@Milerius Are the examples above actual? Please update them if no, add missing RPCs requests samples, and assign @smk762 to this issue for testing and documentation.
@Milerius Do we consider this feature as complete for now? When the documentation is in progress, please assign it to @smk762 and move it to the "Documenting" column. You can do it in the Projects section as outlined in the screenshot below
I think we already have the documentation in dev for offline staking!
https://developers.komodoplatform.com/basic-docs/atomicdex-api-20-dev/add_delegation.html https://developers.komodoplatform.com/basic-docs/atomicdex-api-20-dev/remove_delegation.html
I still need to add get_staking_infos
, will do tonight.
I still need to add
get_staking_infos
, will do tonight.
Yeah was about to say https://github.com/KomodoPlatform/atomicDEX-API/blob/d78b56dfb85f548f1da1a1db148170872a23b81b/mm2src/rpc/dispatcher/dispatcher_v2.rs#L107 is not documented
Doc was created, but not added to sidebar. Should be resolved in https://github.com/KomodoPlatform/developer-docs/pull/328 https://developers.komodoplatform.com/basic-docs/atomicdex-api-20-dev/get_staking_infos.html
Great! It looks like we can close this :slightly_smiling_face: Have we created issues to implement this functionality in GUIs?
cc @tonymorony @Milerius @yurii-khi in regards to the above comment.
Closing, as the functionality exists in API. @yurii-khi @ca333 keep this (offline QTUM staking) on your radar for GUI roadmaps.
Is your feature request related to a problem? Please describe.
My feature is not related to a problem but rather to get more users to use AtomicDEX.
As explained here it would be great to have equivalent features in AtomicDEX core to be able to offline staking on Mobile, Computer and Web
Describe the solution you'd like
The possibility via an rpc call to have the list of validators for offline staking and the possibility of activating staking after choosing a validator for the blockchains that require it. The ideal would be to be able to staker Cosmos, Tezos, Qtum or Band for example.
Describe alternatives you've considered
I have considered implementing it in the desktop version directly but it would be a shame not to share it with all the products, knowing that AWC staking also works on mobile