=====节点搭建部署===== https://hub.docker.com/r/stellar/quickstart/ ===安装Docker=== http://www.runoob.com/docker/centos-docker-install.html sudo systemctl enable docker #拉取镜像 sudo docker pull stellar/quickstart #启动docker 需要先用下面第一行命令,交互式的执行初始化,完毕以后,再Ctrl+C杀掉进程,用第二条命令在后台执行 sudo docker run --rm -it -p "8000:8000" -p "11626:11626" -p "11625:11625" -v "/home/scott/stellar:/opt/stellar" --name stellar stellar/quickstart --pubnet (--testnet) sudo docker run --rm -d -p "8000:8000" -p "11626:11626" -p "11625:11625" -v "/home/scott/stellar:/opt/stellar" --name stellar stellar/quickstart --pubnet (--testnet) #查看docker日志 sudo docker logs -f stellar #进入某个容器 sudo docker exec -it stellar /bin/bash #stellar日志在如下位置 /var/log/supervisor/ =====相关概念===== ===TestNet=== https://www.stellar.org/developers/guides/concepts/test-net.html ===Ledger=== https://www.stellar.org/developers/guides/concepts/ledger.html ===账户最低余额=== https://www.stellar.org/developers/guides/concepts/fees.html#minimum-account-balance [[https://github.com/stellar/stellar-core/blob/master/src/xdr/Stellar-ledger-entries.x|账本结构]] ===构建交易=== https://www.stellar.org/developers/guides/get-started/transactions.html ===测试账号激活=== https://friendbot.stellar.org/?addr=GA5CCGUJMIHZ7ZNP6ZHSONQNRUQX2Z32ZOJ2XMA4VOCR54IRSLBNQ36T =====JavascriptSDK===== 创建地址 const express = require('express'); const fs = require('fs'); const router = express.Router(); const config = require('../config'); var StellarSdk = require('stellar-sdk'); if(config.network === "pubnet") StellarSdk.Network.usePublicNetwork(); else StellarSdk.Network.useTestNetwork(); router.get('/', function(req, res, next) { var pair = StellarSdk.Keypair.random(); pair.secret(); pair.publicKey(); const address = pair.publicKey(); const secret = pair.secret(); let filename = "./privatekey/"+address; fs.writeFile(filename, secret, function(err) { if (err) { return res.end(err.toString()); } }); res.end(address); }); module.exports = router; 创建交易 const express = require('express'); var xdr = require("js-xdr"); const config = require('../config'); var StellarSdk = require('stellar-sdk'); var StellarBase = require('stellar-base'); const router = express.Router(); if(config.network === "pubnet") StellarSdk.Network.usePublicNetwork(); else StellarSdk.Network.useTestNetwork(); StellarSdk.Config.setAllowHttp(true); var domain = config.domain; var server = new StellarSdk.Server(domain); router.get('', function(req, res, next) { var fromAddress = req.query.fromAddress; const toAddress = req.query.toAddress; const value = req.query.value; const memo = req.query.memo; var transaction; server.loadAccount(toAddress) // If the account is not found, surface a nicer error message for logging. // .catch(StellarSdk.NotFoundError, function (error) { // res.end("目的地址不正确!") // throw new Error('The destination account does not exist!'); // }) // If there was no error, load up-to-date information on your account. .then(function() { return server.loadAccount(fromAddress); }) .then(function(sourceAccount) { transaction = new StellarSdk.TransactionBuilder(sourceAccount) .addOperation(StellarSdk.Operation.payment({ destination: toAddress, // Because Stellar allows transaction in many currencies, you must // specify the asset type. The special "native" asset represents Lumens. asset: StellarSdk.Asset.native(), amount: String(value) })) // A memo allows you to add your own metadata to a transaction. It's // optional and does not affect how Stellar treats the transaction. .addMemo(StellarSdk.Memo.text(String(memo))) .build(); let envelope = transaction.toEnvelope().toXDR('base64'); res.end(envelope); }) .catch(function (error) { console.log(error.toString()) res.end(error.toString()) }); }); module.exports = router; 给未激活的账户转账,就需要调用创建账户接口 const express = require('express'); var xdr = require("js-xdr"); const config = require('../config'); var StellarSdk = require('stellar-sdk'); var StellarBase = require('stellar-base'); const router = express.Router(); if(config.network === "pubnet") StellarSdk.Network.usePublicNetwork(); else StellarSdk.Network.useTestNetwork(); StellarSdk.Config.setAllowHttp(true); var domain = config.domain; var server = new StellarSdk.Server(domain); router.get('', function(req, res, next) { var fromAddress = req.query.fromAddress; const toAddress = req.query.toAddress; const value = req.query.value; const memo = req.query.memo; var transaction; //server.loadAccount(toAddress) // If the account is not found, surface a nicer error message for logging. // .catch(StellarSdk.NotFoundError, function (error) { // res.end("目的地址不正确!") // throw new Error('The destination account does not exist!'); // }) // If there was no error, load up-to-date information on your account. //.then(function() { // return server.loadAccount(fromAddress); //}) server.loadAccount(fromAddress) .then(function(sourceAccount) { transaction = new StellarSdk.TransactionBuilder(sourceAccount) .addOperation(StellarSdk.Operation.createAccount({ destination: toAddress, startingBalance: String(value) })) // A memo allows you to add your own metadata to a transaction. It's // optional and does not affect how Stellar treats the transaction. .addMemo(StellarSdk.Memo.text(String(memo))) .build(); let envelope = transaction.toEnvelope().toXDR('base64'); res.end(envelope); }) .catch(function (error) { console.log(error.toString()) res.end(error.toString()) }); }); module.exports = router; =====资料收集===== https://www.stellar.org/developers/js-stellar-sdk/reference/ 编译部署流程: https://galactictalk.org/d/20-setting-up-stellar-core-on-centos-7 ======编译过程(使用docker这段暂时废弃)====== sudo yum groupinstall 'Development Tools' sudo yum install postgresql-devel git clone https://github.com/stellar/stellar-core.git git checkout v0.5.0 # Check out the latest stable version git submodule init git submodule update ./autogen.sh ./configure --------------------------------------- 这一步报错:No package 'libpq' found 建立如下文件,然后拷贝下面的内容。 /usr/lib64/pkgconfig/libpq.pc: prefix=/usr libdir=${prefix}/lib64 includedir=${prefix}/include/pgsql Name: LibPQ Version: 5.5.0 Description: PostgreSQL client library Requires: Libs: -L${libdir}/libpq.so -lpq Cflags: -I${includedir} --------------------------------------- yum install pandoc make -j 2 make check # Runs the tests sudo make install