下文是在Linux下写的,Linux下没有安装中文输入法,所以全是英文,不过没有复杂单词,阅读难度不大。这篇文章是这几天摸索创建山寨ripple币时的笔记,记录了如何创建新的Ripple创世账本,如何用ripple-api来进行交易。create fake-ripple and test it edit ripple sourcecode to create new Genesis Ledger 1. edit Ledger to create new Genesis Ledger
replace “masterpassphrase” with what you like.
generateSeed("masterpassphrase");
2. log out AccountId and secret of new Genesis Ledger
auto const seed = generateSeed("masterpassphrase");
auto genesisKeyPair = generateKeyPair(KeyType::secp256k1, seed);
PublicKey genesisPublicKey = genesisKeyPair.first;
SecretKey genesisSecretKey = genesisKeyPair.second;
auto const humanSecretKey = toBase58(seed);
static auto const id = calcAccountID(genesisPublicKey);
auto const humanId = toBase58(id);
JLOG(m_journal.warn())
<< " Ledger printPublicKeyAndSecretKey:"
<< " Ledger PublicKey:" << genesisPublicKey
<< " Ledger AccountId:" << id
<< " Ledger HumanAccountId" << humanId
<< " Ledger SecretKey:" << genesisSecretKey.to_string()
<< " Ledger HumanSecretKey:" << humanSecretKey;
run ripple server and use ripple-api to exchange 1. run ripple in stand-alone mode
sudo ./rippled -a --start --conf=/home/along/CLionProjects/ripple-test/cfg/rippled-example.cfg
2. use ripple-api to payment
'use strict';
const RippleAPI = require('ripple-lib').RippleAPI;
// require('ripple-lib')// const address = 'INSERT ADDRESS HERE';
// const secret = 'INSERT SECRET HERE';
const gesisAccount = {
secret: "snoPBrXtMeMyMHUVTgbuqAfg1SUTb",
address: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
};
const myAccount = {
secret: "ssEz4WN91XDhEXCYMS2GXhfCd3Ji5",
address: "r3DoZn2koSVyewVzctLnG2XJSe9nixyGfP"
};
const api = new RippleAPI({ server: 'ws://localhost:6006' });
// const instructions = { maxLedgerVersionOffset: 5 };
const payment = {
source: {
address: gesisAccount.address,
maxAmount: {
value: '10000',
currency: 'XRP'
}
},
destination: {
address: myAccount.address,
amount: {
value: '10000',
currency: 'XRP'
}
}
};
function quit(message) {
console.log(message);
process.exit(0);
}function fail(message) {
console.error(message);
process.exit(1);
}api.connect().then(() => {
console.log('Connected...');
return api.preparePayment(gesisAccount.address, payment)
.then(prepared => {
console.log('Payment transaction prepared...');
console.log(prepared);
const { signedTransaction } = api.sign(prepared.txJSON, gesisAccount.secret);
console.log('Payment transaction signed...');
console.log(signedTransaction);
api.submit(signedTransaction).then(quit, fail);
});
}).catch(fail);
3. advance ripple ledger
【创建Ripple山寨币】
./rippled ledger_accept --conf=/home/along/CLionProjects/ripple-test/cfg/rippled-example.cfg
4. get account info
'use strict';
const gesisAccount = {
secret: "snoPBrXtMeMyMHUVTgbuqAfg1SUTb",
address: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
};
const myAccount = {
secret: "ssEz4WN91XDhEXCYMS2GXhfCd3Ji5",
address: "r3DoZn2koSVyewVzctLnG2XJSe9nixyGfP"
};
const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI({
//server: 'wss://s1.ripple.com' // Public rippled server
server: "ws://localhost:6006"
});
api.connect().then(() => {
/* begin custom code ------------------------------------ */
console.log('getting account info for', myAccount.address);
return api.getAccountInfo(myAccount.address);
}).then(info => {
console.log(info);
console.log('getAccountInfo done');
/* end custom code -------------------------------------- */
}).then(() => {
return api.disconnect();
}).then(() => {
console.log('done and disconnected.');
}).catch(console.error);
我的博客即将搬运同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=27u0vgwevihwc
推荐阅读
- 推动NFT走出监管困境,BSN推出支持NFT基础设施网络
- 腾讯|SaaS的收入模型有哪些(终于有人讲明白了)
- 就业方向上什么才是最重要的(--- 来自程序猿的迷茫。(C++?Java?or算法?))
- 区块链中加密货币的含义
- 波场万倍潜力币HYL23号21:09分 正式上线JustSwap
- 《瀚兰房地产开发区块链应用及案例分享》BSN培训精华回顾
- 对联盟链而言,跨链协议为什么重要()
- 区块链能够应用在哪些行业
- BSN区块链服务网络中密钥托管模式和公钥上传模式有啥区别()
- 币圈人物传|币圈大佬今何在 唯有一诺正当时