Skip to content

Instantly share code, notes, and snippets.

View luchenqun's full-sized avatar

Luke luchenqun

View GitHub Profile
import { readFile } from "fs/promises"
import { fromHex } from "@cosmjs/encoding"
import { DirectSecp256k1Wallet, DirectSecp256k1HdWallet, OfflineDirectSigner } from "@cosmjs/proto-signing"
import { SigningStargateClient, StargateClient } from "@cosmjs/stargate"
const tx_3 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
const rpc = "ws://127.0.0.1:26657"
console.log(process.argv)
const getAliceSignerFromPriKey = async () => {
{
"block_id":{
"hash":"E2FB32B1030C83135E59BEDCEBAEA2A4F7940FF334442CB5637B66DCAC468C82",
"parts":{
"total":1,
"hash":"8B55CC975325A501CB1A813C2D0F0D5FAE14C1C860679F4103269DCB23018577"
}
},
"block":{
"header":{
@luchenqun
luchenqun / ppos.js
Created April 2, 2022 12:11
nelo ppos
var RLP = require('rlp');
var EU = require('ethereumjs-util');
var BN = require('bn.js');
var Common = require('ethereumjs-common');
var EthereumTx = require('ethereumjs-tx');
var axios = require('axios');
var utils = require('web3-utils');
const paramsOrder = {
'1000': ['typ', 'benefitAddress', 'nodeId', 'externalId', 'nodeName', 'website', 'details', 'amount', 'rewardPer', 'programVersion', 'programVersionSign', 'blsPubKey', 'blsProof'],
'1001': ['benefitAddress', 'nodeId', 'rewardPer', 'externalId', 'nodeName', 'website', 'details'],
{
"name": "Test Tokens List",
"version": {
"major": 1,
"minor": 0,
"patch": 0
},
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0/logo.png",
"timestamp": "2021-07-25 00:00:00.000+00:00",
"tokens": [
<template>
<div id="app">
<!-- element -->
<div>
<van-image :width="rWidth" :height="rHeight" :src="require('./assets/h.png')" />
<van-image width="32" height="32" :src="require('./assets/flashlight.png')" v-bind:style="{ transform: 'rotate('+ rotate +'deg)', position: 'absolute', left: left + 'px', top: top + 'px' }" style="transform:rotate(300deg);position: absolute; left: 100px; top: 180px;" />
</div>
<van-divider :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 10px' }" />
<van-field v-model="vleft" type="digit" label="左位置" />
<van-field v-model="vtop" type="digit" label="顶位置" />
@luchenqun
luchenqun / loan.js
Created February 23, 2021 02:45
贷款计算
// 参数设置,按照你的实际参数修改
const year = 30; // 贷款多少年年
const loan = 700000; // 总共借贷金额
const perMonthLoan = 3510; // 每月还贷金额
const yearRate = 0.038; // 假设我存到银行年利率
const perMonthDeposit = 6; // 每几(6)个月存一次
// 如果把贷款得钱存银行
let count = 12 * year / perMonthDeposit; // 能存多少次
let sdk = require('./dist/index.js');
let { Percent, Token, Fetcher, TokenAmount, Pair, Trade, TradeType, Route } = sdk;
let providers = require('@ethersproject/providers');
(async () => {
const provider = new providers.JsonRpcProvider("http://111.231.72.59:41230");
const WETH = new Token(1337, '0x80ffbcf7f998208803db528b648def6281dc248f', 18, "WETH", "Wrapped Ether");
@luchenqun
luchenqun / Stop.md
Last active September 16, 2020 06:31
hello

我是用版本为1.9.21-stable-0287d548的 geth 程序在我的Ubuntu机器上面使用命令 nohup geth --datadir /home/ubuntu/eth-data --networkid 88 --nodiscover --rpccorsdomain "*" --port 41229 --rpc --rpcaddr "0.0.0.0" --rpcport 41230 --rpcapi "db,eth,net,web3,personal,admin" --ws --wsaddr "0.0.0.0" --wsport 41231 --wsorigins "*" --wsapi "db,eth,net,web3,personal,admin" --debug --dev & 搭建了一条私链。以下交易均在上面搭建的私链上进行。

  • 部署合约 WETH9,得到合约地址 0x848Be6C1C6Cd6fea30eE0c67818Ef7eaDec755ab。调用改合约的 deposit 函数,给部署者充值 1000000 的 WETH 代币。
  • 部署合约 UniswapV2Factory。得到地址 0x1d1c0De0e3709C8fC15C76E87320b685E1Df9c1a
  • 部署合约 UniswapV2Router02。得到地址 0x83f7cE12B4366F7E81632bA6D3EEd9d5F4Fc2198。
  • 部署六种ERC20代币。然后调用合约 UniswapV2Factory 的函数 createPair。createPair第一个入参为 WETH9 代币地址,第二个入参为我部署的六种ERC20代币地址。得到的信息如下

| symbol | name |token 地址 | 调用createPair返回的配对地址| | ---- | ---- |---- |---- |---- | |CNY|人民币|0xA8d1A0Dd14cefdD1Dc62412A533e8f3612A85090 |0x629C20C409cadf2839c60A3e9337b0c634b54600 |

import Web3 from 'web3';
import axios from 'axios';
import QRCode from 'qrcode';
import config from '@/config';
import api from '@/api';
const Tx = require('ethereumjs-tx');
const Util = require('ethereumjs-util');