This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

symjs

1.0.6 • Public • Published

Symverse Wallet JavaScript API

It provides json rpc communication interface and development library with symverse blockchain, rpc api.
npm: https://www.npmjs.com/package/symjs

Installation

Node.js

npm i symjs

Yarn

yarn add symjs

A minified, browserified file dist/symjs.js is included for use in the browser. Including this file simply attaches the symjs object to window:

<script src='dist/symjs.js'></script>

Usage

Use the symjs object directly from the global namespace:

console.log(SymJs)  // { utils: ...} 
 
const symjs = new SymJs();
console.log(symjs); // {network: ..., utils: ..., signer: ...} 

Network connect(symverse rpc)

const symjs = new SymJs();
symjs.network.connect("http://localhost:8001").then(connectedMessage => {
    console.log(connectedMessage, 'connect success...')
}).catch(e => {
    // connected fail...
})

There you go, now you can use it:

// Return Promise Object By Json RPC   
symjs.network.call.getBalance(address); 
symjs.network.call.clientVersion();
  • Send Raw Transaction example:
let privateKey = "2a43aa399cb2efe186317e0b09f4a7ef88b83cff05089b145709881bf4db3a20"
let params = {
    from:"0x00021000000000010002",
    nonce: 210,
    gasPrice: 1000000000000,
    gasLimit: 41000,
    to: "0x00021000000000020002",
    value: 5,
    workNodes: ["0x00021000000000010002"],
    chainId: 7777 //require
};
// Return Promise Object By Json RPC   
symjs.network.call.sendTransaction(params, privateKey);
  • Send SCT Raw Transaction example:
//sct input tools
symjs.param.sct20.create("HI","asd", 12323, "0x00021000000000010002")
symjs.param.sct20.transfer(to, amount)
symjs.param.sct20.transferFrom(from, to, amount)
symjs.param.sct20.approve(to, amount)
 
symjs.param.sct21 ...
symjs.param.sct30 ...
symjs.param.sct40 ...
...
let privateKey = "1a43aa399cb2efe186317e0b09f4a7ef88b83cff05089b145709881bf4db3a20"
let params = {
    from: "0x00021000000000010002",
    nonce: 214,
    gasPrice: '0x09184e72a000000',
    gasLimit: '0x271000',
    workNodes: ["0x00021000000000010002"],
    type: 1,
    input: "0x"+symjs.param.sct20.create("HI","asd", 12323, "0x00021000000000010002").raw(),
    chainId: 7777
};
 
// Return Promise Object By Json RPC   
symjs.network.call.sendTransaction(params, privateKey);
  • Citizen api call example:
// Return Promise Object By Json RPC   
let citizenInfo = await symjs.network.call.citizen.getCitizenBySymID("0x00021000000000010002")
let count = await symjs.network.call.citizen.getCitizenCount()
  • Warrant api call example:
// Return Promise Object By Json RPC   
let blockNumber = await symjs.network.call.warrant.blockNumber()
  • Sct api call example:
// Return Promise Object By Json RPC   
let constract = await symjs.network.call.sct.getContract("0x4523ad7875a9c41e9629")
let account = await symjs.network.call.sct.getContractAccount("0x4523ad7875a9c41e9629", "0x00021000000000010002")

Contact

https://www.symverse.com/
Please contact us on this page.

Package Sidebar

Install

npm i symjs

Weekly Downloads

1

Version

1.0.6

License

MPL-2.0

Unpacked Size

1.57 MB

Total Files

30

Last publish

Collaborators

  • itsinil