Giter Site home page Giter Site logo

eos-wallet-js's Introduction

[TOC]

eos-wallet-js

简介

eos-wallet-js是一个适配了多款钱包的JS-SDK,为了方便DApp开发者快速开发DApp并上线多款主流钱包,本项目采用统一的API接口。

目前已经对接的钱包应用包括: Scatter、TokenPacket、MeetOne、麦子钱包、比特派、EOSToken

未来我们希望能够将本项目做成一套通用的标准协议,正在与各大钱包厂商协商

如果您的钱包项目愿意添加到本项目中,请联系我们:

微信:

telegram: https://t.me/eoswalletjs

示例程序

注意

如果在chrome浏览器打开,请先配置好Scatter钱包 chrome插件的主网信息为:api.eosbeijing.one节点的信息

git clone https://github.com/yuanjunliang/eos-wallet-js.git
cd eos-wallet-js
git checkout -b test origin/test
yarn install
npm start

API接口

用法

  • 安装钱包
npm install eos-wallet-js --save
或
yarn add eos-wallet-js
  • 使用
const network = {
    blockchain:'eos',
    protocol:'https',
    host:'api.eosbeijing.one',
    port:443,
    chainId:"aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906"
}

const config = {
    dappName:"dapp",        // required:true
    initTimeout:5000,       // required:false default:5000 connect to scatter timeout
    to:"yuanjunliang"
}

import EOSWallet from 'eos-wallet-js'
// create wallet
const Wallet = EOSWallet(network,config)

注:

以下所有接口都支持Promise和async/await的方式调用

  • connect
// connect to wallet
Wallet.connect((connected)=>{})
  • getIdentity
// get account identity
Wallet.getIdentity((error,account)=>{
	console.log(error,account)
})
  • forgetIdentity
// forget account identity
Wallet.forgetIdentity()
  • getBalance
// get account current balance
let params = {
    accountName:"",
    code:"",    // default "eosio.token"
    symbol:""   // default "EOS"
}
Wallet.getBalance(params,(error,response)=>{})
  • getAccount
// get account info
Wallet.getAccount(accountName,(error,response)=>{})
  • transfer
// transfer
let params = {
    from: string,
    to: string,
    count: number|string,
    precision: number|string,  // default:4
    memo: string
}
Wallet.transfer(params,(error,response)=>{
	console.log(error,response)
})
  • pushTransaction
// pushTransaction : call contract method
// 该方法用于调用一些智能合约接口
let action = {
    actions: [{
      account: 'eosio.token',
      name: 'transfer',
      authorization: [{
        actor: 'useraaaaaaaa',
        permission: 'active',
      }],
      data: {
        from: 'useraaaaaaaa',
        to: 'useraaaaaaab',
        quantity: '0.0001 SYS',
        memo: '',
      },
    }]
}

let blocksBehind = {
    blocksBehind: 3,
    expireSeconds: 30,
}

let params = [action,blocksBehind]
Wallet.pushTransaction(params,(error,response)=>{})
  • eosjs api
// 其他eosjs api方法,查看eos模块
Wallet.eos

eosjs api 接口调用方法请参考:https://eosio.github.io/eosjs/

eos-wallet-js's People

Contributors

yuanjunliang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.