成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專(zhuān)欄INFORMATION COLUMN

eos 區(qū)塊鏈采坑,scatter 錢(qián)包

張漢慶 / 1806人閱讀

摘要:做個(gè)有理想的碼農(nóng),坑定的有多少的了解下當(dāng)下最火的技術(shù),提到區(qū)塊鏈不懂也的了解下。有人說(shuō)現(xiàn)在的區(qū)塊鏈哀聲遍野,在這個(gè)互聯(lián)網(wǎng)寒冬下,有多少的區(qū)塊鏈公司,在這個(gè)寒冬倒下,現(xiàn)在的各種的數(shù)字貨幣,炒幣的,挖礦的的,,烏煙瘴氣。。。。。

做個(gè)有理想的碼農(nóng) ,坑定的有多少的了解下當(dāng)下最火的技術(shù),提到區(qū)塊鏈 不懂也的 了解下。
有人說(shuō)現(xiàn)在的區(qū)塊鏈哀聲遍野,在這個(gè)互聯(lián)網(wǎng)寒冬下,有多少的區(qū)塊鏈公司,在這個(gè)寒冬倒下,現(xiàn)在的各種的 數(shù)字貨幣,炒幣的,挖礦的的,,烏煙瘴氣。。。。。

進(jìn)入正題,最近了解下 eos 寫(xiě)了 然后調(diào)用 scatter錢(qián)包時(shí)個(gè)各種各樣的的錯(cuò),屬實(shí)讓人頭疼,這里我 我總結(jié)下了,給自己留個(gè)筆記

import iView from "iview";
import i18n from "@/locale"
import config from "@/config"
import ScatterJS from "scatterjs-core"
import ScatterEOS from "scatterjs-plugin-eosjs"
import Eos from "eosjs";
import {GetQueryString} from "../libs/geturl";
window.ScatterJS = null;

// const eosconfig =process.env.NODE_ENV === "development" ? config.eosConfig.dev : config.eosConfig.pro;

const eosconfig = GetQueryString("dev") != "true" ? config.eosConfig.pro : config.eosConfig.dev;


class getscatter {
    static account;
    static eos;
    static  scatter;
    static instance;


    constructor() {

    }

    ScatterSecureCall(func) {
        const network = ScatterJS.Network.fromJson(eosconfig);
        var app_name = "dada_poker";

        if (ScatterJS.scatter.eos == null) {
            ScatterJS.plugins(new ScatterEOS());
        }
        ScatterJS.scatter.connect(app_name).then(connected => {
            if (connected) {
                const scatter = ScatterJS.scatter;
                scatter.getIdentity({
                    accounts: [network]
                }).then(() => {
                    const scatter = ScatterJS.scatter;
                    const account = scatter.identity.accounts.find(x => x.blockchain === "eos");
                    const eosOptions = {
                        expireInSeconds: 60
                    };
                    const eos = scatter.eos(network, Eos, eosOptions);
                    func(scatter, account, eos);

                }).catch(error => {
                    // document.getElementById("box").innerHTML = format_json(error);
                    console.log(error);
                    iView.Message.error({
                        top: 70,
                        content: JSON.stringify(error),
                        duration: 10
                    });
                });
            } else {
                console.log("The Scatter interface call failed! Please install the Scatter plugin or launch the Scatter app");
                // document.getElementById("box").innerHTML = "Scatter接口調(diào)用失敗!請(qǐng)安裝Scatter插件或者啟動(dòng)Scatter應(yīng)用程序。";
                iView.Message.error({
                    top: 70,
                    content: i18n.t("login_error"),
                    duration: 10
                });
            }
        })
    }

    eosGetIdentity(callback) {
        console.log("enter eosGetIdentity");
        this.ScatterSecureCall((scatter, account, eos) => {
            console.log("[eosGetIdentity] account = ", account);
                this.account = account;
                this.eos = eos;
                this.scatter =scatter
                callback && callback(scatter, this.account, this.eos);
        });
    }

