1.0.26 • Published 5 years ago

eos-wallet-js v1.0.26

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

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/

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago