Git Product home page Git Product logo

d6's People

Contributors

kaidiren avatar

Watchers

 avatar  avatar

d6's Issues

2

这是一条短的状态,目前也只是一条测试 2333 (:з」∠)

10

依然是测试.

9

测试一下自动部署.

7

黎明前的夜晚最是难熬~ 💪

EOS 部署尝试

基础条件

  1. docker
  2. git

如果不知道怎么安装请,自己百度 或 者 google, 这里就不详细说明了. 为什么使用docker 是因为构建过程依赖复杂,还很耗费时间所以直接使用dockerhub上构建好的镜像.

下载项目和配置

git clone https://github.com/EOSIO/eos.git
cd eos/Docker
docker pull eosio/eos

编辑 docker-compose.yml 文件, 替换为:

version: "2"

services:
  eosiod:
    image: eosio/eos
    command: /opt/eosio/bin/start_eosiod.sh
    ports:
      - 8888:8888
      - 9876:9876
    expose:
      - "8888"
    volumes:
      - eosiod-data-volume:/opt/eosio/bin/data-dir
      - ./config.ini:/opt/eosio/bin/data-dir/config.ini

  walletd:
    image: eosio/eos
    command: /opt/eosio/bin/eosiowd
    links:
      - eosiod
    volumes:
      - walletd-data-volume:/opt/eosio/bin/data-dir

volumes:
  eosiod-data-volume:
  walletd-data-volume:

项目启动与重启

执行 docker-compose up 启动文件

如果想要修改配置文件, 直接编辑当前目录下的 config.ini, 修改完成后, 执行 docker-compose down -v, docker-compose up 即可.

命令行执行体验

可以在 ~/.bashrc 中添加如下命令

alias eosioc='docker-compose exec walletd /opt/eosio/bin/eosioc -H eosiod'

添加完记得 soucre ~/.bashrc 促使生效

这样子可以直接通过 终端执行 eosioc, 其实实际上已经访问到 docker 内部,非常方便

执行 eosioc get info
可以看到返回结果类似:

{
  "server_version": "3d4a14f1",
  "head_block_num": 4487,
  "last_irreversible_block_num": 4486,
  "head_block_id": "00001187af48142b9b9ab3120799e828c90e064c663e055020fface4440e5736",
  "head_block_time": "2018-03-12T08:42:42",
  "head_block_producer": "eosio",
  "recent_slots": "1110111111111111111111111111111111111111111111111111111111111111",
  "participation_rate": "0.98437500000000000"
}

iptables 端口转发

  1. 列出所有规则
    iptables -t nat --line-numbers -L
  2. 删除指定规则
    iptables -t nat -D OUTPUT 2
  3. 端口转发 示例从 9001 转发到 8000
    iptables -t nat -A PREROUTING -p tcp --dport 8000 -j REDIRECT --to-ports 9001
    iptables -t nat -A OUTPUT -p tcp -d localhost --dport 8000 -j REDIRECT --to-ports 9001

3

市场还是很会教做人的.😂

波场交易数据结构

TRX 转账交易

image

原始链接 https://tronscan.org/#/block/5280765/transfers
交易数据如下, trx 的进度为 6位

{
  "ret": [
    {
      "contractRet": "SUCCESS"
    }
  ],
  "signature": [
    "a2d57b74cdbbfddf2a770ff1521f6a7811d1ed23474e2a4774324bd8a3e779810bcb5685bff32aeac50d5c0ee74ab5ff53d4ae901394d88ed666c8e03865c21801"
  ],
  "txID": "d7ac8443d29c96748f2ca2dd0f04b0027ad6e40a534eddfe841a3dd6c37a7536",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "amount": 199999900000,
            "owner_address": "410d0707963952f2fba59dd06f2b425ace40b492fe",
            "to_address": "41bcaf8ed84fb2fd98dbd81a74613d607abf88745e"
          },
          "type_url": "type.googleapis.com/protocol.TransferContract"
        },
        "type": "TransferContract"
      }
    ],
    "ref_block_bytes": "9274",
    "ref_block_hash": "950e6861e80b6fbc",
    "expiration": 1545897029528,
    "fee_limit": 100000
  }
}

TRX 智能合约调用

image

原始链接 https://tronscan.org/#/transaction/f878b9b7cd351e512357de2b85be7ea9f85041cbbe7e1057b1cdf18244e4b176

{
  "ret": [
    {
      "contractRet": "SUCCESS"
    }
  ],
  "signature": [
    "a44921271007dd995e2ce5cc7ca76d9b378d9e03328e577ebd5a95b5b4db964c82d358b01ecd71412a1eebea3e3f7e773d6f9a211dec77cfae9809ef7b53e93500"
  ],
  "txID": "f878b9b7cd351e512357de2b85be7ea9f85041cbbe7e1057b1cdf18244e4b176",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "data": "a3082be900000000000000000000000000000000000000000000000000000000000000540000000000000000000000000000000000000000000000000000000000000000",
            "owner_address": "41ff587581be807d3a90d73a7fd1def7c51d6c62ed",
            "contract_address": "412ec5f63da00583085d4c2c5e8ec3c8d17bde5e28",
            "call_value": 260000000
          },
          "type_url": "type.googleapis.com/protocol.TriggerSmartContract"
        },
        "type": "TriggerSmartContract"
      }
    ],
    "ref_block_bytes": "93fb",
    "ref_block_hash": "ce06b75e2217ad39",
    "expiration": 1545895287000,
    "fee_limit": 6000000,
    "timestamp": 1545895230504
  }
}