    eosTransfer(to, quantity, memo, callback) {
        if (this.account == null || this.eos == null) {
            console.log("you must eosGetIdentity");
            this.eosGetIdentity(() => {
                this.eosTransfer(to, quantity, memo, callback);
            });
        } else {
            this.eos.contract("eosio.token").then(contract => {
                const transactionOptions = {authorization: [`${this.account.name}@${this.account.authority}`]};
                contract.transfer(this.account.name, to, quantity, memo, transactionOptions).then(transaction => {
                    console.log("eosTransfer transaction processed object: %d", transaction.processed);
                    if (null != callback) {
                        callback(transaction);
                    }
                }).catch(error => {
                    if (typeof error == "string") {
                        error = JSON.parse(error);
                        let errorMsg = error.error.details[0].message;
                        iView.Message.error({
                            top: 70,
                            content: errorMsg,
                            duration: 10
                        });
                        // alert(errorMsg); //todo
                    }
                    iView.Message.error({
                        top: 70,
                        content: error,
                        duration: 10
                    });
                });
            }).catch(error => {
                console.log(error);
                iView.Message.error({
                    top: 70,
                    content: error,
                    duration: 10
                });
            });
        }
    }

    eosRedeem(quantity, to, callback) {
        if (this.account == null || this.eos == null) {
            console.log("you must eosGetIdentity");
            this.eosGetIdentity(() => {
                this.eosRedeem(quantity, memo, callback);
            });
        } else {
            this.eos.contract(to).then(contract => {
                const transactionOptions = {
                    authorization: [`${this.account.name}@${this.account.authority}`]
                };
                contract.redeem(this.account.name, quantity, transactionOptions).then(transaction => {
                    console.log("eosTransfer transaction processed object: ", transaction.processed);
                    if (null != callback) {
                        callback(transaction);
                    }
                }).catch(error => {
                    if (typeof error == "string") {
                        error = JSON.parse(error);
                        let errorMsg = error.error.details[0].message;
                        iView.Message.error({
                            top: 70,
                            content: errorMsg,
                            duration: 10
                        });

                    }
                    console.log(error);
                    iView.Message.error({
                        top: 70,
                        content: error,
                        duration: 10
                    });
                })
            }).catch(error => {
                console.log(error);
                iView.Message.error({
                    top: 70,
                    content: error,
                    duration: 10
                });
            });
        }
    }

    eosLogin(callback) {
        if (this.account == null || this.eos == null) {
            console.log(11);
            this.eosGetIdentity(() => {
                console.log(this.account);
                this.eosLogin(callback);
            });
        } else {
            ScatterJS.login().then(res => {
                console.log(res);
                callback(res, this.account)
            }).catch((error) => {
                iView.Message.error({
                    top: 70,
                    content: error,
                    duration: 10
                });
            })
        }
    }

    eosLogout(callback) {
        if (this.account == null || this.eos == null) {
            this.eosGetIdentity(() => {
                this.eosLogout(callback)
            })
        } else {
            ScatterJS.logout().then(res => {
                try{//App
                    this.scatter.isConnected()
                    this.account = null;
                    this.eos = null;
                }catch (e) {//瀏覽器
                    // throw  new Error("瀏覽器插件")
                    console.log(e);

                }
                callback && callback(res)
                window.ScatterJS = null;
            }).catch(error => {
                iView.Message.error({
                    top: 70,
                    content: error,
                    duration: 10
                });
            })
        }
    }


}

const ScatterSecureCall = new getscatter();

export {
    // ScatterJS,
    ScatterSecureCall
}

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/24596.html

