YOYOW开发笔记

in hive-180932 •  3 years ago 

yoyow.jpg

下载与资源:

文档 |
平台接入
区块浏览器
github
js

节点

https://api-bj.yoyow.one

获取帐户基础数据

curl --data '{"jsonrpc": "2.0", "method": "call", "params": [0, "get_accounts_by_uid", [["384452518"]]], "id": 1}' https://api-bj.yoyow.one

curl --data '{"jsonrpc": "2.0", "method": "call", "params": [0, "get_account_balances", ["384452518", [0,1]]], "id": 1}' https://api-bj.yoyow.one

//vue.js
axios.request({
    method: 'post',
    url: 'https://api-bj.yoyow.one',
    headers: {'X-Requested-With': 'XMLHttpRequest',     
              "Content-Type": "application/json;charset=utf-8"},                    
    data: {"jsonrpc": "2.0", "method": "call", "params": [0, "get_accounts_by_uid", [["3856899855"]]], "id": 1}
})
.then( (arg) => {
    console.log(5889,arg)  
})
.catch((error) => {
    console.log(333,error)
})

查询帐户历史数据

curl --data '{"jsonrpc": "2.0", "method": "call", "params": ["history", "get_relative_account_history", [384452518, null, 1,3,10]], "id": 1}' https://api-bj.yoyow.one 

//vue.js
//以384452518为例,查询最近的10条记录
axios.request({
    method: 'post',
    url: 'https://api-bj.yoyow.one',
    headers: {'X-Requested-With': 'XMLHttpRequest',     
              "Content-Type": "application/json;charset=utf-8"},                    
    data: {"jsonrpc": "2.0", "method": "call", "params": ["history", "get_relative_account_history", [384452518, null, 0,10,0]], "id": 1}
})
.then( (arg) => {
    console.log(255,arg)  
    })
.catch((error) => {
    console.log(333,error)
})

历史数据类型说明

history2.png

查询用户发贴

以币问平台(375867735)为例,以用户365964252来查询

//get_post
curl --data '{"jsonrpc": "2.0", "method": "call", "params":[0,"get_post",["375867735","365964252",10]], "id": 0}' https://api-bj.yoyow.one

curl --data '{"jsonrpc": "2.0", "method": "call", "params":[0,"get_posts_count",["375867735","365964252"]], "id": 1}' https://api-bj.yoyow.one

查询平台的发帖

curl --data '{"id":1, "method":"call", "params":[0,"get_posts_by_platform_poster",[375867735, null,"1.8.0", 100]]}' https://api-bj.yoyow.one

//"1.8.0"表示 这次查询起始的 oid 编号。

//遍历查询:先执行 curl --data '{"id":1, "method":"call", "params":[0,"get_posts_by_platform_poster",[375867735, null,"1.8.0", 10]]} '  ,返回10条记录。 第10条记录oid 是 1.7.122461 ,查询接下来的10条,再执行 curl --data '{"id":1, "method":"call", "params":[0,"get_posts_by_platform_poster",[375867735, null,"1.7.122461", 10]]} '

解密memo

//https://github.com/yoyow-org/yoyowjs-lib ->dist
let {Aes, PrivateKey} = require("./dist")

var priv_wif = "5xxxxxxxx";  //解密方账号memo prive key
var public_key =  "YYW5xxxxx";  //对方账号memo public key
var nonce = "42050555";
var message = "540d5555";

var priv_key = PrivateKey.fromWif(priv_wif); 

var memo_plain = Aes.decrypt_with_checksum(
    priv_key,
    public_key,
    nonce,
    message
).toString("utf-8");

console.log(memo_plain);

转帐

let {Apis} = require("yoyowjs-ws")
let {ChainStore, PrivateKey, TransactionHelper} = require("./dist")

let from = 365964252
let to = 384452518
let active_key = "xxx"
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
let private_key = PrivateKey.fromWif(active_key)
let amount = { amount: 180000, asset_id: 0 }
let op_data = { from, to, amount }

let transfer = async () => {
    console.log(11, "transfer start")
    let fees = await TransactionHelper.process_transaction('transfer', op_data, from)
    console.log('get fees : ', fees)
    let result = await TransactionHelper.process_transaction('transfer', op_data, from, true, true, private_key, true)
    console.log('process result : ', result)
    console.log(22, "end")
   // process.exit(0)
}

Apis.instance("https://api-bj.yoyow.one", true)
    .init_promise.then((res) => {
    console.log("connected to:", res[0].network_name, "network")
    ChainStore.init().then(() => transfer())
});
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!