TRX 通证转账

image

原始链接 https://tronscan.org/#/transaction/228b24129b2dbde8692e44f6943b28f3df6f6a514667ea316894cddbac6c8d4c

{
  "ret": [
    {
      "contractRet": "SUCCESS"
    }
  ],
  "signature": [
    "09c9354006b6854217241f7061eb32ae0d03537c1caa7c4fdf2b99f1b8b906bb7ae9e9be80a24db4008f90bf83955612ec31a594e394f2e835324b1a11f18c3b01"
  ],
  "txID": "228b24129b2dbde8692e44f6943b28f3df6f6a514667ea316894cddbac6c8d4c",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "amount": 4,
            "asset_name": "434244",
            "owner_address": "41ed7c12a59e5134c3e365e6e0711803ea16328e60",
            "to_address": "4116d7c90a41da1b2cc818704124bfbfa6d0de84dd"
          },
          "type_url": "type.googleapis.com/protocol.TransferAssetContract"
        },
        "type": "TransferAssetContract"
      }
    ],
    "ref_block_bytes": "9397",
    "ref_block_hash": "48ee569e4bf577bc",
    "expiration": 1545895218000,
    "timestamp": 1545894920723
  }

其他全部详情 https://github.com/tronprotocol/Documentation/blob/master/%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3/%E6%B3%A2%E5%9C%BA%E5%8D%8F%E8%AE%AE/%E4%BA%A4%E6%98%93%E6%93%8D%E4%BD%9C%E7%B1%BB%E5%9E%8B%E8%AF%B4%E6%98%8E.md

测试文章发布

这是一篇 从 github issue 发来的文章.

  • 有一个简洁的输入框
  • 可以在手机上使用 😋
  • 支持 markdown

所以先以这样的发布吧. 🎉

11

测试

磁盘挂载

硬盘挂载

硬盘挂载

mount -o rw /dev/sdb1 /disk/sata01

显示 硬盘设备生产商

lsscsi 可以用于查看是 ssd 还是 hdd
2018-10-09.15.40.37-image.png

查看挂载关系

lsblk

2018-10-09.15.40.02-image.png

查看硬盘设备

fdisk -l

2018-10-09.15.39.44-image.png

显示硬盘使用信息

df -lh

2018-10-09.15.39.04-image.png

8

以太猫, 甚至是冥币, 看起来这么没用,没意义,又边缘的东西,其实就是想象力的探索结果,或许需要从另外的层面来看待什么是"意义".而未来终究是属于想象力的. ​​​​

EOS 智能合约体验

接上文: #4

官方文档地址: https://github.com/EOSIO/eos#example-currency-contract-walkthrough

智能合约示例

首先启动 节点

docker-compose up

导入帐号

在创世区块的配置中已经存在一个 eosio 的账户, 把私钥导入.

eosioc wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

为 "currency" 合约创建帐号

先生成2个密钥对:

rkd@mac:~/blockchain/eos/Docker$ eosioc create key
Private key: 5KMohsQ5cqXGgMRPH5qXqaTpRhrThwtGT7e8sqS7KuxXRxGLFfW
Public key: EOS55iuKLbH2XhNv4pJXjNtxTJYoD5Xes2PuB4N7LYfgdeEjFPWat   // owner_key
rkd@mac:~/blockchain/eos/Docker$ eosioc create key
Private key: 5K8T42F56S6VX3bFh3sC6UcNjC1aQEY37AmK2rdnXVzsSX3YeCT
Public key: EOS6RPNryk7rxkrcxKEigmrNBS4dzGcUqdoWT4HupbrbYnVro5npM  // active_key

通过 eosio 这个帐号, 创建 currency 帐号

eosioc create account eosio currency EOS55iuKLbH2XhNv4pJXjNtxTJYoD5Xes2PuB4N7LYfgdeEjFPWat EOS55iuKLbH2XhNv4pJXjNtxTJYoD5Xes2PuB4N7LYfgdeEjFPWat

会返回一大段 json 串就说明成功了

查询一下:
eosioc get account currency

返回结果:

{
  "account_name": "currency",
  "permissions": []
}

导入钱包私钥:

eosioc wallet import 5KMohsQ5cqXGgMRPH5qXqaTpRhrThwtGT7e8sqS7KuxXRxGLFfW
eosioc wallet import 5K8T42F56S6VX3bFh3sC6UcNjC1aQEY37AmK2rdnXVzsSX3YeCT

上传 "currency" 合约

上传前可以查看下:

eosioc get code currency
code hash: 0000000000000000000000000000000000000000000000000000000000000000

上传:

eosioc set contract currency ../../contracts/currency/currency.wast ../../contracts/currency/currency.abi

返回的结果中带有 transaction_id 字段那就说明成功了

