您正在查看: surou 发布的文章

MyEtherWallet 本地部署

编译运行

git clone https://github.com/MyEtherWallet/MyEtherWallet.git
cd MyEtherWallet/
npm i
npm run start:ci

外网访问

https://github.com/MyEtherWallet/MyEtherWallet/blob/1e76e24312d21a447d35f0810c5431dbdb7432ee/vueConfig/mew.js#L10

 devServer: {
    https: true, // 是否默认https
    host: 'localhost', // 访问地址
    hotOnly: true,
    port: 8080,  //端口
    headers: defaultConfigs.headers // 删掉
  },

web3j.ethCall 测试

package com.example.demo.test;

import com.example.demo.util.Constants;
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.FunctionReturnDecoder;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.generated.Uint256;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.EthCall;
import org.web3j.protocol.http.HttpService;

import java.util.Arrays;
import java.util.List;

public class TransactionGetTest {

    public static void main(String[] args) throws Exception {
        Web3j web3j = Web3j.build(new HttpService()); // defaults to http://localhost:8545/

        /*
         * String name 函数名字
         * List<Type> inputParameters 入口参数
         * List<TypeReference<?>> outputParameters 出口参数
         */
        Function function = new Function("get",
                Arrays.<Type>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {
                }));

        // encode the function
        String encodedFunction = FunctionEncoder.encode(function);

        /*
         * String from null(optional)
         * String to 合约地址
         * String data ABI
         */
        EthCall response = web3j.ethCall(Transaction.createEthCallTransaction(null, Constants.ADDRESS, encodedFunction), DefaultBlockParameterName.LATEST).send();

        // get result
        List<Type> result = FunctionReturnDecoder.decode(response.getValue(), function.getOutputParameters());
        int data = Integer.parseInt(result.get(0).getValue().toString());
        System.out.println("data = " + data);
    }
}

https://github.com/zhangbincheng1997/Ethereum/blob/dda4509fca76157b28465b8449d8aae9a1ac9ef6/helloworld/src/main/java/com/example/demo/test/TransactionGetTest.java

由Golang实现的多币种HD钱包

https://github.com/foxnut/go-hdwallet

supported coins

  • BTC
  • LTC
  • DOGE
  • DASH
  • ETH
  • ETC
  • BCH
  • QTUM
  • USDT
  • IOST
  • USDC

install

go get -v -u github.com/foxnut/go-hdwallet

example

package main

import (
    "fmt"

    "github.com/foxnut/go-hdwallet"
)

var (
    mnemonic = "range sheriff try enroll deer over ten level bring display stamp recycle"
)

func main() {
    master, err := hdwallet.NewKey(
        hdwallet.Mnemonic(mnemonic),
    )
    if err != nil {
        panic(err)
    }

    // BTC: 1AwEPfoojHnKrhgt1vfuZAhrvPrmz7Rh4
    wallet, _ := master.GetWallet(hdwallet.CoinType(hdwallet.BTC), hdwallet.AddressIndex(1))
    address, _ := wallet.GetAddress()
    addressP2WPKH, _ := wallet.GetKey().AddressP2WPKH()
    addressP2WPKHInP2SH, _ := wallet.GetKey().AddressP2WPKHInP2SH()
    fmt.Println("BTC: ", address, addressP2WPKH, addressP2WPKHInP2SH)

    // BCH: 1CSBT18sjcCwLCpmnnyN5iqLc46Qx7CC91
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.BCH))
    address, _ = wallet.GetAddress()
    addressBCH, _ := wallet.GetKey().AddressBCH()
    fmt.Println("BCH: ", address, addressBCH)

    // LTC: LLCaMFT8AKjDTvz1Ju8JoyYXxuug4PZZmS
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.LTC))
    address, _ = wallet.GetAddress()
    fmt.Println("LTC: ", address)

    // DOGE: DHLA3rJcCjG2tQwvnmoJzD5Ej7dBTQqhHK
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.DOGE))
    address, _ = wallet.GetAddress()
    fmt.Println("DOGE:", address)

    // ETH: 0x37039021cBA199663cBCb8e86bB63576991A28C1
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.ETH))
    address, _ = wallet.GetAddress()
    fmt.Println("ETH: ", address)

    // ETC: 0x480C69E014C7f018dAbF17A98273e90f0b0680cf
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.ETC))
    address, _ = wallet.GetAddress()
    fmt.Println("ETC: ", address)
}