其他回答《一招教你使用Node.js中iis部署运行node(附代码)》中,为大家介绍如何使用iis布署运作node。下边本文来给大家掌握EOS区块链技术红心柚钱夹前面软件scatter开发设计,小伙伴们一起来看看一下。
分布式账本红心柚(EOS)钱夹前面软件scatter安装及应用
安装及应用
npm i scatterjs-core scatterjs-plugin-eosjs eosjs -D
//main.js
import ScatterJS from "scatterjs-core";
import ScatterEOS from "scatterjs-plugin-eosjs";
import Eos from "eosjs";
ScatterJS.plugins(new ScatterEOS());
互联网链
// EOS公有链(正式环境)
let main = {
protocol: "https",
blockchain: "eos",
host: "nodes.get-scatter.com",
port: 443,
chainId: "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
};
// 检测链 (是用来测试)
let jungle2 = {
protocol: "http",
blockchain: "eos",
host: "jungle2.cryptolions.io",
port: 80,
chainId: "e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473",
};
调节和配置
翻墙下载scatter
插件安装。
1、开启scatter
---setting
--network
---新创建把jungle2
的信息填到相对应的部位,(取名字随意取,jungle2
)--储存
2、形成密匙对,一键生成公钥和公匙
形成密匙正确的详细地址https://eostea.github.io/eos-generate-key/
3、新创建检测账户,必须填写刚才那公匙,账号名是z-a
,1-5
长短 12 位组成
新创建检测账号详细地址https://monitor.jungletestnet.io/#account
4、在线充值,账户创建成功后莫富有, 可以直接在线充值 100 块。测试情况下省着点用
在线充值地址http://monitor.jungletestnet.io/#faucet
5、检测链上的账户建成以后,开启scatter
---真实身份---新创建,挑选刚刚创建的network
=> jungle2
,然后点击相匹配的账户。点导进---储存
那样scatter
软件配备结束。能够轻松愉快的研发了。
创建scatter
ScatterJS.scatter.connect("app").then((connected) => {
if (!connected) return false;
let scatter = ScatterJS.scatter; //这里是
window.ScatterJS = null;
window.scatter = null;
//根据两种形式取得eos 目标
// this.eos = Eos({ httpEndpoint: '', signatureProvider: ScatterJS.scatter.eosHook(jungle2) });
this.eos = scatter.eos(jungle2, Eos, { expireInSeconds: 60 });
//假如受权取得成功,则能够拿到客户有关信息
if (scatter.identity) {
this.account = scatter.identity.accounts.find(
(x) => x.blockchain === "eos"
);
}
});
受权和取消授权
//受权
const requiredFields = { accounts: [jungle2] };
scatter
.getIdentity(requiredFields)
.then(() => {
//各自取得客户信息 和 eos 目标
this.account = scatter.identity.accounts.find(
(x) => x.blockchain === "eos"
);
this.eos = scatter.eos(jungle2, Eos, { expireInSeconds: 60 }, "https");
})
.catch((res) => {});
//撤出
scatter.forgetIdentity().then((id) => {
this.account = null;
this.eos = null;
});
转帐买卖一部分
//取货币有关信息
let config = {
account: "xxx", //账号名
code: "eosio.token", //合同名字
symbol: "ETH", //货币
};
eos.getCurrencyBalance(config).then((e) => {
console.log(e);
});
//取客户有关信息
eos.getAccount({ account_name: "xxx" }).then((res) => {
// console.log(res)
let totoal = res.core_liquid_balance; //账户余额
let cpu = res.cpu_limit; //CPU
let net = res.net_limit; //NET
});
//进行转帐
// eos.transfer('发送方账号', '接收方账号', '0.3000 DEV','memo', options, callback)
eos
.transfer(account.name, user, `${coin} EOS`, memo, transactionOptions)
.then((trx) => {
// That's it!
console.log(`Transaction ID: ${trx.transaction_id}`);
//有transaction_id 就表明转账成功了
})
.catch((res) => {});
//还可以使用目标
eos.transfer({
from: "发送方账号",
to: "接收方账号",
quantity: "0.1000 DEV",
memo: "备注名称",
callback,
});
互动一部分
// 获得Table行数据信息
eosjs.getTableRows({"scope":'合同名称', "code":'合同名称', "table":"game", "json": true},callback)
//实行合同里的函数公式
eos.contract("合同名称").then(actions => { //actions随意起用户标识符
actions.test('hello', { //test是方法名, 'hello'是这个actions合同test方式的参数
authorization: [{actor:'lilei'}] //lilei是构建该合约的客户
}).then(result => {
console.log(result);
});
自然EOS的API 特别多详细地址:https://developers.eos.io/eosio-nodeos/v1.6.0/reference#get_block但对于前面来讲,之上充足开发一个线上赌博游戏。
对于说发货币啊,布署合同,质押,竞价,售卖,选购,新创建账号这都不需要,能够转至后面。
【完】
强烈推荐学习培训:JS视频教学
以上就是关于浅谈EOS区块链技术红心柚钱夹前面软件scatter开发设计(共享)的具体内容,大量欢迎关注AdminJS其他类似文章!