相關(guān)文章

  • 使用EOSJS和scatterEOS區(qū)塊鏈上開(kāi)發(fā)dApp

    摘要:必備知識(shí)設(shè)置用于為區(qū)塊鏈簽署交易,并在不泄露密鑰的情況下向應(yīng)用程序提供個(gè)人信息。 由于我一直在深入研究EOS dApp的開(kāi)發(fā),我看了不少好文章。在這里,我匯總了下做一些研究后得到的所有知識(shí)。在本文中,我將解釋如何使用EOSJS和scatter。我假設(shè)你對(duì)智能合約以及如何在EOS區(qū)塊鏈上部署它們有基本的了解,因?yàn)槲覍⒃诒疚闹刑^(guò)該部分。 我們?cè)跇?gòu)建什么? ?我們正在構(gòu)建一個(gè)簡(jiǎn)單的todo...

    Mr_houzi 評(píng)論0 收藏0
  • 使用EOSJS和scatterEOS區(qū)塊鏈上開(kāi)發(fā)dApp

    摘要:必備知識(shí)設(shè)置用于為區(qū)塊鏈簽署交易,并在不泄露密鑰的情況下向應(yīng)用程序提供個(gè)人信息。 由于我一直在深入研究EOS dApp的開(kāi)發(fā),我看了不少好文章。在這里,我匯總了下做一些研究后得到的所有知識(shí)。在本文中,我將解釋如何使用EOSJS和scatter。我假設(shè)你對(duì)智能合約以及如何在EOS區(qū)塊鏈上部署它們有基本的了解,因?yàn)槲覍⒃诒疚闹刑^(guò)該部分。 我們?cè)跇?gòu)建什么? ?我們正在構(gòu)建一個(gè)簡(jiǎn)單的todo...

    mumumu 評(píng)論0 收藏0
  • 使用EOSJS和scatterEOS區(qū)塊鏈上開(kāi)發(fā)dApp

    摘要:必備知識(shí)設(shè)置用于為區(qū)塊鏈簽署交易,并在不泄露密鑰的情況下向應(yīng)用程序提供個(gè)人信息。 由于我一直在深入研究EOS dApp的開(kāi)發(fā),我看了不少好文章。在這里,我匯總了下做一些研究后得到的所有知識(shí)。在本文中,我將解釋如何使用EOSJS和scatter。我假設(shè)你對(duì)智能合約以及如何在EOS區(qū)塊鏈上部署它們有基本的了解,因?yàn)槲覍⒃诒疚闹刑^(guò)該部分。 我們?cè)跇?gòu)建什么? ?我們正在構(gòu)建一個(gè)簡(jiǎn)單的todo...

    xiaodao 評(píng)論0 收藏0
  • 使用docker compose在EOS本地Testnet上開(kāi)發(fā)

    摘要:為本地配置的錢(qián)包。以太坊,主要是針對(duì)工程師使用進(jìn)行區(qū)塊鏈以太坊開(kāi)發(fā)的詳解。以太坊,主要是介紹使用進(jìn)行智能合約開(kāi)發(fā)交互,進(jìn)行賬號(hào)創(chuàng)建交易轉(zhuǎn)賬代幣開(kāi)發(fā)以及過(guò)濾器和交易等內(nèi)容。這里是如何使用和在本地上開(kāi)發(fā) EOS區(qū)塊鏈的開(kāi)發(fā)并不是立竿見(jiàn)影的,因?yàn)樾枰恍┓秋@而易見(jiàn)的組件,需要對(duì)它們進(jìn)行配置和協(xié)同工作。 nodeos:塊生成器守護(hù)程序。 keosd:錢(qián)包守護(hù)進(jìn)程,存儲(chǔ)私鑰。 eosio-cp...

    cod7ce 評(píng)論0 收藏0
  • 【許曉笛】EOS 系統(tǒng)架構(gòu)圖解

    摘要:了解系統(tǒng)架構(gòu)之前我們先看看目前系統(tǒng)的主要組成部分系統(tǒng)的核心進(jìn)程,也就是所謂的節(jié)點(diǎn)。 其實(shí)沒(méi)有那么復(fù)雜 相信關(guān)心 EOS 系統(tǒng)的同學(xué)肯定見(jiàn)過(guò)下面這張藍(lán)圖。對(duì),目前只是一個(gè)藍(lán)圖,而且以 BM 的尿性,肯定在心理已經(jīng)把這張圖改的面目全非了(比如圖中的 eosd 早就改名了)。所以這張圖只能作為未來(lái) EOS 發(fā)展方向的參考而已,目前的 EOS 還遠(yuǎn)沒(méi)有這么復(fù)雜和完善。 showImg(http...

    vibiu 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<