区块链项目_USDT泰达币

Tether Limited公司基于Omni Layer这层协议(Omni Layer protocol)发行tetherUSD,Omni Layer 是基于比特币区块链的通信协议,它实现了智能合约的特性,也就是说tetherUSD就是Omni Layer的一个智能合约。而实现Omni Layer protocol的开源软件项目是Omni Core,tetherUSD在 Omnichest.info 上的资产id是31,可以查看链接:https://omniexplorer.info/asset/31

一、 安装Omni Core

下载源码,按照项目源码里 doc 目录下的相应的build文件编译安装即可,如build-unix.md文件

二、使用regtest测试网络

启动regtest测试网络

y@ubuntu:~$ omnicored -regtest -daemon
Omni Core server starting
y@ubuntu:~$ 2018-07-20 05:34:34 Initializing Omni Core v0.3.0 [regtest]
2018-07-20 05:34:34 Loading trades database: OK
2018-07-20 05:34:34 Loading send-to-owners database: OK
2018-07-20 05:34:34 Loading tx meta-info database: OK
2018-07-20 05:34:34 Loading smart property database: OK
2018-07-20 05:34:34 Loading master transactions database: OK
2018-07-20 05:34:34 Loading fee cache database: OK
2018-07-20 05:34:34 Loading fee history database: OK
2018-07-20 05:34:34 Loading persistent state: NONE (no usable previous state found)
2018-07-20 05:34:34 Exodus balance: 0.00000000 OMNI
2018-07-20 05:34:34 Omni Core initialization completed

y@ubuntu:~$ 

查看区块信息

y@ubuntu:~$ omnicore-cli -regtest getblockchaininfo
{
  "chain": "regtest",
  "blocks": 0,
  "headers": 0,
  "bestblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
  "difficulty": 4.656542373906925e-10,
  "mediantime": 1296688602,
  "verificationprogress": 1,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000000002",
  "pruned": false,
  "softforks": [
    {
      "id": "bip34",
      "version": 2,
      "enforce": {
        "status": false,
        "found": 0,
        "required": 750,
        "window": 1000
      },
      "reject": {
        "status": false,
        "found": 0,
        "required": 950,
        "window": 1000
      }
    }, 
    {
      "id": "bip66",
      "version": 3,
      "enforce": {
        "status": false,
        "found": 0,
        "required": 750,
        "window": 1000
      },
      "reject": {
        "status": false,
        "found": 0,
        "required": 950,
        "window": 1000
      }
    }, 
    {
      "id": "bip65",
      "version": 4,
      "enforce": {
        "status": false,
        "found": 0,
        "required": 750,
        "window": 1000
      },
      "reject": {
        "status": false,
        "found": 0,
        "required": 950,
        "window": 1000
      }
    }
  ],
  "bip9_softforks": {
    "csv": {
      "status": "defined",
      "startTime": 0,
      "timeout": 999999999999
    },
    "segwit": {
      "status": "defined",
      "startTime": 0,
      "timeout": 999999999999
    }
  }
}

挖矿,生成200个区块

y@ubuntu:~$ omnicore-cli -regtest generate 200
[
  "5c512679d25fc36061265b6934c7f4399e978a244765ef28018d956936e57a2a", 
  "2c6e7fc9e148b4903a7a4d44e69ddf3621e4758f5eeaecd471cc783da7b85153", 
  "6885e6742d053ea99b1a4692cb40901c5c2003190f8e6b537ca8b23844e40c1b", 
  "700590c8209602971f28df29e4e8f5af63d73c412f8e2f477a73d91e8b5811be", 

  ....这里省略很多个区块.....

  "1d5621e19633f3911918c91ab35181aa5143d4258f07d8998778dd994d54d23c", 
  "75cc9a35709e8bc491e5585009b75cba92b2ead444fd9edce6dbcd3fd9237fe0", 
  "356b9e5a4e0f66d352bfcb0486be7b6e906fd0a07021df145527c27aa2e1b536"
]

再查询区块信息

y@ubuntu:~$ omnicore-cli -regtest getblockchaininfo
{
  "chain": "regtest",
  "blocks": 200,
  "headers": 200,
  "bestblockhash": "356b9e5a4e0f66d352bfcb0486be7b6e906fd0a07021df145527c27aa2e1b536",
  "difficulty": 4.656542373906925e-10,
  "mediantime": 1532065236,
  "verificationprogress": 1,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000000192",
  "pruned": false,
  "softforks": [
    {
      "id": "bip34",
      "version": 2,
      "enforce": {
        "status": false,
        "found": 200,
        "required": 750,
        "window": 1000
      },
      "reject": {
        "status": false,
        "found": 200,
        "required": 950,
        "window": 1000
      }
    }, 
    {
      "id": "bip66",
      "version": 3,
      "enforce": {
        "status": false,
        "found": 200,
        "required": 750,
        "window": 1000
      },
      "reject": {
        "status": false,
        "found": 200,
        "required": 950,
        "window": 1000
      }
    }, 
    {
      "id": "bip65",
      "version": 4,
      "enforce": {
        "status": false,
        "found": 200,
        "required": 750,
        "window": 1000
      },
      "reject": {
        "status": false,
        "found": 200,
        "required": 950,
        "window": 1000
      }
    }
  ],
  "bip9_softforks": {
    "csv": {
      "status": "started",
      "bit": 0,
      "startTime": 0,
      "timeout": 999999999999
    },
    "segwit": {
      "status": "started",
      "bit": 1,
      "startTime": 0,
      "timeout": 999999999999
    }
  }
}