你可以再查询验证下:

eosioc get code currency

返回结果看起来像这样子:

code hash: 9b9db1a7940503a88535517049e64467a6e8f4e9e03af15e9968ec89dd794975

使用这个合约前,要现先生成代币.

eosioc push action currency issue '{"to":"currency","quantity":"1000.0000 CUR"}' --permission currency@active

验证下看看余额对不对:

eosioc get table currency currency account
{
  "rows": [{
     "currency": 1381319428,
     "balance": 10000000
     }
  ],
  "more": false
}

通过合约交易

eosioc push action currency transfer '{"from":"currency","to":"eosio","quantity":"20.0000 CUR","memo":"my first transfer"}' --permission currency@active

返回的结果中带有 transaction_id 字段那就说明成功了

通过合约查询余额

eosioc get table eosio currency account
{
  "rows": [{
      "currency": 1381319428,
      "balance": 200000
       }
    ],
  "more": false
}
eosioc get table currency currency account
{
  "rows": [{
      "currency": 1381319428,
      "balance": 9800000
    }
  ],
  "more": false
}

显然余额已经发生变化了.

6

偶尔写写东西感觉也不错~

让终端 sudo 时用上 Touch ID

用了一段时间 MacBook Pro with TouchBar 感觉开机或唤醒时读指纹还是很方便的,但安装一些软件或执行命令操作时还是需要输入密码,似乎不那么省事,对设置复杂密码也不够友好。今天学到了一个新技巧,让我们在终端里sudo执行命令时不再需要手输密码,而是Touch ID验证。

修改/etc/pam.d/sudo这个文件,建议用
sudo vim /etc/pam.d/sudo

在第一行增加
auth sufficient pam_tid.so

现在尝试下 sudo 操作吧,应该会看到提示识别指纹而不是输入密码了。

image

如果你使用了 tmux 需要 添加额外的配置

https://github.com/fabianishere/pam_reattach

git clone https://github.com/fabianishere/pam_reattach
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local <PATH-TO-SOURCE>
make
sudo make install

修改/etc/pam.d/sudo这个文件,建议用
sudo vim /etc/pam.d/sudo

在第一行增加
auth optional pam_reattach.so

然后就可以顺利使用了

从 etherscan 获取 可用的 peer

https://etherscan.io/nodetracker/nodes

var enodeTable = document.getElementsByClassName("table")[0]
var enodeList = []
var info = []
var commandList = []


for (i = 1; i < enodeTable.rows.length; i++) {
    var enodeUrl = "";
    var command= "";
    // GET THE CELLS COLLECTION OF THE CURRENT ROW.
    var objCells = enodeTable.rows.item(i).cells;
    var btn = objCells[8]
    copySpan = btn.getElementsByClassName("d-none")
    enodeUrl = copySpan[0].innerText
    enodeList.push(enodeUrl);
    command = 'admin.addPeer("' + enodeUrl + '");';
    commandList.push(command);
}
var arrLength = commandList.length
for(i=0; i< arrLength; i++)
{
    console.log(commandList[i]);
}

EOS eosio.system 和 eosio.token 合约部署

  1. eos 版本 dawn-v4.0.0
  2. 前置条件 bios 已经设置好了,相关的 bp 也已经设置完毕
#  创建 token 对应的账号
./programs/cleos/cleos --wallet-url http://localhost:8899 --url http://127.0.0.1:8788 create account eosio eosio.token EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
# 部署 system 合约
./programs/cleos/cleos --wallet-url http://localhost:8899 --url http://127.0.0.1:8788 set contract eosio.token contracts/eosio.system -p eosio.token@active
# 部署token 合约
./programs/cleos/cleos --wallet-url http://localhost:8899 --url http://127.0.0.1:8788 set contract eosio.token contracts/eosio.token -p eosio.token@active
# 创建 eos token
./programs/cleos/cleos --wallet-url http://localhost:8899 --url http://127.0.0.1:8788 push action eosio.token create '{"issuer":"eosio.token", "maximum_supply":"1000000000.0000 EOS","can_freeze":0, "can_recall":0, "can_whitelist":0}' -p eosio.token@active
# 发放 eos token
./programs/cleos/cleos --wallet-url http://localhost:8899 --url http://127.0.0.1:8788 push action eosio.token issue '{"to":"eosio.token","quantity":"1000000000.0000 EOS","memo":"init"}' -p eosio.token@active

# 查询余额
./programs/cleos/cleos --wallet-url http://localhost:8899 --url http://127.0.0.1:8788 get currency balance eosio.token eosio.token EOS
# 转账
./programs/cleos/cleos --wallet-url http://localhost:8899 --url http://127.0.0.1:8788 push action eosio.token transfer '[ "eosio.token", "inita", "1.0000 EOS", "m" ]' -p eosio.token
# 查询余额
./programs/cleos/cleos --wallet-url http://localhost:8899 --url http://127.0.0.1:8788 get currency balance eosio.token inita EOS
# 查询余额
./programs/cleos/cleos --wallet-url http://localhost:8899 --url http://127.0.0.1:8788 get currency balance eosio.token eosio.token EOS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.