Skip to content

Instantly share code, notes, and snippets.

@ninjaahhh
ninjaahhh / token.py
Last active August 24, 2020 05:38
Convert between token IDs and names
import re
TOKEN_BASE = 36
TOKEN_ID_MAX = 4873763662273663091 # ZZZZZZZZZZZZ
TOKEN_MAX = "ZZZZZZZZZZZZ"
def token_char_encode(char: str) -> int:
if ord(char) >= ord("A") and ord(char) <= ord("Z"):
return 10 + ord(char) - ord("A")
pragma solidity ^0.5.1;
contract StakingPool {
struct StakerInfo {
uint128 stakes;
uint128 arrPos;
}
mapping (address => StakerInfo) public stakerInfo;

Now you can use QuarkChain explorer's PoSW page to mine root chain with lower difficulty if you stake enough QKC. Following is a quick start.

To begin with, root chain miners need to meet two requirements to be able to mine with PoSW in effect:

  1. having enough stakes (1,000,000 QKC for 1 block allocation, with maximum allocation size 512);
  2. signing the submitted root block work with the correct signer specified by the root chain staking system contract (by default, it's the miner him/herself).

With this in mind, go to the explorer's PoSW page, you should find your staking information showing locking status, staking amount and corresponding mineable block allocation, signer and withdrawable time (if unlocked) right in the middle of the page. Their meanings are straightforward, with following notes:

  1. Locking status: stakes are effective only during LOCKED status (which is the default status). It will become UNLOCKED if you send an unlocking transaction.
@ninjaahhh
ninjaahhh / getLockedStakes.json
Created September 24, 2019 23:06
Get locked stakes for root chain PoSW
[
{
"constant": true,
"inputs": [
{
"internalType": "address",
"name": "staker",
"type": "address"
}
],
# exposed load balancer
apiVersion: v1
kind: Service
metadata:
name: qkc-cluster-exposed
spec:
type: LoadBalancer
externalTrafficPolicy: Local
selector:
statefulset.kubernetes.io/pod-name: qkc-cluster-0
contract SimpleGame {
function addFund() public payable {
// Thank you.
}
receive() public payable {
if (msg.value == 0) {
return;
}