查看挖矿奖励

y@ubuntu:~$ omnicore-cli -regtest getbalance
5000.00000000

查看钱包默认账户的地址

y@ubuntu:~$ omnicore-cli -regtest getaccountaddress ""
mwwBnJxxcUHu9gaVMMe4Gt7QkbqDEWK5Qk

分配一个新地址

y@ubuntu:~$ omnicore-cli -regtest getnewaddress
musbek3hDYu3wiKc8RSWCFjXAMWChLHJf8

向新地址中转账,这里转10个币

y@ubuntu:~$ omnicore-cli -regtest sendtoaddress musbek3hDYu3wiKc8RSWCFjXAMWChLHJf8 10
321b4a4342b0f28e74cf8c10b016a4973a8f83a66f20e9357215a364f51ada4e

输出的结果是该交易的hash

查看该交易详细信息

y@ubuntu:~$ omnicore-cli -regtest getrawtransaction 321b4a4342b0f28e74cf8c10b016a4973a8f83a66f20e9357215a364f51ada4e
0100000001bef67eb810be01877df0ff51b8b3512c207515f57fdf1797215f94350b0bd3210000000049483045022100f871d1e0a867226fe1a31a127072ca0aabd55b5e3f9c6597d0654d99b85d74e802203015e7a3c1a19e9c39c15ab8e78a659061fef2bf5f19ed951e12f969a7082c7401feffffff0200196bee000000001976a914e3b1368fe79a95ba21616a68518c68e73cd3e67588ac00ca9a3b000000001976a9149d7943969b6cd236c0034d8c347afe5bd4c6399588ac80000000
y@ubuntu:~$ omnicore-cli -regtest decoderawtransaction  0100000001bef67eb810be01877df0ff51b8b3512c207515f57fdf1797215f94350b0bd3210000000049483045022100f871d1e0a867226fe1a31a127072ca0aabd55b5e3f9c6597d0654d99b85d74e802203015e7a3c1a19e9c39c15ab8e78a659061fef2bf5f19ed951e12f969a7082c7401feffffff0200196bee000000001976a914e3b1368fe79a95ba21616a68518c68e73cd3e67588ac00ca9a3b000000001976a9149d7943969b6cd236c0034d8c347afe5bd4c6399588ac80000000
{
  "txid": "321b4a4342b0f28e74cf8c10b016a4973a8f83a66f20e9357215a364f51ada4e",
  "hash": "321b4a4342b0f28e74cf8c10b016a4973a8f83a66f20e9357215a364f51ada4e",
  "size": 192,
  "vsize": 192,
  "version": 1,
  "locktime": 128,
  "vin": [
    {
      "txid": "21d30b0b35945f219717df7ff51575202c51b3b851fff07d8701be10b87ef6be",
      "vout": 0,
      "scriptSig": {
        "asm": "3045022100f871d1e0a867226fe1a31a127072ca0aabd55b5e3f9c6597d0654d99b85d74e802203015e7a3c1a19e9c39c15ab8e78a659061fef2bf5f19ed951e12f969a7082c74[ALL]",
        "hex": "483045022100f871d1e0a867226fe1a31a127072ca0aabd55b5e3f9c6597d0654d99b85d74e802203015e7a3c1a19e9c39c15ab8e78a659061fef2bf5f19ed951e12f969a7082c7401"
      },
      "sequence": 4294967294
    }
  ],
  "vout": [
    {
      "value": 39.99996160,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 e3b1368fe79a95ba21616a68518c68e73cd3e675 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914e3b1368fe79a95ba21616a68518c68e73cd3e67588ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "n2GsyapTapZRzTRqhmUA39AMiRFDibuigs"
        ]
      }
    }, 
    {
      "value": 10.00000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 9d7943969b6cd236c0034d8c347afe5bd4c63995 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a9149d7943969b6cd236c0034d8c347afe5bd4c6399588ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "musbek3hDYu3wiKc8RSWCFjXAMWChLHJf8"
        ]
      }
    }
  ]
}

生成一个区块,使得交易得到确认

y@ubuntu:~$ omnicore-cli -regtest generate 1
[
  "347b3cca07295452df25aeca0a794e4f8de869f66978c32dbba78d041f7c9e0d"
]

查看收到的币

y@ubuntu:~$ omnicore-cli -regtest listreceivedbyaddress
[
  {
    "address": "musbek3hDYu3wiKc8RSWCFjXAMWChLHJf8",
    "account": "",
    "amount": 10.00000000,
    "confirmations": 1,
    "label": "",
    "txids": [
      "321b4a4342b0f28e74cf8c10b016a4973a8f83a66f20e9357215a364f51ada4e"
    ]
  }
]

官网::https://tether.to/
白皮书:https://tether.to/wp-content/uploads/2016/06/TetherWhitePaper.pdf
Omni Core的github项目仓库:https://github.com/OmniLayer/omnicore
关于虚拟货币交易你所不知道的东西丨USDT是啥? Tether(USDT)认识与使用

你可能感兴趣的:(区块链)