npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

seeleteamme.js

v1.7.2

Published

Generic script api library for Seele blockchain

Downloads

9

Readme

SeeleJS

SeeleJS is a generic scripting API library for Seele's blockchain.

Import

NPM

npm install [email protected]

Due to problems with the keccak library, some errors will occur during installation, but if Keccak bindings compilation fail. Pure JS implementation will be used. occurs, it doesn't matter, the package is normal. Follow-up will consider blocking this error.

Browser

Alternatively, if you are in the client/browser you can import seele_browserify.js(github.com/seeleteam/seele.js/browserify/seele_browserify.js) directly , then you can use SeeleJS.

This file is generated using the command and runs browserify -r ./src/seele.js:seele.js > ./browserify/seele_browserify.js in the root folder.

<script src="./browserify/seele_browserify.js"></script>
<script>
const seelejs = require('seele.js');

const client = new seelejs();
client.getInfo().then(data => {
  console.log("data")
  console.log(data)
}).catch(err => {
  console.log("err")
  console.log(err)
})
</script>

Meteor

wangff:[email protected] Or meteor add wangff:[email protected]

Also, when you import seele.js /seele_browerify.js, the global variable SeeleWebProvider is set, so you can use it directly, just like:

const client = new SeeleWebProvider();

client.getInfo().then(data => {
  console.log("data")
  console.log(data)
}).catch(err => {
  console.log("err")
  console.log(err)
})

Example

Async Call

These functions will return a Promise object, you can use then to process the result and use catch to handle the error.

const seelejs = require('seele.js');

const client = new seelejs();
// async - Call mode 1
let sendR = client.send("getInfo");
sendR.then(data => {
    console.log("data")
    console.log(data)
}).catch(err => {
    console.log("err")
    console.log(err)
})

// async - Call mode 2
let execR = client.exec("getInfo");
execR.then(data => {
    console.log("data")
    console.log(data)
}).catch(err => {
    console.log("err")
    console.log(err)
})

// async - Call mode 3
client.getInfo().then(data => {
    console.log("data")
    console.log(data)
}).catch(err => {
    console.log("err")
    console.log(err)
})

Sync Call

const seelejs = require('seele.js');

const client = new seelejs();
// sync - Call mode 1
let info = client.sendSync("getInfo");
console.log(info);

// sync - Call mode 2
let execI = client.execSync("getInfo");
console.log(execI);

Options

You can pass options to the initialization function or use the default options.

const seelejs = require('seele.js');

function seelejs(host, headers, user, password, timeout){
  ...
};

Available options and default values:

  • host(String) : The communication protocol plus the domain name or IP address plus the requested server port. Default: http://localhost:8037.
  • headers(Object) : An object containing request headers, the format must be [{'name':'', 'vaule':''}, {'name':'', 'vaule':''}...].
  • user(String) : Basic authentication i.e. 'user:password' to compute an Authorization header. Not used.
  • password(String) : Basic authentication i.e. 'user:password' to compute an Authorization header. Not used.
  • timeout(Number) : timeout A number specifying the socket timeout in milliseconds. This will set the timeout before the socket is connected. Default: 30000.

Methods

The Seele API is supported as direct methods. Use camelcase and lowercase first letter.

client.getInfo().then(data => {
    console.log("data")
    console.log(data)
}).catch(err => {
    console.log("err")
    console.log(err)
})

.send(command [string], ...arguments..., callback [function])

Sends the given command with optional arguments. Function callback defaults to console.log. All of the API commands are supported in camelcase and lowercase first letter.

client.send("getBlock", "", 1, false).then(data => {
    console.log("data")
    console.log(data)
}).catch(err => {
    console.log("err")
    console.log(err)
})

.sendSync(command [string], ...arguments...)

Sends the given command with optional arguments. This function will return a Promise object, and you can use to handle the result. All of the API commands are supported in camelcase and lowercase first letter.

var result = client.sendSync("getInfo")
console.log("sendSync"+JSON.stringify(result))

.exec(command [string], ...arguments..., callback [function])

Executes the given command with optional arguments. Function callback defaults to console.log. All of the API commands are supported in camelcase and lowercase first letter.

client.exec("getInfo");

client.exec("getInfo").then(data => {
    console.log("data")
    console.log(data)
}).catch(err => {
    console.log("err")
    console.log(err)
})

.execSync(command [string], ...arguments...)

Executes the given command with optional arguments. This function will return a Promise object, and you can use to handle the result. All of the API commands are supported in camelcase and lowercase first letter.

var result = client.execSync("getInfo")
console.log("execSync"+JSON.stringify(result))

.generateTx(privatekey [Hex String], rawTx [JSON String]) return tx [Object]

Generate transaction and sign, the rawTx must be in the example format, otherwise an error will occur.

var privatekey = "0x24ce9cadcc9207c94296db166ab7a0fa686f2a6d29f7ea54fe8c22271c40812e"
var rawTx = {
  "From":"0xa61e5b0b30e91c4ae10dda3a6ddeb9d9d35ebfe1",
  "To":"0x0000000000000000000000000000000000000000",
  "Amount":0,
  "AccountNonce":123,
  "GasPrice":1,
  "GasLimit":3000000,
  "Timestamp":0,
  "Payload":""
}

tx = generateTx(privatekey, rawTx)

.filterBlockTx(height [Number], address [Hex String], flag [Number]) return txs [Array - tx JSON]

Filtering transactions for a specific address based on block height, an error occurs if the block height does not exist. If the height is -1, it will filter the current block. When the flag is 1, the transaction from equal to the address is filtered in the block. When the flag is 2, the transaction to equal to the address is filtered in the block.

var txs = client.filterBlockTx(-1, "0x4c10f2cd2159bb432094e3be7e17904c2b4aeb21", "2")
console.log("sync:"+JSON.stringify(txs))

Properties

.wallet

This object is used to create the Seele account and export/import the keystore file.

  • shardnum(Number) : The Seele shard number. Default: 2.
  • accounts(Array) : The accounts[i] means the wallet contains the accounts of the shard i+1. Default: [[],[]].

Method

.create() return keypair [JSON String, contains 'publickey' and 'privatekey']

Create a Seele account for the random shard.

let keypair = client.wallet.create()
console.log(keypair)
.createbyshard(shard [Number]) return keypair [JSON String, contains 'publickey' and 'privatekey' Hex String]

Create a Seele account for the specified shard.

let keypair = client.wallet.createbyshard(2)
console.log(keypair)
.getshardnum(publickey [Hex String]) return shard [Number]

Calculate the shard of the publickey.

let keypair = client.wallet.create()
let shard = client.wallet.getshardnum(keypair.publickey)
console.log(shard)