{"id":30864070,"url":"https://github.com/kaidiren/pcx-revote","last_synced_at":"2025-09-07T19:18:07.243Z","repository":{"id":54072762,"uuid":"211591997","full_name":"kaidiren/pcx-revote","owner":"kaidiren","description":"chainx pcx revote tool","archived":false,"fork":false,"pushed_at":"2021-05-10T16:02:25.000Z","size":179,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-16T14:10:25.362Z","etag":null,"topics":["chainx","pcx"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaidiren.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-29T02:42:11.000Z","updated_at":"2024-04-16T14:10:25.363Z","dependencies_parsed_at":"2022-08-13T06:31:04.363Z","dependency_job_id":null,"html_url":"https://github.com/kaidiren/pcx-revote","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kaidiren/pcx-revote","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaidiren%2Fpcx-revote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaidiren%2Fpcx-revote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaidiren%2Fpcx-revote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaidiren%2Fpcx-revote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaidiren","download_url":"https://codeload.github.com/kaidiren/pcx-revote/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaidiren%2Fpcx-revote/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274082826,"owners_count":25219315,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chainx","pcx"],"created_at":"2025-09-07T19:18:05.588Z","updated_at":"2025-09-07T19:18:07.235Z","avatar_url":"https://github.com/kaidiren.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PCX 自动提息复投操作脚本\n\n1. 适当编辑代码\n```js\nconst _ = require('lodash')\nconst { ApiBase, WsProvider } = require('chainx.js')\n\nconst pk = '' // 私钥\nconst address = '' // 自己的账户地址\nconst voteAddress = '' // 投票地址\n\nasync function sleep (delay) {\n  return new Promise((resolve) =\u003e {\n    setTimeout(() =\u003e {\n      resolve()\n    }, delay)\n  })\n}\n\n;(async () =\u003e {\n  try {\n    const api = new ApiBase(new WsProvider('wss://w1.chainx.org.cn/ws'))\n    await api.isReady\n\n    // 提息操作\n    const claim = api.tx.xStaking.claim(voteAddress)\n    await claim.signAndSend(pk)\n    // 等待 10秒 避免节点间的数据差异问题\n    await sleep(10000)\n\n    // 投票操作\n    const assets = await api.rpc.chainx.getAssetsByAccount(address, 0, 10)\n    const pcx = _.find(assets.data, ['name', 'PCX'])\n    const free = pcx.details.Free\n    // 保留 0.1 PCX 备用\n    const amout = free - 1e7\n    if (amout \u003e 0) {\n      const nominate = api.tx.xStaking.nominate(voteAddress, amout, '')\n      await nominate.signAndSend(pk)\n    }\n  } catch (e) {\n    console.log(e)\n  }\n  process.exit()\n})()\n\n```\n2. 把编辑好的脚本加入定时器 crontab 示例 每天早上9 点 01 分自动操作\n\n   ```bash\n   1 9 * * * cd /root/revote \u0026\u0026 /root/.nvm/versions/node/v12.10.0/bin/node app.js \u003e\u003e log\n   ```\n\n结果可在 交易记录里查看\n\n![image-20190929103603405](./images/image-20190929103603405.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaidiren%2Fpcx-revote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaidiren%2Fpcx-revote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaidiren%2Fpcx-revote/lists"}