New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aelf-sdk

Package Overview
Dependencies
Maintainers
4
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aelf-sdk

aelf-sdk js library

  • 3.2.23
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
557
decreased by-11.02%
Maintainers
4
Weekly downloads
 
Created
Source

aelf-sdk.js - AELF JavaScript API

Build Status

Introduction

This is the AElf JavaScript API which connects to the Generic JSON RPC spec.

You need to run a local or remote AElf node to use this library.

Please read the ./docs for more.

Get the examples in the ./examples directory

Installation

Script

<!-- minified version with UMD module -->
<script src="https://unpkg.com/aelf-sdk@lastest/dist/aelf.umd.js"></script>

Npm

npm install aelf-sdk

Yarn

yarn add aelf-sdk

Library files

In our dist directory, we support different packages for different platforms, such as Node and Browser.

packagesusage
dist/aelf.cjs.jsbuilt for node, remove node-built modules such as crypto.
dist/aelf.umd.jsbuilt for browser, add some node modules by webpack

You can choose any packages based on what you need, for examples:

if you are new to FrontEnd, you can use AElf-sdk by add a script tag in your html files.

<!-- minified version with UMD module -->
<script src="https://unpkg.com/aelf-sdk@lastest/dist/aelf.umd.js"></script>

if you want to use a bundle system such as webpack or rollup, and build your applications for Node.js and Browsers, just import the specified version of package files.

For browser usage and use UMD

Webpack:

module.exports = {
  // ...
  resolve: {
    alias: {
      'aelf-sdk': 'aelf-sdk/dist/aelf.umd.js'
    }
  }
}

Rollup:

const alias = require('rollup-plugin-alias');

rollup({
  // ...
  plugins: [
    alias({
      'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.umd.js')
    })
  ]
})

For Node.js usage and use commonjs module system

Webpack:

module.exports = {
  // ...
  resolve: {
    alias: {
      'aelf-sdk': 'aelf-sdk/dist/aelf.cjs.js'
    }
  }
}

Rollup:

const alias = require('rollup-plugin-alias');

rollup({
  // ...
  plugins: [
    alias({
      'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.cjs.js')
    })
  ]
})

Basic usage

import AElf from 'aelf-sdk';

// simple
const aelf = new AElf(new AElf.providers.HttpProvider('https://127.0.0.1:8000'));

init contract and call methods. You can get more demos in ./examples.

// tokenContractAddress = xxx; wallet = xxx;
// We use token contract for example.
// in async function
await aelf.chain.contractAt(tokenContractAddress, wallet);

// promise way
aelf.chain.contractAt(tokenContractAddress, wallet)
  .then(result => {});

// callback way
aelf.chain.contractAt(tokenContractAddress, wallet, (error, result) => {});
  

Additionally you can set a provider using aelf.setProvider()

import AElf from 'aelf-sdk';

const aelf = new AElf(new AElf.providers.HttpProvider('https://127.0.0.1:8000'));
aelf.setProvider(new AElf.providers.HttpProvider('https://127.0.0.1:8010'));

wallet

base on bip39.

import AElf from 'aelf-sdk';

AElf.wallet.createNewWallet();
// wallet.AESDecrypto            wallet.AESEncrypto            wallet.bip39
// wallet.createNewWallet        wallet.getWalletByMnemonic    wallet.getWalletByPrivateKey
// wallet.sign                   wallet.signTransaction

pbjs

almost the same as protobufjs

Sometimes we have to deal with some protobuf data.

pbUtils

Some basic format methods of aelf.

For more information, please see the code in ./lib/aelf/proto.js. It is simple and easy to understand.

    // methods.
    getRepForAddress
    getAddressFromRep
    getAddressObjectFromRep
    getRepForHash
    getHashFromHex
    getHashObjectFromHex
    getTransaction
    getMsigTransaction
    getAuthorization
    getReviewer
    encodeTransaction
    getProposal
    encodeProposal
    getApproval
    encodeApproval
    getSideChainInfo
    getBalance
    encodeSideChainInfo
    Transaction
    Hash
    Address
    Authorization
    Proposal
    ProposalStatus
    SideChainInfo
    SideChainStatus
    ResourceTypeBalancePair

version

import AElf from 'aelf-sdk';
AElf.version // eg. 2.1.10

Contributing

  • All contributions have to go into the dev-2.0 branch

  • Please follow the code style of the other files, we use 4 spaces as tabs.

Requirements

Support

browsers node

About contributing

Read out contributing guide

About Version

https://semver.org/

Keywords

FAQs

Package last updated on 02 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc